ruby-changes:53502
From: normal <ko1@a...>
Date: Wed, 14 Nov 2018 12:52:32 +0900 (JST)
Subject: [ruby-changes:53502] normal:r65718 (trunk): thread.c (rb_thread_fd_select): favor rb_thread_* when no FDs
normal 2018-11-14 12:52:28 +0900 (Wed, 14 Nov 2018) New Revision: 65718 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65718 Log: 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. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 65717) +++ thread.c (revision 65718) @@ -4004,21 +4004,11 @@ rb_thread_fd_select(int max, rb_fdset_t https://github.com/ruby/ruby/blob/trunk/thread.c#L4004 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 https://github.com/ruby/ruby/blob/trunk/thread.c#L4018 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); \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/