зеркало из https://github.com/github/ruby.git
thread.c (rb_thread_fd_select): favor rb_thread_* when no FDs
select() is a crap API for even sleeping on sigwait_fd, so favor the native_sleep-based functions when there are no FDs, instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
cb592b3713
Коммит
cc07dc7cf2
20
thread.c
20
thread.c
|
@ -4004,21 +4004,11 @@ rb_thread_fd_select(int max, rb_fdset_t * read, rb_fdset_t * write, rb_fdset_t *
|
|||
set.th = GET_THREAD();
|
||||
RUBY_VM_CHECK_INTS_BLOCKING(set.th->ec);
|
||||
set.max = max;
|
||||
set.sigwait_fd = rb_sigwait_fd_get(set.th);
|
||||
set.rset = read;
|
||||
set.wset = write;
|
||||
set.eset = except;
|
||||
set.timeout = timeout;
|
||||
|
||||
if (set.sigwait_fd >= 0) {
|
||||
if (set.rset)
|
||||
rb_fd_set(set.sigwait_fd, set.rset);
|
||||
else
|
||||
set.rset = init_set_fd(set.sigwait_fd, &set.orig_rset);
|
||||
if (set.sigwait_fd >= set.max) {
|
||||
set.max = set.sigwait_fd + 1;
|
||||
}
|
||||
}
|
||||
if (!set.rset && !set.wset && !set.eset) {
|
||||
if (!timeout) {
|
||||
rb_thread_sleep_forever();
|
||||
|
@ -4028,6 +4018,16 @@ rb_thread_fd_select(int max, rb_fdset_t * read, rb_fdset_t * write, rb_fdset_t *
|
|||
return 0;
|
||||
}
|
||||
|
||||
set.sigwait_fd = rb_sigwait_fd_get(set.th);
|
||||
if (set.sigwait_fd >= 0) {
|
||||
if (set.rset)
|
||||
rb_fd_set(set.sigwait_fd, set.rset);
|
||||
else
|
||||
set.rset = init_set_fd(set.sigwait_fd, &set.orig_rset);
|
||||
if (set.sigwait_fd >= set.max) {
|
||||
set.max = set.sigwait_fd + 1;
|
||||
}
|
||||
}
|
||||
#define fd_init_copy(f) do { \
|
||||
if (set.f) { \
|
||||
rb_fd_resize(set.max - 1, set.f); \
|
||||
|
|
Загрузка…
Ссылка в новой задаче