Browse Source

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.
tags/v1.9.90
Pierre Ossman 5 years ago
parent
commit
a4308c9ec4

+ 0
- 7
common/network/Socket.h View File

// This is only necessary if the Socket has been put in non-blocking // This is only necessary if the Socket has been put in non-blocking
// mode and needs this callback to flush the buffer. // mode and needs this callback to flush the buffer.
virtual void processSocketWriteEvent(network::Socket* sock) = 0; 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;
}; };


} }

+ 0
- 10
common/rfb/VNCServerST.cxx View File

throw rdr::Exception("invalid Socket in VNCServerST"); throw rdr::Exception("invalid Socket in VNCServerST");
} }


int VNCServerST::checkTimeouts()
{
int timeout = 0;

soonestTimeout(&timeout, Timer::checkTimeouts());
return timeout;
}


// VNCServer methods // VNCServer methods


void VNCServerST::blockUpdates() void VNCServerST::blockUpdates()

+ 0
- 6
common/rfb/VNCServerST.h View File

// Flush pending data from the Socket on to the network. // Flush pending data from the Socket on to the network.
virtual void processSocketWriteEvent(network::Socket* sock); 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 // Methods overridden from VNCServer



+ 2
- 2
unix/x0vncserver/x0vncserver.cxx View File

} }
} }


soonestTimeout(&wait_ms, server.checkTimeouts());
soonestTimeout(&wait_ms, Timer::checkTimeouts());


tv.tv_sec = wait_ms / 1000; tv.tv_sec = wait_ms / 1000;
tv.tv_usec = (wait_ms % 1000) * 1000; tv.tv_usec = (wait_ms % 1000) * 1000;
} }
} }


server.checkTimeouts();
Timer::checkTimeouts();


// Client list could have been changed. // Client list could have been changed.
server.getSockets(&sockets); server.getSockets(&sockets);

+ 1
- 1
unix/xserver/hw/vnc/XserverDesktop.cc View File

} }


// Trigger timers and check when the next will expire // Trigger timers and check when the next will expire
int nextTimeout = server->checkTimeouts();
int nextTimeout = Timer::checkTimeouts();
if (nextTimeout > 0 && (*timeout == -1 || nextTimeout < *timeout)) if (nextTimeout > 0 && (*timeout == -1 || nextTimeout < *timeout))
*timeout = nextTimeout; *timeout = nextTimeout;
} catch (rdr::Exception& e) { } catch (rdr::Exception& e) {

+ 2
- 1
win/rfb_win32/SocketManager.cxx View File

#include <winsock2.h> #include <winsock2.h>
#include <list> #include <list>
#include <rfb/LogWriter.h> #include <rfb/LogWriter.h>
#include <rfb/Timer.h>
#include <rfb_win32/SocketManager.h> #include <rfb_win32/SocketManager.h>


using namespace rfb; using namespace rfb;


std::map<HANDLE,ListenInfo>::iterator i; std::map<HANDLE,ListenInfo>::iterator i;
for (i=listeners.begin(); i!=listeners.end(); i++) for (i=listeners.begin(); i!=listeners.end(); i++)
soonestTimeout(&timeout, i->second.server->checkTimeouts());
soonestTimeout(&timeout, Timer::checkTimeouts());


std::list<network::Socket*> shutdownSocks; std::list<network::Socket*> shutdownSocks;
std::map<HANDLE,ConnInfo>::iterator j, j_next; std::map<HANDLE,ConnInfo>::iterator j, j_next;

Loading…
Cancel
Save