Merge branch 'v1.7.4-stable' of https://github.com/synergy/synergy into v1.7.4-stable

This commit is contained in:
Adam Potolsky
2015-06-18 14:19:06 -07:00
12 changed files with 114 additions and 49 deletions

View File

@@ -273,6 +273,7 @@ Client::leave()
if (m_sendClipboardThread != NULL) {
StreamChunker::interruptClipboard();
m_sendClipboardThread->wait();
m_sendClipboardThread = NULL;
}

View File

@@ -469,34 +469,47 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
}
bool needNewJob = false;
static UInt32 s_retryOutputBufferSize = 0;
static bool s_retry = false;
static int s_retrySize = 0;
static void* s_staticBuffer = NULL;
if (write) {
try {
// write data
int buffSize = m_outputBuffer.getSize();
int bufferSize = 0;
int bytesWrote = 0;
int status = 0;
if (s_retryOutputBufferSize > 0) {
buffSize = s_retryOutputBufferSize;
if (s_retry) {
bufferSize = s_retrySize;
}
else {
bufferSize = m_outputBuffer.getSize();
s_staticBuffer = malloc(bufferSize);
memcpy(s_staticBuffer, m_outputBuffer.peek(bufferSize), bufferSize);
}
const void* buffer = m_outputBuffer.peek(buffSize);
if (bufferSize == 0) {
return job;
}
if (isSecure()) {
if (isSecureReady()) {
status = secureWrite(buffer, buffSize, bytesWrote);
status = secureWrite(s_staticBuffer, bufferSize, bytesWrote);
if (status > 0) {
s_retryOutputBufferSize = 0;
s_retry = false;
bufferSize = 0;
free(s_staticBuffer);
s_staticBuffer = NULL;
}
else if (status < 0) {
return NULL;
}
else if (status == 0) {
s_retryOutputBufferSize = buffSize;
return job;
s_retry = true;
s_retrySize = bufferSize;
return newJob();
}
}
else {
@@ -504,7 +517,10 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
}
}
else {
bytesWrote = (UInt32)ARCH->writeSocket(m_socket, buffer, buffSize);
bytesWrote = (UInt32)ARCH->writeSocket(m_socket, s_staticBuffer, bufferSize);
bufferSize = 0;
free(s_staticBuffer);
s_staticBuffer = NULL;
}
// discard written data
@@ -559,7 +575,7 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
return NULL;
}
else if (status == 0) {
return job;
return newJob();
}
}
else {

View File

@@ -96,6 +96,10 @@ private:
serviceConnected(ISocketMultiplexerJob*,
bool, bool, bool);
protected:
bool m_readable;
bool m_writable;
private:
Mutex m_mutex;
ArchSocket m_socket;
@@ -103,8 +107,6 @@ private:
StreamBuffer m_outputBuffer;
CondVar<bool> m_flushed;
bool m_connected;
bool m_readable;
bool m_writable;
IEventQueue* m_events;
SocketMultiplexer* m_socketMultiplexer;
};

View File

@@ -417,14 +417,21 @@ SecureSocket::checkResult(int status, int& retry)
break;
case SSL_ERROR_WANT_READ:
m_readable = true;
retry++;
LOG((CLOG_DEBUG2 "want to read, error=%d, attempt=%d", errorCode, retry));
break;
case SSL_ERROR_WANT_WRITE:
m_writable = true;
retry++;
LOG((CLOG_DEBUG2 "want to write, error=%d, attempt=%d", errorCode, retry));
break;
case SSL_ERROR_WANT_CONNECT:
case SSL_ERROR_WANT_ACCEPT:
// it seems like these sort of errors are part of openssl's normal behavior,
// so we should expect a very high amount of these. sleeping doesn't seem to
// help... maybe you just have to swallow the errors (yuck).
retry++;
LOG((CLOG_DEBUG2 "passive ssl error, error=%d, attempt=%d", errorCode, retry));
LOG((CLOG_DEBUG2 "want to connect, error=%d, attempt=%d", errorCode, retry));
break;
case SSL_ERROR_SYSCALL:

View File

@@ -509,6 +509,8 @@ Server::switchScreen(BaseClientProxy* dst,
// clipboard data could be corrupted on the other side
if (m_sendClipboardThread != NULL) {
StreamChunker::interruptClipboard();
m_sendClipboardThread->wait();
m_sendClipboardThread = NULL;
}
// send the clipboard data to new active screen