diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-03 09:24:51 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-06-19 16:39:07 +0200 |
commit | bf286837db638a67bde0ab9be0baa621f863b8d5 (patch) | |
tree | ab74492ab53922a216b338a1f1f84312439552d4 /unix | |
parent | 37cf0ffaba7f4e855a909f57adf72da43c0ac275 (diff) | |
download | tigervnc-bf286837db638a67bde0ab9be0baa621f863b8d5.tar.gz tigervnc-bf286837db638a67bde0ab9be0baa621f863b8d5.zip |
Stop treating "0" as "no timeouts"
It is much more sane to treat "0" as "a timer is ready NOW", so let's
change to using -1 as the invalid timeout value.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/vncconfig/vncconfig.cxx | 2 | ||||
-rw-r--r-- | unix/x0vncserver/x0vncserver.cxx | 7 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.cc | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx index f39e9934..be8c8195 100644 --- a/unix/vncconfig/vncconfig.cxx +++ b/unix/vncconfig/vncconfig.cxx @@ -308,7 +308,7 @@ int main(int argc, char** argv) // Process expired timers and get the time until the next one int timeoutMs = Timer::checkTimeouts(); - if (timeoutMs) { + if (timeoutMs >= 0) { tv.tv_sec = timeoutMs / 1000; tv.tv_usec = (timeoutMs % 1000) * 1000; tvp = &tv; diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 8e27e62b..ffaf5788 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -382,7 +382,7 @@ int main(int argc, char** argv) PollingScheduler sched((int)pollingCycle, (int)maxProcessorUsage); while (!caughtSignal) { - int wait_ms; + int wait_ms, nextTimeout; struct timeval tv; fd_set rfds, wfds; std::list<Socket*> sockets; @@ -426,7 +426,10 @@ int main(int argc, char** argv) } } - soonestTimeout(&wait_ms, Timer::checkTimeouts()); + // Trigger timers and check when the next will expire + nextTimeout = Timer::checkTimeouts(); + if (nextTimeout >= 0 && nextTimeout < wait_ms) + wait_ms = nextTimeout; tv.tv_sec = wait_ms / 1000; tv.tv_usec = (wait_ms % 1000) * 1000; diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc index b5a58671..64b2e614 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.cc +++ b/unix/xserver/hw/vnc/XserverDesktop.cc @@ -395,7 +395,7 @@ void XserverDesktop::blockHandler(int* timeout) // Trigger timers and check when the next will expire int nextTimeout = Timer::checkTimeouts(); - if (nextTimeout > 0 && (*timeout == -1 || nextTimeout < *timeout)) + if (nextTimeout >= 0 && (*timeout == -1 || nextTimeout < *timeout)) *timeout = nextTimeout; } catch (rdr::Exception& e) { vlog.error("XserverDesktop::blockHandler: %s",e.str()); |