summaryrefslogtreecommitdiff
path: root/mjit.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-09-04 18:21:56 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2022-09-04 18:22:25 -0700
commitf6d569b7c0ae7cb5e08534330cdf94572a12e869 (patch)
tree204f12d86933c498632981dbac3de4991f5bae8a /mjit.c
parent51291ade70d7fc972cb8229fc788456a8c2d8a6b (diff)
Call appropriate hooks on MJIT's fork
This takes care of signal_self_pipe and other things.
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/mjit.c b/mjit.c
index 662ef99b32..0aa6d6e7cf 100644
--- a/mjit.c
+++ b/mjit.c
@@ -742,23 +742,17 @@ mjit_compact_unit(struct rb_mjit_unit *unit)
return 1;
}
+extern pid_t rb_mjit_fork();
+
static pid_t
start_mjit_compact(struct rb_mjit_unit *unit)
{
- rb_vm_t *vm = GET_VM();
- rb_native_mutex_lock(&vm->waitpid_lock);
-
- pid_t pid = rb_fork();
+ pid_t pid = rb_mjit_fork();
if (pid == 0) {
- rb_native_mutex_unlock(&vm->waitpid_lock);
-
int exit_code = mjit_compact_unit(unit);
exit(exit_code);
}
else {
- mjit_add_waiting_pid(vm, pid);
- rb_native_mutex_unlock(&vm->waitpid_lock);
-
return pid;
}
}
@@ -908,20 +902,12 @@ mjit_compile_unit(struct rb_mjit_unit *unit)
static pid_t
start_mjit_compile(struct rb_mjit_unit *unit)
{
- rb_vm_t *vm = GET_VM();
- rb_native_mutex_lock(&vm->waitpid_lock);
-
- pid_t pid = rb_fork();
+ pid_t pid = rb_mjit_fork();
if (pid == 0) {
- rb_native_mutex_unlock(&vm->waitpid_lock);
-
int exit_code = mjit_compile_unit(unit);
exit(exit_code);
}
else {
- mjit_add_waiting_pid(vm, pid);
- rb_native_mutex_unlock(&vm->waitpid_lock);
-
return pid;
}
}