diff options
author | Rickard Green <[email protected]> | 2016-08-31 14:29:56 +0200 |
---|---|---|
committer | Rickard Green <[email protected]> | 2016-08-31 14:29:56 +0200 |
commit | 74fecb1c89c9f3149dc0e42b2a4a19827a28370f (patch) | |
tree | 878cc36923f6fd7cee7d5cc8475021610a5617e3 /erts/emulator | |
parent | bfe6427fa5ec615e73fc0aad2c5760370d786b19 (diff) | |
parent | 451eb69edbe6c1b2ed53bcac18babda57e5f964c (diff) | |
download | otp-74fecb1c89c9f3149dc0e42b2a4a19827a28370f.tar.gz otp-74fecb1c89c9f3149dc0e42b2a4a19827a28370f.tar.bz2 otp-74fecb1c89c9f3149dc0e42b2a4a19827a28370f.zip |
Merge branch 'maint'
* maint:
Improve accuracy of timeouts using premature timeouts
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/sys/common/erl_poll.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/erts/emulator/sys/common/erl_poll.c b/erts/emulator/sys/common/erl_poll.c index e394d84f73..b8a28bcc18 100644 --- a/erts/emulator/sys/common/erl_poll.c +++ b/erts/emulator/sys/common/erl_poll.c @@ -75,6 +75,7 @@ #include "erl_driver.h" #include "erl_alloc.h" #include "erl_msacc.h" +#include "erl_misc_utils.h" #if !defined(ERTS_POLL_USE_EPOLL) \ && !defined(ERTS_POLL_USE_DEVPOLL) \ @@ -2132,16 +2133,19 @@ get_timeout(ErtsPollSet ps, if (timeout > (ErtsMonotonicTime) INT_MAX) timeout = (ErtsMonotonicTime) INT_MAX; save_timeout_time += ERTS_MSEC_TO_MONOTONIC(timeout); + timeout -= ERTS_PREMATURE_TIMEOUT(timeout, 1000); break; case 1000000: /* Round up to nearest even micro second */ timeout = ERTS_MONOTONIC_TO_USEC(diff_time - 1) + 1; save_timeout_time += ERTS_USEC_TO_MONOTONIC(timeout); + timeout -= ERTS_PREMATURE_TIMEOUT(timeout, 1000*1000); break; case 1000000000: /* Round up to nearest even nano second */ timeout = ERTS_MONOTONIC_TO_NSEC(diff_time - 1) + 1; save_timeout_time += ERTS_NSEC_TO_MONOTONIC(timeout); + timeout -= ERTS_PREMATURE_TIMEOUT(timeout, 1000*1000*1000); break; default: ERTS_INTERNAL_ERROR("Invalid resolution"); @@ -2452,7 +2456,15 @@ ERTS_POLL_EXPORT(erts_poll_wait)(ErtsPollSet ps, } #endif - res = check_fd_events(ps, to, no_fds); + while (1) { + res = check_fd_events(ps, to, no_fds); + if (res != 0) + break; + if (to == ERTS_POLL_NO_TIMEOUT) + break; + if (erts_get_monotonic_time(NULL) >= timeout_time) + break; + } woke_up(ps); |