mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
Update Csocket
This fixes an unimportant leak (if ReadBuf or ReadLine returned by throwing an exception a 4k buffer was leaked). We only triggered this if we were shutting down and thus this leak is unimportant to us. Also remove the svn:keywords property from Csocket.h and .cpp so the $Revision$ strings from upstream aren't changed. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@854 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* $Revision$
|
||||
* $Revision: 1.58 $
|
||||
*/
|
||||
|
||||
#include "Csocket.h"
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* $Revision$
|
||||
* $Revision: 1.174 $
|
||||
*/
|
||||
|
||||
// note to compile with win32 need to link to winsock2, using gcc its -lws2_32
|
||||
@@ -112,6 +112,27 @@ namespace Csocket
|
||||
{
|
||||
#endif /* _NO_CSOCKET_NS */
|
||||
|
||||
/**
|
||||
* @class CSCharBuffer
|
||||
* @brief ease of use self deleting char * class
|
||||
*/
|
||||
class CSCharBuffer
|
||||
{
|
||||
public:
|
||||
CSCharBuffer( size_t iSize )
|
||||
{
|
||||
m_pBuffer = (char *)malloc( iSize );
|
||||
}
|
||||
~CSCharBuffer()
|
||||
{
|
||||
free( m_pBuffer );
|
||||
}
|
||||
char * operator()() { return( m_pBuffer ); }
|
||||
|
||||
private:
|
||||
char * m_pBuffer;
|
||||
};
|
||||
|
||||
class CSSockAddr
|
||||
{
|
||||
public:
|
||||
@@ -1461,22 +1482,17 @@ public:
|
||||
{
|
||||
// read in data
|
||||
// if this is a
|
||||
char *buff;
|
||||
int iLen = 0;
|
||||
|
||||
if ( pcSock->GetSSL() )
|
||||
iLen = pcSock->GetPending();
|
||||
|
||||
if ( iLen > 0 )
|
||||
{
|
||||
buff = (char *)malloc( iLen );
|
||||
} else
|
||||
{
|
||||
if ( iLen <= 0 )
|
||||
iLen = CS_BLOCKSIZE;
|
||||
buff = (char *)malloc( CS_BLOCKSIZE );
|
||||
}
|
||||
|
||||
CSCharBuffer cBuff( iLen );
|
||||
|
||||
int bytes = pcSock->Read( buff, iLen );
|
||||
int bytes = pcSock->Read( cBuff(), iLen );
|
||||
|
||||
if ( ( bytes != T::READ_TIMEDOUT ) && ( bytes != T::READ_CONNREFUSED )
|
||||
&& ( !pcSock->IsConnected() ) )
|
||||
@@ -1518,14 +1534,12 @@ public:
|
||||
if ( T::TMO_READ & pcSock->GetTimeoutType() )
|
||||
pcSock->ResetTimer(); // reset the timeout timer
|
||||
|
||||
pcSock->ReadData( buff, bytes ); // Call ReadData() before PushBuff() so that it is called before the ReadLine() event - LD 07/18/05
|
||||
pcSock->PushBuff( buff, bytes );
|
||||
pcSock->ReadData( cBuff(), bytes ); // Call ReadData() before PushBuff() so that it is called before the ReadLine() event - LD 07/18/05
|
||||
pcSock->PushBuff( cBuff(), bytes );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// free up the buff
|
||||
free( buff );
|
||||
} else if ( iErrno == SELECT_ERROR )
|
||||
{
|
||||
// a socket came back with an error
|
||||
|
||||
Reference in New Issue
Block a user