From: Pierre Ossman Date: Fri, 26 Oct 2018 13:54:56 +0000 (+0200) Subject: Get rid of SocketServer::checkTimeouts() X-Git-Tag: v1.9.90~65^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a4308c9;p=tigervnc.git Get rid of SocketServer::checkTimeouts() It doesn't belong on each socket server object as timers are global. Force implementations to call the Timer system directly instead, avoiding any middle men. --- diff --git a/common/network/Socket.h b/common/network/Socket.h index c7d06c3e..d38feba4 100644 --- a/common/network/Socket.h +++ b/common/network/Socket.h @@ -144,13 +144,6 @@ namespace network { // This is only necessary if the Socket has been put in non-blocking // mode and needs this callback to flush the buffer. virtual void processSocketWriteEvent(network::Socket* sock) = 0; - - // checkTimeouts() allows the server to check socket timeouts, etc. The - // return value is the number of milliseconds to wait before - // checkTimeouts() should be called again. If this number is zero then - // there is no timeout and checkTimeouts() should be called the next time - // an event occurs. - virtual int checkTimeouts() = 0; }; } diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index c6734458..40580b16 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -224,16 +224,6 @@ void VNCServerST::processSocketWriteEvent(network::Socket* sock) throw rdr::Exception("invalid Socket in VNCServerST"); } -int VNCServerST::checkTimeouts() -{ - int timeout = 0; - - soonestTimeout(&timeout, Timer::checkTimeouts()); - - return timeout; -} - - // VNCServer methods void VNCServerST::blockUpdates() diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h index a994c942..43a3bb95 100644 --- a/common/rfb/VNCServerST.h +++ b/common/rfb/VNCServerST.h @@ -76,12 +76,6 @@ namespace rfb { // Flush pending data from the Socket on to the network. virtual void processSocketWriteEvent(network::Socket* sock); - // checkTimeouts - // Returns the number of milliseconds left until the next idle timeout - // expires. If any have already expired, the corresponding connections - // are closed. Zero is returned if there is no idle timeout. - virtual int checkTimeouts(); - // Methods overridden from VNCServer diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 4c8f0bf9..5f6c9f45 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -322,7 +322,7 @@ int main(int argc, char** argv) } } - soonestTimeout(&wait_ms, server.checkTimeouts()); + soonestTimeout(&wait_ms, Timer::checkTimeouts()); tv.tv_sec = wait_ms / 1000; tv.tv_usec = (wait_ms % 1000) * 1000; @@ -357,7 +357,7 @@ int main(int argc, char** argv) } } - server.checkTimeouts(); + Timer::checkTimeouts(); // Client list could have been changed. server.getSockets(&sockets); diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc index d4891c3a..d8b3a4d4 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.cc +++ b/unix/xserver/hw/vnc/XserverDesktop.cc @@ -368,7 +368,7 @@ void XserverDesktop::blockHandler(int* timeout) } // Trigger timers and check when the next will expire - int nextTimeout = server->checkTimeouts(); + int nextTimeout = Timer::checkTimeouts(); if (nextTimeout > 0 && (*timeout == -1 || nextTimeout < *timeout)) *timeout = nextTimeout; } catch (rdr::Exception& e) { diff --git a/win/rfb_win32/SocketManager.cxx b/win/rfb_win32/SocketManager.cxx index aa469e53..0092d94d 100644 --- a/win/rfb_win32/SocketManager.cxx +++ b/win/rfb_win32/SocketManager.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include using namespace rfb; @@ -161,7 +162,7 @@ int SocketManager::checkTimeouts() { std::map::iterator i; for (i=listeners.begin(); i!=listeners.end(); i++) - soonestTimeout(&timeout, i->second.server->checkTimeouts()); + soonestTimeout(&timeout, Timer::checkTimeouts()); std::list shutdownSocks; std::map::iterator j, j_next;