Call appropriate hooks on MJIT's fork
This takes care of signal_self_pipe and other things.
This commit is contained in:
parent
51291ade70
commit
f6d569b7c0
22
mjit.c
22
mjit.c
@ -742,23 +742,17 @@ mjit_compact_unit(struct rb_mjit_unit *unit)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern pid_t rb_mjit_fork();
|
||||||
|
|
||||||
static pid_t
|
static pid_t
|
||||||
start_mjit_compact(struct rb_mjit_unit *unit)
|
start_mjit_compact(struct rb_mjit_unit *unit)
|
||||||
{
|
{
|
||||||
rb_vm_t *vm = GET_VM();
|
pid_t pid = rb_mjit_fork();
|
||||||
rb_native_mutex_lock(&vm->waitpid_lock);
|
|
||||||
|
|
||||||
pid_t pid = rb_fork();
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
rb_native_mutex_unlock(&vm->waitpid_lock);
|
|
||||||
|
|
||||||
int exit_code = mjit_compact_unit(unit);
|
int exit_code = mjit_compact_unit(unit);
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mjit_add_waiting_pid(vm, pid);
|
|
||||||
rb_native_mutex_unlock(&vm->waitpid_lock);
|
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -908,20 +902,12 @@ mjit_compile_unit(struct rb_mjit_unit *unit)
|
|||||||
static pid_t
|
static pid_t
|
||||||
start_mjit_compile(struct rb_mjit_unit *unit)
|
start_mjit_compile(struct rb_mjit_unit *unit)
|
||||||
{
|
{
|
||||||
rb_vm_t *vm = GET_VM();
|
pid_t pid = rb_mjit_fork();
|
||||||
rb_native_mutex_lock(&vm->waitpid_lock);
|
|
||||||
|
|
||||||
pid_t pid = rb_fork();
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
rb_native_mutex_unlock(&vm->waitpid_lock);
|
|
||||||
|
|
||||||
int exit_code = mjit_compile_unit(unit);
|
int exit_code = mjit_compile_unit(unit);
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mjit_add_waiting_pid(vm, pid);
|
|
||||||
rb_native_mutex_unlock(&vm->waitpid_lock);
|
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
process.c
23
process.c
@ -4204,6 +4204,29 @@ retry_fork_async_signal_safe(struct rb_process_status *status, int *ep,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_MJIT
|
||||||
|
// This is used to create MJIT's child Ruby process
|
||||||
|
pid_t
|
||||||
|
rb_mjit_fork(void)
|
||||||
|
{
|
||||||
|
struct child_handler_disabler_state old;
|
||||||
|
rb_vm_t *vm = GET_VM();
|
||||||
|
prefork();
|
||||||
|
disable_child_handler_before_fork(&old);
|
||||||
|
before_fork_ruby();
|
||||||
|
|
||||||
|
rb_native_mutex_lock(&vm->waitpid_lock);
|
||||||
|
pid_t pid = rb_fork();
|
||||||
|
if (pid > 0) mjit_add_waiting_pid(vm, pid);
|
||||||
|
rb_native_mutex_unlock(&vm->waitpid_lock);
|
||||||
|
|
||||||
|
after_fork_ruby();
|
||||||
|
disable_child_handler_fork_parent(&old);
|
||||||
|
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static rb_pid_t
|
static rb_pid_t
|
||||||
fork_check_err(struct rb_process_status *status, int (*chfunc)(void*, char *, size_t), void *charg,
|
fork_check_err(struct rb_process_status *status, int (*chfunc)(void*, char *, size_t), void *charg,
|
||||||
VALUE fds, char *errmsg, size_t errmsg_buflen,
|
VALUE fds, char *errmsg, size_t errmsg_buflen,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user