Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent race condition in Notifier#run / #stop
There is a potential race condition when a notifier is run in a new thread and then immediately stopped in the original thread. If `Notifier#stop` sets `@stop = true` before `Notifier#run` sets `@stop = false`, then `Notifier#run` will loop until `Notifier#stop` is called again. Furthermore, if `Notifier#run` acquires the `@running` mutex before `Notifier#stop` does (but after `Notifier#stop` sets `@stop = true`), then `Notifier#stop` will get stuck waiting for the mutex while `Notifier#run` infinitely loops. This commit modifies `Notifier#run` to assume `@stop == false` when it begins, and to reset `@stop = false` only after its loop terminates, thus eliminating the race.
- Loading branch information
1 parent
34e3db4
commit 010f140
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters