From 30015e31803fe6a986bfcc927ad457b90806a574 Mon Sep 17 00:00:00 2001 From: "tommi@webrtc.org" Date: Tue, 10 Feb 2015 09:33:28 +0000 Subject: [PATCH] Fix bug in EventPosix where we'd miss a set event. In cases of timeout or error, we could change the state of the event to 'down' (unset) and subsequently never satisfy a Wait() for a given Set(). BUG=4284 R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/38049004 Cr-Commit-Position: refs/heads/master@{#8310} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8310 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/system_wrappers/source/event_posix.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/webrtc/system_wrappers/source/event_posix.cc b/webrtc/system_wrappers/source/event_posix.cc index 907409bd59..2a53afac36 100644 --- a/webrtc/system_wrappers/source/event_posix.cc +++ b/webrtc/system_wrappers/source/event_posix.cc @@ -148,10 +148,13 @@ EventTypeWrapper EventPosix::Wait(unsigned long timeout) { } } - if (ret_val == 0) - CHECK(state_ == kUp); + // Be careful to only change the state if we're about to report that the + // event was signaled. + if (ret_val == 0) { + DCHECK(state_ == kUp); + state_ = kDown; + } - state_ = kDown; pthread_mutex_unlock(&mutex_); switch (ret_val) {