From 9210bdc97e2320301725dcae7ed0242d244f260c Mon Sep 17 00:00:00 2001 From: psychon Date: Sun, 18 Jan 2009 10:32:16 +0000 Subject: [PATCH] Update to latest Csocket git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1335 726aef4b-f618-498e-8847-2d620e286838 --- Csocket.cpp | 6 +++++- Csocket.h | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Csocket.cpp b/Csocket.cpp index 1d144b1b..6842818c 100644 --- a/Csocket.cpp +++ b/Csocket.cpp @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.90 $ +* $Revision: 1.92 $ */ #include "Csocket.h" @@ -562,6 +562,7 @@ void Csock::Dereference() #endif /* HAVE_LIBSSL */ m_vcCrons.clear(); + Close( CLT_DEREFERENCE ); } void Csock::Copy( const Csock & cCopy ) @@ -1029,6 +1030,8 @@ bool Csock::SSLClientSetup() if ( !m_ssl_ctx ) return( false ); + SSL_CTX_set_default_verify_paths( m_ssl_ctx ); + if ( !m_sPemFile.empty() ) { // are we sending a client cerificate ? SSL_CTX_set_default_passwd_cb( m_ssl_ctx, PemPassCB ); @@ -1117,6 +1120,7 @@ bool Csock::SSLServerSetup() m_ssl_ctx = SSL_CTX_new ( m_ssl_method ); if ( !m_ssl_ctx ) return( false ); + SSL_CTX_set_default_verify_paths( m_ssl_ctx ); // set the pemfile password SSL_CTX_set_default_passwd_cb( m_ssl_ctx, PemPassCB ); diff --git a/Csocket.h b/Csocket.h index 7d5f5486..7134b78a 100644 --- a/Csocket.h +++ b/Csocket.h @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.200 $ +* $Revision: 1.202 $ */ // note to compile with win32 need to link to winsock2, using gcc its -lws2_32 @@ -473,7 +473,8 @@ public: { CLT_DONT = 0, //! don't close DER CLT_NOW = 1, //! close immediatly - CLT_AFTERWRITE = 2 //! close after finishing writing the buffer + CLT_AFTERWRITE = 2, //! close after finishing writing the buffer + CLT_DEREFERENCE = 3 //! used after copy in Csock::Dereference() to cleanup a sock thats being shutdown }; Csock & operator<<( const CS_STRING & s ); @@ -1726,11 +1727,14 @@ public: T * pSock = (*this)[iPos]; - if ( pSock->IsConnected() ) - pSock->Disconnected(); // only call disconnected event if connected event was called (IE IsConnected was set) + if( pSock->GetCloseType() != T::CLT_DEREFERENCE ) + { + if ( pSock->IsConnected() ) + pSock->Disconnected(); // only call disconnected event if connected event was called (IE IsConnected was set) - m_iBytesRead += pSock->GetBytesRead(); - m_iBytesWritten += pSock->GetBytesWritten(); + m_iBytesRead += pSock->GetBytesRead(); + m_iBytesWritten += pSock->GetBytesWritten(); + } CS_Delete( pSock ); this->erase( this->begin() + iPos ); @@ -1753,8 +1757,8 @@ public: Csock *pSock = (*this)[iOrginalSockIdx]; pNewSock->Copy( *pSock ); pSock->Dereference(); - CS_Delete( pSock ); (*this)[iOrginalSockIdx] = (T *)pNewSock; + this->push_back( (T *)pSock ); // this allows it to get cleaned up return( true ); } @@ -1825,7 +1829,8 @@ private: // before we go any further, Process work needing to be done on the job for( unsigned int i = 0; i < this->size(); i++ ) { - if ( ( (*this)[i]->GetCloseType() == T::CLT_NOW ) || ( ( (*this)[i]->GetCloseType() == T::CLT_AFTERWRITE ) && ( (*this)[i]->GetWriteBuffer().empty() ) ) ) + Csock::ECloseType eCloseType = (*this)[i]->GetCloseType(); + if( eCloseType == T::CLT_NOW || eCloseType == T::CLT_DEREFERENCE || ( eCloseType == T::CLT_AFTERWRITE && (*this)[i]->GetWriteBuffer().empty() ) ) DelSock( i-- ); // close any socks that have requested it else (*this)[i]->Cron(); // call the Cron handler here