зеркало из https://github.com/github/ruby.git
process.c: keep GVL if WNOHANG
* process.c (rb_waitpid): do not release GVL when WNOHANG is set, it should return immediately without blocking. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2a87a0fc73
Коммит
d3022c424c
30
process.c
30
process.c
|
@ -846,20 +846,23 @@ struct waitpid_arg {
|
||||||
int *st;
|
int *st;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void *
|
static rb_pid_t
|
||||||
rb_waitpid_blocking(void *data)
|
do_waitpid(rb_pid_t pid, int *st, int flags)
|
||||||
{
|
{
|
||||||
rb_pid_t result;
|
|
||||||
struct waitpid_arg *arg = data;
|
|
||||||
|
|
||||||
#if defined HAVE_WAITPID
|
#if defined HAVE_WAITPID
|
||||||
result = waitpid(arg->pid, arg->st, arg->flags);
|
return waitpid(pid, st, flags);
|
||||||
#elif defined HAVE_WAIT4
|
#elif defined HAVE_WAIT4
|
||||||
result = wait4(arg->pid, arg->st, arg->flags, NULL);
|
return wait4(pid, st, flags, NULL);
|
||||||
#else
|
#else
|
||||||
# error waitpid or wait4 is required.
|
# error waitpid or wait4 is required.
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
rb_waitpid_blocking(void *data)
|
||||||
|
{
|
||||||
|
struct waitpid_arg *arg = data;
|
||||||
|
rb_pid_t result = do_waitpid(arg->pid, arg->st, arg->flags);
|
||||||
return (void *)(VALUE)result;
|
return (void *)(VALUE)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,10 +884,15 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
|
||||||
{
|
{
|
||||||
rb_pid_t result;
|
rb_pid_t result;
|
||||||
|
|
||||||
while ((result = do_waitpid_nonblocking(pid, st, flags)) < 0 &&
|
if (flags & WNOHANG) {
|
||||||
(errno == EINTR)) {
|
result = do_waitpid(pid, st, flags);
|
||||||
rb_thread_t *th = GET_THREAD();
|
}
|
||||||
RUBY_VM_CHECK_INTS(th);
|
else {
|
||||||
|
while ((result = do_waitpid_nonblocking(pid, st, flags)) < 0 &&
|
||||||
|
(errno == EINTR)) {
|
||||||
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
RUBY_VM_CHECK_INTS(th);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
rb_last_status_set(*st, result);
|
rb_last_status_set(*st, result);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче