diff options
author | Samuel Williams <[email protected]> | 2020-11-10 10:21:14 +1300 |
---|---|---|
committer | Samuel Williams <[email protected]> | 2020-12-05 11:38:56 +1300 |
commit | 3b5b309b7b3724849c27dc1c836b5348a8a82e23 (patch) | |
tree | d950dd6df636d053563d117bbeed169ceed2c1b7 /thread.c | |
parent | 15e23312f6abcbf1afc6fbbf7917a57a0637f680 (diff) |
Proposed method for dealing with stack locals which have non-local lifetime.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3624
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1789,23 +1789,23 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd) rb_execution_context_t * volatile ec = GET_EC(); volatile int saved_errno = 0; enum ruby_tag_type state; - struct waiting_fd wfd; + COROUTINE_STACK_LOCAL(struct waiting_fd, wfd); - wfd.fd = fd; - wfd.th = rb_ec_thread_ptr(ec); + wfd->fd = fd; + wfd->th = rb_ec_thread_ptr(ec); RB_VM_LOCK_ENTER(); { - list_add(&rb_ec_vm_ptr(ec)->waiting_fds, &wfd.wfd_node); + list_add(&rb_ec_vm_ptr(ec)->waiting_fds, &wfd->wfd_node); } RB_VM_LOCK_LEAVE(); EC_PUSH_TAG(ec); if ((state = EC_EXEC_TAG()) == TAG_NONE) { - BLOCKING_REGION(wfd.th, { + BLOCKING_REGION(wfd->th, { val = func(data1); saved_errno = errno; - }, ubf_select, wfd.th, FALSE); + }, ubf_select, wfd->th, FALSE); } EC_POP_TAG(); @@ -1815,7 +1815,8 @@ rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd) */ RB_VM_LOCK_ENTER(); { - list_del(&wfd.wfd_node); + list_del(&wfd->wfd_node); + COROUTINE_STACK_FREE(wfd); } RB_VM_LOCK_LEAVE(); |