summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 58e7651446..eca14b4b4c 100644
--- a/thread.c
+++ b/thread.c
@@ -1429,11 +1429,15 @@ call_without_gvl(void *(*func)(void *), void *data1,
rb_execution_context_t *ec = GET_EC();
rb_thread_t *th = rb_ec_thread_ptr(ec);
int saved_errno = 0;
+ VALUE ubf_th = Qfalse;
if (ubf == RUBY_UBF_IO || ubf == RUBY_UBF_PROCESS) {
ubf = ubf_select;
data2 = th;
}
+ else if (ubf && vm_living_thread_num(th->vm) == 1) {
+ ubf_th = rb_thread_start_unblock_thread();
+ }
BLOCKING_REGION(th, {
val = func(data1);
@@ -1444,6 +1448,10 @@ call_without_gvl(void *(*func)(void *), void *data1,
RUBY_VM_CHECK_INTS_BLOCKING(ec);
}
+ if (ubf_th != Qfalse) {
+ thread_value(rb_thread_kill(ubf_th));
+ }
+
errno = saved_errno;
return val;