diff options
| author | Brad King <brad.king@kitware.com> | 2020-09-23 12:13:59 -0400 |
|---|---|---|
| committer | Brad King <brad.king@kitware.com> | 2020-09-23 12:13:59 -0400 |
| commit | e21325c2c6ab5a73682fa5ab3ec43104e397f666 (patch) | |
| tree | ec73d37fe975cd56b87fb06399a3eb8c52a18be7 /Utilities/cmlibuv/src/unix/sunos.c | |
| parent | d827fdb6f99e58e4dfc6fdda3816ed2862e00a95 (diff) | |
| parent | c1463f959f7445207d932ec7640d77aebc2a6498 (diff) | |
| download | cmake-e21325c2c6ab5a73682fa5ab3ec43104e397f666.tar.gz | |
Merge branch 'upstream-libuv' into update-libuv
* upstream-libuv:
libuv 2020-09-22 (ed5b42d5)
Diffstat (limited to 'Utilities/cmlibuv/src/unix/sunos.c')
| -rw-r--r-- | Utilities/cmlibuv/src/unix/sunos.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/Utilities/cmlibuv/src/unix/sunos.c b/Utilities/cmlibuv/src/unix/sunos.c index 9697648054..2166e8f08e 100644 --- a/Utilities/cmlibuv/src/unix/sunos.c +++ b/Utilities/cmlibuv/src/unix/sunos.c @@ -158,6 +158,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { sigset_t set; uint64_t base; uint64_t diff; + uint64_t idle_poll; unsigned int nfds; unsigned int i; int saved_errno; @@ -166,6 +167,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { int count; int err; int fd; + int user_timeout; + int reset_timeout; if (loop->nfds == 0) { assert(QUEUE_EMPTY(&loop->watcher_queue)); @@ -203,7 +206,21 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { base = loop->time; count = 48; /* Benchmarks suggest this gives the best throughput. */ + if (uv__get_internal_fields(loop)->flags & UV_METRICS_IDLE_TIME) { + reset_timeout = 1; + user_timeout = timeout; + timeout = 0; + } else { + reset_timeout = 0; + } + for (;;) { + /* Only need to set the provider_entry_time if timeout != 0. The function + * will return early if the loop isn't configured with UV_METRICS_IDLE_TIME. + */ + if (timeout != 0) + uv__metrics_set_provider_entry_time(loop); + if (timeout != -1) { spec.tv_sec = timeout / 1000; spec.tv_nsec = (timeout % 1000) * 1000000; @@ -246,6 +263,11 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { SAVE_ERRNO(uv__update_time(loop)); if (events[0].portev_source == 0) { + if (reset_timeout != 0) { + timeout = user_timeout; + reset_timeout = 0; + } + if (timeout == 0) return; @@ -286,10 +308,12 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { /* Run signal watchers last. This also affects child process watchers * because those are implemented in terms of signal watchers. */ - if (w == &loop->signal_io_watcher) + if (w == &loop->signal_io_watcher) { have_signals = 1; - else + } else { + uv__metrics_update_idle_time(loop); w->cb(loop, w, pe->portev_events); + } nevents++; @@ -301,8 +325,15 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); } - if (have_signals != 0) + if (reset_timeout != 0) { + timeout = user_timeout; + reset_timeout = 0; + } + + if (have_signals != 0) { + uv__metrics_update_idle_time(loop); loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); + } loop->watchers[loop->nwatchers] = NULL; loop->watchers[loop->nwatchers + 1] = NULL; |
