mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
thread_win32.c: no GVL for interrupt_event
* thread_win32.c (w32_wait_events): do not acquire GVL, to fix deadlock at read/close race condition. instead, just ignore interrupt_event if it is closed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
04b618e53e
commit
7206ac5492
1 changed files with 7 additions and 25 deletions
|
@ -158,22 +158,6 @@ Init_native_thread(void)
|
||||||
th->native_thread_data.interrupt_event);
|
th->native_thread_data.interrupt_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
w32_set_event(HANDLE handle)
|
|
||||||
{
|
|
||||||
if (SetEvent(handle) == 0) {
|
|
||||||
w32_error("w32_set_event");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
w32_reset_event(HANDLE handle)
|
|
||||||
{
|
|
||||||
if (ResetEvent(handle) == 0) {
|
|
||||||
w32_error("w32_reset_event");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th)
|
w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th)
|
||||||
{
|
{
|
||||||
|
@ -184,20 +168,16 @@ w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th)
|
||||||
thread_debug(" w32_wait_events events:%p, count:%d, timeout:%ld, th:%p\n",
|
thread_debug(" w32_wait_events events:%p, count:%d, timeout:%ld, th:%p\n",
|
||||||
events, count, timeout, th);
|
events, count, timeout, th);
|
||||||
if (th && (intr = th->native_thread_data.interrupt_event)) {
|
if (th && (intr = th->native_thread_data.interrupt_event)) {
|
||||||
gvl_acquire(th->vm, th);
|
if (ResetEvent(intr) && (!RUBY_VM_INTERRUPTED(th) || SetEvent(intr))) {
|
||||||
if (intr == th->native_thread_data.interrupt_event) {
|
|
||||||
w32_reset_event(intr);
|
|
||||||
if (RUBY_VM_INTERRUPTED(th)) {
|
|
||||||
w32_set_event(intr);
|
|
||||||
}
|
|
||||||
|
|
||||||
targets = ALLOCA_N(HANDLE, count + 1);
|
targets = ALLOCA_N(HANDLE, count + 1);
|
||||||
memcpy(targets, events, sizeof(HANDLE) * count);
|
memcpy(targets, events, sizeof(HANDLE) * count);
|
||||||
|
|
||||||
targets[count++] = intr;
|
targets[count++] = intr;
|
||||||
thread_debug(" * handle: %p (count: %d, intr)\n", intr, count);
|
thread_debug(" * handle: %p (count: %d, intr)\n", intr, count);
|
||||||
}
|
}
|
||||||
gvl_release(th->vm);
|
else if (intr == th->native_thread_data.interrupt_event) {
|
||||||
|
w32_error("w32_wait_events");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_debug(" WaitForMultipleObjects start (count: %d)\n", count);
|
thread_debug(" WaitForMultipleObjects start (count: %d)\n", count);
|
||||||
|
@ -682,7 +662,9 @@ ubf_handle(void *ptr)
|
||||||
rb_thread_t *th = (rb_thread_t *)ptr;
|
rb_thread_t *th = (rb_thread_t *)ptr;
|
||||||
thread_debug("ubf_handle: %p\n", th);
|
thread_debug("ubf_handle: %p\n", th);
|
||||||
|
|
||||||
w32_set_event(th->native_thread_data.interrupt_event);
|
if (!SetEvent(th->native_thread_data.interrupt_event)) {
|
||||||
|
w32_error("ubf_handle");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
|
Loading…
Reference in a new issue