From d0e323971e9a35f494dfe2bd8d652b89e2e08661 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 17 Mar 2020 11:03:54 -0600 Subject: [PATCH] zos: fix potential event loop stall This is a port of 70002c80 to z/OS to fix the same potential issue that could effectively enter an infinite loop (but not a busy loop) under certain conditions when polling for events. PR-URL: https://github.com/libuv/libuv/pull/2725 Reviewed-By: Fedor Indutny Reviewed-By: Santiago Gimeno Reviewed-By: Jameson Nash --- src/unix/os390.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/unix/os390.c b/src/unix/os390.c index dce169b9..458e7310 100644 --- a/src/unix/os390.c +++ b/src/unix/os390.c @@ -887,12 +887,13 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (nfds == 0) { assert(timeout != -1); - if (timeout > 0) { - timeout = real_timeout - timeout; - continue; - } + if (timeout == 0) + return; - return; + /* We may have been inside the system call for longer than |timeout| + * milliseconds so we need to update the timestamp to avoid drift. + */ + goto update_timeout; } if (nfds == -1) {