From 70f57afea5e3b3e9a3b58a2f9397b84a6647a167 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 22 Mar 2007 19:36:16 +0000 Subject: EAGAIN fixes for gnutls git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6698 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_ssl_gnutls.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/modules/extra') diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index ec6680d24..5896f812b 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -383,6 +383,7 @@ class ModuleSSLGnuTLS : public Module virtual void OnRawSocketClose(int fd) { + ServerInstance->Log(DEBUG,"Close 3"); CloseSession(&sessions[fd]); EventHandler* user = ServerInstance->SE->GetRef(fd); @@ -403,6 +404,7 @@ class ModuleSSLGnuTLS : public Module if (!session->sess) { readresult = 0; + ServerInstance->Log(DEBUG,"Close 4"); CloseSession(session); return 1; } @@ -419,6 +421,7 @@ class ModuleSSLGnuTLS : public Module } else if (session->status == ISSL_HANDSHAKING_WRITE) { + errno = EAGAIN; return -1; } @@ -434,6 +437,7 @@ class ModuleSSLGnuTLS : public Module { // Client closed connection. readresult = 0; + ServerInstance->Log(DEBUG,"Close 5"); CloseSession(session); return 1; } @@ -447,6 +451,7 @@ class ModuleSSLGnuTLS : public Module else { readresult = 0; + ServerInstance->Log(DEBUG,"Close 6"); CloseSession(session); } } @@ -495,6 +500,7 @@ class ModuleSSLGnuTLS : public Module if (!session->sess) { + ServerInstance->Log(DEBUG,"Close 7"); CloseSession(session); return 1; } @@ -508,7 +514,7 @@ class ModuleSSLGnuTLS : public Module // The handshake isn't finished, try to finish it. Handshake(session); errno = EAGAIN; - return 0; + return -1; } int ret = 0; @@ -518,11 +524,22 @@ class ModuleSSLGnuTLS : public Module ret = gnutls_record_send(session->sess, sendbuffer, count); if(ret == 0) + { + ServerInstance->Log(DEBUG,"Close 1"); CloseSession(session); - else if(ret < 0) + } + else if (ret < 0) { if(ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) + { + ServerInstance->Log(DEBUG,"Close 7"); CloseSession(session); + } + else + { + errno = EAGAIN; + return -1; + } } else { @@ -603,6 +620,7 @@ class ModuleSSLGnuTLS : public Module else { // Handshake failed. + ServerInstance->Log(DEBUG,"Close 2"); CloseSession(session); session->status = ISSL_CLOSING; } -- cgit v1.2.3