Created
August 4, 2011 10:57
-
-
Save mrkn/1124962 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/thread_pthread.c b/thread_pthread.c | |
index 8ef34dd..26a0135 100644 | |
--- a/thread_pthread.c | |
+++ b/thread_pthread.c | |
@@ -267,10 +267,23 @@ native_cond_destroy(rb_thread_cond_t *cond) | |
} | |
} | |
+/* | |
+ * In OS X 10.7 (Lion), pthread_cond_signal and pthread_cond_broadcast return | |
+ * EAGAIN after retrying 8196 times. You can see them in the following page: | |
+ * | |
+ * http://www.opensource.apple.com/source/Libc/Libc-763.11/pthreads/pthread_cond.c | |
+ * | |
+ * The following native_cond_signal and native_cond_broadcast functions | |
+ * need to retrying until pthread functions don't return EAGAIN. | |
+ */ | |
+ | |
static void | |
native_cond_signal(rb_thread_cond_t *cond) | |
{ | |
- int r = pthread_cond_signal(&cond->cond); | |
+ int r; | |
+ do { | |
+ r = pthread_cond_signal(&cond->cond); | |
+ } while (r == EAGAIN); | |
if (r != 0) { | |
rb_bug_errno("pthread_cond_signal", r); | |
} | |
@@ -279,7 +292,10 @@ native_cond_signal(rb_thread_cond_t *cond) | |
static void | |
native_cond_broadcast(rb_thread_cond_t *cond) | |
{ | |
- int r = pthread_cond_broadcast(&cond->cond); | |
+ int r; | |
+ do { | |
+ r = pthread_cond_broadcast(&cond->cond) | |
+ } while (r == EAGAIN); | |
if (r != 0) { | |
rb_bug_errno("native_cond_broadcast", r); | |
} | |
@@ -736,7 +752,10 @@ use_cached_thread(rb_thread_t *th) | |
} | |
} | |
if (result) { | |
- pthread_cond_signal(entry->cond); | |
+ int r; | |
+ do { | |
+ r = pthread_cond_signal(entry->cond); | |
+ } while (r == EAGAIN); | |
} | |
pthread_mutex_unlock(&thread_cache_lock); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment