Repository: mesos
Updated Branches:
  refs/heads/master 993dc2dc5 -> da7b4ac6c


Fix ProcTest.MultipleThreads hanging.

Replace 'sleep' with 'pthread_testcancel'.

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


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

Branch: refs/heads/master
Commit: 3c6d43117dd832a992343cfe46893b56517d8ffa
Parents: 993dc2d
Author: Joris Van Remoortere <[email protected]>
Authored: Fri Nov 21 08:02:37 2014 -0800
Committer: Benjamin Hindman <[email protected]>
Committed: Fri Nov 21 08:02:38 2014 -0800

----------------------------------------------------------------------
 .../libprocess/3rdparty/stout/tests/proc_tests.cpp    | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3c6d4311/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp 
b/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
index 56a63e8..d3c9aed 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
@@ -73,11 +73,17 @@ TEST(ProcTest, SingleThread)
 }
 
 
-void* threadFunction(void*)
+void* cancelFunction(void*)
 {
   // Newly created threads have PTHREAD_CANCEL_ENABLE and
-  // PTHREAD_CANCEL_DEFERRED so they can be cancelled from the main thread.
-  while (true) { sleep(1); }
+  // PTHREAD_CANCEL_DEFERRED so they can be cancelled from the main
+  // thread.
+  while (true) {
+    // Use pthread_testcancel() as opposed to sleep() because we've
+    // seen sleep() hang on certain linux machines even though sleep
+    // should be a cancellation point.
+    pthread_testcancel();
+  }
 
   return NULL;
 }
@@ -93,7 +99,7 @@ TEST(ProcTest, MultipleThreads)
   // Create additional threads.
   for (size_t i = 0; i < numThreads; i++)
   {
-    EXPECT_EQ(0, pthread_create(&pthreads[i], NULL, threadFunction, NULL));
+    EXPECT_EQ(0, pthread_create(&pthreads[i], NULL, cancelFunction, NULL));
   }
 
   // Check we have the expected number of threads.

Reply via email to