Made secure socket logging more user friendly #4558

This commit is contained in:
XinyuHou 2015-04-29 13:25:01 +01:00
parent 88a8099881
commit 4af987e8de
1 changed files with 7 additions and 17 deletions

View File

@ -108,6 +108,7 @@ SecureSocket::secureRead(void* buffer, UInt32 n)
{ {
int r = 0; int r = 0;
if (m_ssl->m_ssl != NULL) { if (m_ssl->m_ssl != NULL) {
LOG((CLOG_DEBUG2 "reading secure socket"));
r = SSL_read(m_ssl->m_ssl, buffer, n); r = SSL_read(m_ssl->m_ssl, buffer, n);
bool fatal, retry; bool fatal, retry;
@ -126,6 +127,7 @@ SecureSocket::secureWrite(const void* buffer, UInt32 n)
{ {
int r = 0; int r = 0;
if (m_ssl->m_ssl != NULL) { if (m_ssl->m_ssl != NULL) {
LOG((CLOG_DEBUG2 "writing secure socket"));
r = SSL_write(m_ssl->m_ssl, buffer, n); r = SSL_write(m_ssl->m_ssl, buffer, n);
bool fatal, retry; bool fatal, retry;
@ -346,31 +348,19 @@ SecureSocket::checkResult(int n, bool& fatal, bool& retry)
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
// connection closed // connection closed
LOG((CLOG_DEBUG2 "secure socket error: SSL_ERROR_ZERO_RETURN")); LOG((CLOG_DEBUG2 "SSL connection has been closed"));
break; break;
case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_READ:
LOG((CLOG_DEBUG2 "secure socket error: SSL_ERROR_WANT_READ"));
retry = true;
break;
case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_WRITE:
LOG((CLOG_DEBUG2 "secure socket error: SSL_ERROR_WANT_WRITE"));
retry = true;
break;
case SSL_ERROR_WANT_CONNECT: case SSL_ERROR_WANT_CONNECT:
LOG((CLOG_DEBUG2 "secure socket error: SSL_ERROR_WANT_CONNECT"));
retry = true;
break;
case SSL_ERROR_WANT_ACCEPT: case SSL_ERROR_WANT_ACCEPT:
LOG((CLOG_DEBUG2 "secure socket error: SSL_ERROR_WANT_ACCEPT")); LOG((CLOG_DEBUG2 "need to retry the same SSL function"));
retry = true; retry = true;
break; break;
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL:
LOG((CLOG_ERR "secure socket error: SSL_ERROR_SYSCALL")); LOG((CLOG_ERR "some secure socket I/O error occurred"));
if (ERR_peek_error() == 0) { if (ERR_peek_error() == 0) {
if (n == 0) { if (n == 0) {
LOG((CLOG_ERR "an EOF violates the protocol")); LOG((CLOG_ERR "an EOF violates the protocol"));
@ -390,12 +380,12 @@ SecureSocket::checkResult(int n, bool& fatal, bool& retry)
break; break;
case SSL_ERROR_SSL: case SSL_ERROR_SSL:
LOG((CLOG_ERR "secure socket error: SSL_ERROR_SSL")); LOG((CLOG_ERR "a failure in the SSL library occurred"));
fatal = true; fatal = true;
break; break;
default: default:
LOG((CLOG_ERR "secure socket error: unknown")); LOG((CLOG_ERR "unknown secure socket error"));
fatal = true; fatal = true;
break; break;
} }