summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 17:17:13 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 17:17:13 +0000
commit9d4027b50334ef804f6f138fba1d342fe188826b (patch)
tree188881021cb48ac4e073520a5bf3e2facf029742 /thread.c
parent943bf37b10599d585f368c1f8d2e738b6ed8e98c (diff)
process.c: simplify SIGCHLD-based waitpid
Introduce a new rb_thread_sleep_interruptible that does not execute interrupts before sleeping. Skipping the interrupt check before sleep is required for out-of-GVL ruby_waitpid_all to function properly when setting waitpid_state.ret Now that ubf_select can be called by the gvl.timer thread without recursive locking gvl.lock, we can safely use rb_threadptr_interrupt to deal with waking up sleeping processes, git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/thread.c b/thread.c
index 04487876c6..066d34c42a 100644
--- a/thread.c
+++ b/thread.c
@@ -1256,6 +1256,18 @@ rb_thread_sleep_deadly(void)
sleep_forever(GET_THREAD(), SLEEP_DEADLOCKABLE|SLEEP_SPURIOUS_CHECK);
}
+void
+rb_thread_sleep_interruptible(void)
+{
+ rb_thread_t *th = GET_THREAD();
+ enum rb_thread_status prev_status = th->status;
+
+ th->status = THREAD_STOPPED;
+ native_sleep(th, 0);
+ RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
+ th->status = prev_status;
+}
+
static void
rb_thread_sleep_deadly_allow_spurious_wakeup(void)
{
@@ -5408,25 +5420,3 @@ rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data)
return rb_ensure(b_proc, data, rb_ary_pop, cur_th->pending_interrupt_mask_stack);
}
-
-#ifndef USE_NATIVE_SLEEP_COND
-# define USE_NATIVE_SLEEP_COND (0)
-#endif
-
-#if !USE_NATIVE_SLEEP_COND
-rb_nativethread_cond_t *
-rb_sleep_cond_get(const rb_execution_context_t *ec)
-{
- rb_nativethread_cond_t *cond = ALLOC(rb_nativethread_cond_t);
- rb_native_cond_initialize(cond);
-
- return cond;
-}
-
-void
-rb_sleep_cond_put(rb_nativethread_cond_t *cond)
-{
- rb_native_cond_destroy(cond);
- xfree(cond);
-}
-#endif /* !USE_NATIVE_SLEEP_COND */