You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/11/04 02:29:50 UTC

svn commit: r1405465 - /incubator/mesos/branches/0.10.0/third_party/libprocess/src/latch.cpp

Author: benh
Date: Sun Nov  4 01:29:50 2012
New Revision: 1405465

URL: http://svn.apache.org/viewvc?rev=1405465&view=rev
Log:
*** MODIFIED FOR 0.10.0 ***
Fixed bug in libprocess Latch::await that might cause triggered
latches to be missed.

Modified:
    incubator/mesos/branches/0.10.0/third_party/libprocess/src/latch.cpp

Modified: incubator/mesos/branches/0.10.0/third_party/libprocess/src/latch.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/branches/0.10.0/third_party/libprocess/src/latch.cpp?rev=1405465&r1=1405464&r2=1405465&view=diff
==============================================================================
--- incubator/mesos/branches/0.10.0/third_party/libprocess/src/latch.cpp (original)
+++ incubator/mesos/branches/0.10.0/third_party/libprocess/src/latch.cpp Sun Nov  4 01:29:50 2012
@@ -40,7 +40,18 @@ void Latch::trigger()
 bool Latch::await(double secs)
 {
   if (!triggered) {
-    return process::wait(pid, secs); // Explict to disambiguate.
+    process::wait(pid, secs); // Explict to disambiguate.
+    // It's possible that we failed to wait because:
+    //   (1) Our process has already terminated.
+    //   (2) We timed out (i.e., duration was not "infinite").
+
+    // In the event of (1) we might need to return 'true' since a
+    // terminated process might imply that the latch has been
+    // triggered. To capture this we simply return the value of
+    // 'triggered' (which will also capture cases where we actually
+    // timed out but have since triggered, which seems like an
+    // acceptable semantics given such a "tie").
+    return triggered;
   }
 
   return true;