diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-18 02:12:18 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-18 02:12:18 +0000 |
commit | f65ee1e8f1aa6713ff9f7189855ac711af93a9b9 (patch) | |
tree | a9ab4c2168d0b4936deae11be3243feab54f34e7 /thread.c | |
parent | e6bf0128add103730d8c96727f3ed4dab95088e4 (diff) | |
download | ruby-f65ee1e8f1aa6713ff9f7189855ac711af93a9b9.tar.gz |
thread.c: stop updating timespec when timeout is unspecified
No need to waste cycles updating timespecs if there's no expiry.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -3802,6 +3802,7 @@ do_select(int n, rb_fdset_t *const readfds, rb_fdset_t *const writefds, 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 readfds, rb_fdset_t *const writefds, (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 readfds, rb_fdset_t *const writefds, 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, struct timeval *timeout) 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) { |