ruby-changes:50343
From: normal <ko1@a...>
Date: Sun, 18 Feb 2018 11:12:22 +0900 (JST)
Subject: [ruby-changes:50343] normal:r62458 (trunk): thread.c: stop updating timespec when timeout is unspecified
normal 2018-02-18 11:12:18 +0900 (Sun, 18 Feb 2018) New Revision: 62458 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62458 Log: thread.c: stop updating timespec when timeout is unspecified No need to waste cycles updating timespecs if there's no expiry. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 62457) +++ thread.c (revision 62458) @@ -3802,6 +3802,7 @@ do_select(int n, rb_fdset_t *const readf https://github.com/ruby/ruby/blob/trunk/thread.c#L3802 rb_fdset_t MAYBE_UNUSED(orig_write); rb_fdset_t MAYBE_UNUSED(orig_except); struct timespec end; + struct timespec *tsp = 0; struct timespec ts #if defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8) = {0, 0} @@ -3813,11 +3814,12 @@ do_select(int n, rb_fdset_t *const readf https://github.com/ruby/ruby/blob/trunk/thread.c#L3814 (restore_fdset(readfds, &orig_read), \ restore_fdset(writefds, &orig_write), \ restore_fdset(exceptfds, &orig_except), \ - update_timespec(&ts, &end)) + update_timespec(tsp, &end)) if (timeout) { getclockofday(&end); timespec_add(&end, timespec_for(&ts, timeout)); + tsp = &ts; } #define fd_init_copy(f) \ @@ -3832,7 +3834,7 @@ do_select(int n, rb_fdset_t *const readf https://github.com/ruby/ruby/blob/trunk/thread.c#L3834 BLOCKING_REGION({ result = native_fd_select(n, readfds, writefds, exceptfds, - timeval_for(timeout, &ts), th); + timeval_for(timeout, tsp), th); if (result < 0) lerrno = errno; }, ubf_select, th, FALSE); @@ -3974,7 +3976,7 @@ rb_wait_for_single_fd(int fd, int events https://github.com/ruby/ruby/blob/trunk/thread.c#L3976 RUBY_VM_CHECK_INTS_BLOCKING(th->ec); } while (result < 0 && retryable(errno = lerrno) && - update_timespec(&ts, &end)); + update_timespec(tsp, &end)); if (result < 0) return -1; if (fds.revents & POLLNVAL) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/