summaryrefslogtreecommitdiff
path: root/thread_win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread_win32.c')
-rw-r--r--thread_win32.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/thread_win32.c b/thread_win32.c
index 68d993a0b2..9241d274b0 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -519,17 +519,17 @@ native_thread_apply_priority(rb_thread_t *th)
static void
ubf_handle(void *ptr)
{
- static int checked = 0;
typedef BOOL (WINAPI *cancel_io_func_t)(HANDLE);
static cancel_io_func_t cancel_func = NULL;
rb_thread_t *th = (rb_thread_t *)ptr;
thread_debug("ubf_handle: %p\n", th);
- if (!checked) {
+ if (!cancel_func) {
cancel_func = (cancel_io_func_t)GetProcAddress(GetModuleHandle("kernel32"), "CancelSynchronousIo");
- checked = 1;
+ if (!cancel_func)
+ cancel_func = (cancel_io_func_t)-1;
}
- if (cancel_func)
+ if (cancel_func != (cancel_io_func_t)-1)
cancel_func((HANDLE)th->thread_id);
w32_set_event(th->native_thread_data.interrupt_event);