You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2014/10/22 22:30:46 UTC

git commit: Fixed race condition in Latch.

Repository: mesos
Updated Branches:
  refs/heads/master 6e77b3529 -> d9cd0e318


Fixed race condition in Latch.

There is a race condition in Latch. The same pid can be terminated by
2 seperate threads simultaneously.

Review: https://reviews.apache.org/r/26783


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d9cd0e31
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d9cd0e31
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d9cd0e31

Branch: refs/heads/master
Commit: d9cd0e318d0261e39ff4b91f494117ab3a555a4e
Parents: 6e77b35
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Wed Oct 22 13:02:08 2014 -0700
Committer: Niklas Q. Nielsen <ni...@mesosphere.io>
Committed: Wed Oct 22 13:02:08 2014 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/latch.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d9cd0e31/3rdparty/libprocess/src/latch.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/latch.cpp b/3rdparty/libprocess/src/latch.cpp
index 89185ec..cba4dcd 100644
--- a/3rdparty/libprocess/src/latch.cpp
+++ b/3rdparty/libprocess/src/latch.cpp
@@ -26,7 +26,9 @@ Latch::Latch()
 
 Latch::~Latch()
 {
-  terminate(pid);
+  if (__sync_bool_compare_and_swap(&triggered, false, true)) {
+    terminate(pid);
+  }
 }