summaryrefslogtreecommitdiff
path: root/thread_win32.c
diff options
context:
space:
mode:
authorKoichi Sasada <[email protected]>2023-10-13 01:14:17 +0900
committerKoichi Sasada <[email protected]>2023-10-13 09:19:31 +0900
commitcdb36dfe7ddb7cbd7ed95e84b24114c8869a7e5e ()
tree2de31772f8288869838c7fa5fff6ba60c342453f /thread_win32.c
parent2794a8fef65eb16767c2f46f8f5058c10b4591b9 (diff)
fix `native_thread_destroy()` timing
With M:N thread scheduler, the native thread (NT) related resources should be freed when the NT is no longer needed. So the calling `native_thread_destroy()` at the end of `is will be freed when `thread_cleanup_func()` (at the end of Ruby thread) is not correct timing. Call it when the corresponding Ruby thread is collected.
-rw-r--r--thread_win32.c11
1 files changed, 7 insertions, 4 deletions
@@ -623,11 +623,13 @@ native_thread_init_stack(rb_thread_t *th)
(void *)InterlockedExchange((long *)(t), (long)(v))
#endif
static void
-native_thread_destroy(rb_thread_t *th)
{
- HANDLE intr = InterlockedExchangePointer(&th->nt->interrupt_event, 0);
- RUBY_DEBUG_LOG("close handle intr:%p, thid:%p\n", intr, th->nt->thread_id);
- w32_close_handle(intr);
}
static unsigned long __stdcall
@@ -893,6 +895,7 @@ th_has_dedicated_nt(const rb_thread_t *th)
void
rb_threadptr_sched_free(rb_thread_t *th)
{
ruby_xfree(th->nt);
ruby_xfree(th->sched.vm_stack);
}