From eb38fb670bb74522f253cca440bccfd8d8d63c3c Mon Sep 17 00:00:00 2001 From: normal Date: Fri, 30 Nov 2018 03:56:29 +0000 Subject: vm_trace.c: workqueue as thread-safe version of postponed_job postponed_job is safe to use in signal handlers, but is not thread-safe for MJIT. Implement a workqueue for MJIT thread-safety. [Bug #15316] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'thread.c') diff --git a/thread.c b/thread.c index d02b560ac1..d76f05aa41 100644 --- a/thread.c +++ b/thread.c @@ -419,6 +419,7 @@ rb_vm_gvl_destroy(rb_vm_t *vm) if (0) { /* may be held by running threads */ rb_native_mutex_destroy(&vm->waitpid_lock); + rb_native_mutex_destroy(&vm->workqueue_lock); } } @@ -4422,6 +4423,7 @@ rb_thread_atfork_internal(rb_thread_t *th, void (*atfork)(rb_thread_t *, const r /* may be held by MJIT threads in parent */ rb_native_mutex_initialize(&vm->waitpid_lock); + rb_native_mutex_initialize(&vm->workqueue_lock); /* may be held by any thread in parent */ rb_native_mutex_initialize(&th->interrupt_lock); @@ -5183,6 +5185,7 @@ Init_Thread(void) gvl_init(th->vm); gvl_acquire(th->vm, th); rb_native_mutex_initialize(&th->vm->waitpid_lock); + rb_native_mutex_initialize(&th->vm->workqueue_lock); rb_native_mutex_initialize(&th->interrupt_lock); th->pending_interrupt_queue = rb_ary_tmp_new(0); -- cgit v1.2.3