Improved secure socket intensive try operations #4796

This commit is contained in:
Jerry (Xinyu Hou) 2015-06-12 16:53:41 -07:00
parent 099c984d7d
commit 3e32d9fbee
3 changed files with 17 additions and 8 deletions

View File

@ -496,7 +496,7 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
} }
else if (status == 0) { else if (status == 0) {
s_retryOutputBufferSize = buffSize; s_retryOutputBufferSize = buffSize;
return job; return newJob();
} }
} }
else { else {
@ -559,7 +559,7 @@ TCPSocket::serviceConnected(ISocketMultiplexerJob* job,
return NULL; return NULL;
} }
else if (status == 0) { else if (status == 0) {
return job; return newJob();
} }
} }
else { else {

View File

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

View File

@ -417,14 +417,21 @@ SecureSocket::checkResult(int status, int& retry)
break; break;
case SSL_ERROR_WANT_READ: 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: 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_CONNECT:
case SSL_ERROR_WANT_ACCEPT: 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++; 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; break;
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL: