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/10/04 01:37:36 UTC

svn commit: r1393822 - /incubator/mesos/trunk/third_party/libprocess/src/latch.cpp

Author: benh
Date: Wed Oct  3 23:37:36 2012
New Revision: 1393822

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

Modified:
    incubator/mesos/trunk/third_party/libprocess/src/latch.cpp

Modified: incubator/mesos/trunk/third_party/libprocess/src/latch.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/latch.cpp?rev=1393822&r1=1393821&r2=1393822&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/latch.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/latch.cpp Wed Oct  3 23:37:36 2012
@@ -42,7 +42,18 @@ void Latch::trigger()
 bool Latch::await(const Duration& duration)
 {
   if (!triggered) {
-    return process::wait(pid, duration); // Explict to disambiguate.
+    process::wait(pid, duration); // 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;