synergy hook DLL will now restart itself if a client tries to

init() it while it's already running.  fixed an uninitialized
pointer bug in CServer and some cleanup-on-error code in
CMSWindowsPrimaryScreen.  also added timeout to read() on
IInputStream and a heartbeat sent by clients so the server
can disconnect clients that are dead but never reset the TCP
connection.  previously the server would keep these dead
clients around forever and if the user was locked on the
client screen for some reason then the server would have to
be rebooted (or the server would have to be killed via a
remote login).
This commit is contained in:
crs
2002-06-26 16:31:48 +00:00
parent d9b2c59d02
commit ed8ed72f26
14 changed files with 169 additions and 63 deletions

View File

@@ -2,6 +2,7 @@
#include "CLock.h"
#include "CMutex.h"
#include "CThread.h"
#include "CStopwatch.h"
#include "IJob.h"
#include "XIO.h"
#include <cstring>
@@ -43,15 +44,19 @@ CBufferedInputStream::hangup()
}
UInt32
CBufferedInputStream::readNoLock(void* dst, UInt32 n)
CBufferedInputStream::readNoLock(void* dst, UInt32 n, double timeout)
{
if (m_closed) {
throw XIOClosed();
}
// wait for data (or hangup)
// wait for data, hangup, or timeout
CStopwatch timer(true);
while (!m_hungup && m_empty == true) {
m_empty.wait();
if (!m_empty.wait(timer, timeout)) {
// timed out
return (UInt32)-1;
}
}
// read data
@@ -98,10 +103,10 @@ CBufferedInputStream::close()
}
UInt32
CBufferedInputStream::read(void* dst, UInt32 n)
CBufferedInputStream::read(void* dst, UInt32 n, double timeout)
{
CLock lock(m_mutex);
return readNoLock(dst, n);
return readNoLock(dst, n, timeout);
}
UInt32