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
diff --git a/webrtc/system_wrappers/source/event_posix.cc b/webrtc/system_wrappers/source/event_posix.cc
index 907409b..2a53afa 100644
--- a/webrtc/system_wrappers/source/event_posix.cc
+++ b/webrtc/system_wrappers/source/event_posix.cc
@@ -148,10 +148,13 @@
     }
   }
 
-  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) {