Browse Source

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.
tags/v1.6.90
Pierre Ossman 8 years ago
parent
commit
278e420bbb
1 changed files with 11 additions and 10 deletions
  1. 11
    10
      unix/x0vncserver/x0vncserver.cxx

+ 11
- 10
unix/x0vncserver/x0vncserver.cxx View File

@@ -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.

Loading…
Cancel
Save