diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-18 08:25:48 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-18 08:25:48 +0000 |
commit | fe6974a8fcca42f4f83171097a3bc29fbe0f2f67 (patch) | |
tree | 01f157d468dc018c5765144f344e98a37a584c62 /process.c | |
parent | 0a7a5a7ad4da3ec8bed425502f5012908a0e77c8 (diff) |
mjit_worker.c: support MJIT in forked Ruby process
by launching MJIT worker thread in child Ruby process.
See the comment before `mjit_child_after_fork` for details.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -1502,12 +1502,26 @@ after_exec(void) } #if defined HAVE_WORKING_FORK || defined HAVE_DAEMON -#define before_fork_ruby() before_exec() static void -after_fork_ruby(void) +before_fork_ruby(void) +{ + if (mjit_enabled) { + /* avoid leaving locked mutex and units being modified for child process. */ + mjit_pause(FALSE); + } + + before_exec(); +} + +static void +after_fork_ruby(int parent_p) { rb_threadptr_pending_interrupt_clear(GET_THREAD()); after_exec(); + + if (mjit_enabled && parent_p) { /* child is cared by `rb_thread_atfork` */ + mjit_resume(); + } } #endif @@ -3997,7 +4011,7 @@ rb_fork_ruby(int *status) before_fork_ruby(); pid = fork(); err = errno; - after_fork_ruby(); + after_fork_ruby(pid > 0); disable_child_handler_fork_parent(&old); /* yes, bad name */ if (pid >= 0) /* fork succeed */ return pid; @@ -6422,7 +6436,7 @@ rb_daemon(int nochdir, int noclose) #ifdef HAVE_DAEMON before_fork_ruby(); err = daemon(nochdir, noclose); - after_fork_ruby(); + after_fork_ruby(TRUE); rb_thread_atfork(); #else int n; |