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