diff options
author | Pierre Ossman <ossman@cendio.se> | 2016-04-29 14:28:54 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2016-04-29 14:28:54 +0200 |
commit | 278e420bbb855f39b67e21e583bea599ea8b020a (patch) | |
tree | 45eb3994d107ad95e64727dc659ca5ce53a66e0f /unix | |
parent | 3529468b8cbd22d63daf71fdc7efc4333f73611f (diff) | |
download | tigervnc-278e420bbb855f39b67e21e583bea599ea8b020a.tar.gz tigervnc-278e420bbb855f39b67e21e583bea599ea8b020a.zip |
Fix timeout handling in x0vncserver
We need to proper respect the timeouts set up by the core RFB code
and not just the polling scheduler.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/x0vncserver/x0vncserver.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 791714e9..caf7814f 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -508,6 +508,7 @@ int main(int argc, char** argv) PollingScheduler sched((int)pollingCycle, (int)maxProcessorUsage); while (!caughtSignal) { + int wait_ms; struct timeval tv; fd_set rfds; std::list<Socket*> sockets; @@ -538,23 +539,24 @@ int main(int argc, char** argv) if (!clients_connected) sched.reset(); + wait_ms = 0; + if (sched.isRunning()) { - int wait_ms = sched.millisRemaining(); + wait_ms = sched.millisRemaining(); if (wait_ms > 500) { wait_ms = 500; } - tv.tv_usec = wait_ms * 1000; -#ifdef DEBUG - // fprintf(stderr, "[%d]\t", wait_ms); -#endif - } else { - tv.tv_usec = 100000; } - tv.tv_sec = 0; + + soonestTimeout(&wait_ms, server.checkTimeouts()); + + tv.tv_sec = wait_ms / 1000; + tv.tv_usec = (wait_ms % 1000) * 1000; // Do the wait... sched.sleepStarted(); - int n = select(FD_SETSIZE, &rfds, 0, 0, &tv); + int n = select(FD_SETSIZE, &rfds, 0, 0, + wait_ms ? &tv : NULL); sched.sleepFinished(); if (n < 0) { @@ -580,7 +582,6 @@ int main(int argc, char** argv) } } - Timer::checkTimeouts(); server.checkTimeouts(); // Client list could have been changed. |