Skip to content

Commit

Permalink
WIP: fix win32 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1 committed Oct 2, 2023
1 parent 3ebbf7b commit 5747694
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions thread_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,17 +655,17 @@ thread_start_func_1(void *th_ptr)
static int
native_thread_create(rb_thread_t *th)
{
// setup nt
const size_t stack_size = th->vm->default_params.thread_machine_stack_size + th->vm->default_params.thread_vm_stack_size;
th->nt = ZALLOC(struct rb_native_thread);
th->nt->thread_id = w32_create_thread(stack_size, thread_start_func_1, th);

// setup vm stack
size_t vm_stack_word_size = th->vm->default_params.thread_vm_stack_size / sizeof(VALUE);
void *vm_stack = ruby_xmalloc(vm_stack_word_size * sizeof(VALUE));
th->sched.vm_stack = vm_stack;
rb_ec_initialize_vm_stack(th->ec, vm_stack, vm_stack_word_size);

// setup nt
const size_t stack_size = th->vm->default_params.thread_machine_stack_size + th->vm->default_params.thread_vm_stack_size;
th->nt = ZALLOC(struct rb_native_thread);
th->nt->thread_id = w32_create_thread(stack_size, thread_start_func_1, th);

if ((th->nt->thread_id) == 0) {
return thread_errno;
}
Expand Down Expand Up @@ -896,8 +896,6 @@ th_has_dedicated_nt(const rb_thread_t *th)
void
rb_threadptr_sched_free(rb_thread_t *th)
{
CloseHandle(TH_SCHED(th)->lock);
ruby_xfree(th->nt);
ruby_xfree(th->sched.vm_stack);
}

Expand Down

0 comments on commit 5747694

Please sign in to comment.