mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 09:01:04 -05:00
fix(cli): Don't crash on races
I misused `compare_exchange` when I didn't even really need it. Fixes #284
This commit is contained in:
parent
5304d94fb7
commit
655b6571bd
2 changed files with 10 additions and 15 deletions
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
<!-- next-header -->
|
<!-- next-header -->
|
||||||
## [Unreleased] - ReleaseDate
|
## [Unreleased] - ReleaseDate
|
||||||
|
|
||||||
|
#### Bug Fixes
|
||||||
|
|
||||||
|
- Fix a crash from hitting a race condition
|
||||||
|
|
||||||
## [1.0.8] - 2021-06-15
|
## [1.0.8] - 2021-06-15
|
||||||
|
|
||||||
## [1.0.7] - 2021-06-15
|
## [1.0.7] - 2021-06-15
|
||||||
|
|
|
@ -59,21 +59,12 @@ impl<'r> MessageStatus<'r> {
|
||||||
|
|
||||||
impl<'r> Report for MessageStatus<'r> {
|
impl<'r> Report for MessageStatus<'r> {
|
||||||
fn report(&self, msg: Message) -> Result<(), std::io::Error> {
|
fn report(&self, msg: Message) -> Result<(), std::io::Error> {
|
||||||
let _ = self.typos_found.compare_exchange(
|
if msg.is_correction() {
|
||||||
false,
|
self.typos_found.store(true, atomic::Ordering::Relaxed);
|
||||||
msg.is_correction(),
|
}
|
||||||
atomic::Ordering::Relaxed,
|
if msg.is_error() {
|
||||||
atomic::Ordering::Relaxed,
|
self.errors_found.store(true, atomic::Ordering::Relaxed);
|
||||||
);
|
}
|
||||||
let _ = self
|
|
||||||
.errors_found
|
|
||||||
.compare_exchange(
|
|
||||||
false,
|
|
||||||
msg.is_error(),
|
|
||||||
atomic::Ordering::Relaxed,
|
|
||||||
atomic::Ordering::Relaxed,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
self.reporter.report(msg)
|
self.reporter.report(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue