Skip to content

evwatch: fix race condition#802

Merged
azat merged 1 commit intolibevent:masterfrom
mergeconflict:watch_thread_safety
Apr 18, 2019
Merged

evwatch: fix race condition#802
azat merged 1 commit intolibevent:masterfrom
mergeconflict:watch_thread_safety

Conversation

@mergeconflict
Copy link
Copy Markdown

There was a race between event_base_loop and evwatch_new (adding a
prepare/check watcher while iterating over the watcher list). Only
release the mutex immediately before invoking each watcher callback,
and reacquire it immediately afterwards (same as is done for normal
event handlers).

There was a race between event_base_loop and evwatch_new (adding a
prepare/check watcher while iterating over the watcher list). Only
release the mutex immediately before invoking each watcher callback,
and reacquire it immediately afterwards (same as is done for normal
event handlers).
@mergeconflict
Copy link
Copy Markdown
Author

Hi @azat, it's me again :)

We just discovered this bug in my evwatch code when testing Envoy with the clang thread sanitizer. I've validated this fix with the same sanitizer.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.02%) to 81.519% when pulling 1cd8830 on mergeconflict:watch_thread_safety into 04563d5 on libevent:master.

@azat azat merged commit 1cd8830 into libevent:master Apr 18, 2019
@azat
Copy link
Copy Markdown
Member

azat commented Apr 18, 2019

Hi @mergeconflict

Applied, thanks!

@mergeconflict mergeconflict deleted the watch_thread_safety branch April 18, 2019 14:53
@mergeconflict
Copy link
Copy Markdown
Author

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants