Created
February 4, 2014 16:59
-
-
Save mdotterer/8807766 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
From 49b87a89a11a429022d401407832dba5e731e8e4 Mon Sep 17 00:00:00 2001 | |
From: Michael Dotterer <michael@groupsite.com> | |
Date: Tue, 4 Feb 2014 11:23:15 -0500 | |
Subject: [PATCH] Apply patch from 1.8.7 to address virtual timer expired error | |
--- | |
eval.c | 28 ++++++++++++++++------------ | |
1 file changed, 16 insertions(+), 12 deletions(-) | |
diff --git a/eval.c b/eval.c | |
index b2f671b..c9a3d9a 100644 | |
--- a/eval.c | |
+++ b/eval.c | |
@@ -11953,6 +11953,12 @@ rb_thread_alloc(klass) | |
static int thread_init; | |
+#if defined(POSIX_SIGNAL) | |
+#define CATCH_VTALRM() posix_signal(SIGVTALRM, catch_timer) | |
+#else | |
+#define CATCH_VTALRM() signal(SIGVTALRM, catch_timer) | |
+#endif | |
+ | |
#if defined(_THREAD_SAFE) | |
static void | |
catch_timer(sig) | |
@@ -12036,6 +12042,8 @@ rb_thread_start_timer() | |
static pthread_cond_t start = PTHREAD_COND_INITIALIZER; | |
if (!thread_init) return; | |
+ if (rb_thread_alone()) return; | |
+ CATCH_VTALRM(); | |
args[0] = &time_thread; | |
args[1] = &start; | |
safe_mutex_lock(&time_thread.lock); | |
@@ -12078,6 +12086,8 @@ rb_thread_start_timer() | |
struct itimerval tval; | |
if (thread_init) return; | |
+ if (rb_thread_alone()) return; | |
+ CATCH_VTALRM(); | |
tval.it_interval.tv_sec = 0; | |
tval.it_interval.tv_usec = 10000; | |
tval.it_value = tval.it_interval; | |
@@ -12117,18 +12127,6 @@ rb_thread_start_0(fn, arg, th) | |
"can't start a new thread (frozen ThreadGroup)"); | |
} | |
- if (!thread_init) { | |
-#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE) | |
-#if defined(POSIX_SIGNAL) | |
- posix_signal(SIGVTALRM, catch_timer); | |
-#else | |
- signal(SIGVTALRM, catch_timer); | |
-#endif | |
- | |
- rb_thread_start_timer(); | |
-#endif | |
- } | |
- | |
if (THREAD_SAVE_CONTEXT(curr_thread)) { | |
return thread; | |
} | |
@@ -12150,6 +12148,9 @@ rb_thread_start_0(fn, arg, th) | |
curr_thread->next = th; | |
th->priority = curr_thread->priority; | |
th->thgroup = curr_thread->thgroup; | |
+#if defined(HAVE_SETITIMER) || defined(THREAD_SAFE) | |
+ rb_thread_start_timer(); | |
+#endif | |
} | |
PUSH_TAG(PROT_THREAD); | |
@@ -12876,6 +12877,9 @@ rb_thread_atfork() | |
main_thread = curr_thread; | |
curr_thread->next = curr_thread; | |
curr_thread->prev = curr_thread; | |
+#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE) | |
+ rb_thread_stop_timer(); | |
+#endif | |
} | |
-- | |
1.8.3.4 (Apple Git-47) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's up Mike! I found this while searching for the Virtual timer expired error I'm getting while trying to run rake test. Went to Stack Overflow and saw that you had answered a question there regarding it :)