diff options
author | Pierre Ossman <ossman@cendio.se> | 2016-04-29 14:29:43 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2016-04-29 14:29:43 +0200 |
commit | 16419cce135e9880e8d816acb7ded0249f795453 (patch) | |
tree | c93d27e99e0698803e808a748b73b59af631329e /unix | |
parent | 278e420bbb855f39b67e21e583bea599ea8b020a (diff) | |
download | tigervnc-16419cce135e9880e8d816acb7ded0249f795453.tar.gz tigervnc-16419cce135e9880e8d816acb7ded0249f795453.zip |
Use non-blocking sockets in x0vnserver
Diffstat (limited to 'unix')
-rw-r--r-- | unix/x0vncserver/x0vncserver.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index caf7814f..8f73ac2c 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -510,7 +510,7 @@ int main(int argc, char** argv) while (!caughtSignal) { int wait_ms; struct timeval tv; - fd_set rfds; + fd_set rfds, wfds; std::list<Socket*> sockets; std::list<Socket*>::iterator i; @@ -518,6 +518,8 @@ int main(int argc, char** argv) TXWindow::handleXEvents(dpy); FD_ZERO(&rfds); + FD_ZERO(&wfds); + FD_SET(ConnectionNumber(dpy), &rfds); for (std::list<TcpListener*>::iterator i = listeners.begin(); i != listeners.end(); @@ -532,6 +534,8 @@ int main(int argc, char** argv) delete (*i); } else { FD_SET((*i)->getFd(), &rfds); + if ((*i)->outStream().bufferUsage() > 0) + FD_SET((*i)->getFd(), &wfds); clients_connected++; } } @@ -555,7 +559,7 @@ int main(int argc, char** argv) // Do the wait... sched.sleepStarted(); - int n = select(FD_SETSIZE, &rfds, 0, 0, + int n = select(FD_SETSIZE, &rfds, &wfds, 0, wait_ms ? &tv : NULL); sched.sleepFinished(); @@ -575,6 +579,7 @@ int main(int argc, char** argv) if (FD_ISSET((*i)->getFd(), &rfds)) { Socket* sock = (*i)->accept(); if (sock) { + sock->outStream().setBlocking(false); server.addSocket(sock); } else { vlog.status("Client connection rejected"); @@ -595,6 +600,8 @@ int main(int argc, char** argv) for (i = sockets.begin(); i != sockets.end(); i++) { if (FD_ISSET((*i)->getFd(), &rfds)) server.processSocketReadEvent(*i); + if (FD_ISSET((*i)->getFd(), &wfds)) + server.processSocketWriteEvent(*i); } if (desktop.isRunning() && sched.goodTimeToPoll()) { |