diff --git a/include/znc/Csocket.h b/include/znc/Csocket.h index 0145ab02..b8428e79 100644 --- a/include/znc/Csocket.h +++ b/include/znc/Csocket.h @@ -395,6 +395,9 @@ public: //! removes the pause on RunJon void UnPause(); + //! reset the timer + void Reset(); + timeval GetInterval() const; uint32_t GetMaxCycles() const; uint32_t GetCyclesLeft() const; diff --git a/src/Csocket.cpp b/src/Csocket.cpp index 2edb0834..347fd394 100644 --- a/src/Csocket.cpp +++ b/src/Csocket.cpp @@ -697,6 +697,7 @@ void CCron::StartMaxCycles( double dTimeSequence, u_int iMaxCycles ) gettimeofday( &tNow, NULL ); timeradd( &tNow, &m_tTimeSequence, &m_tTime ); m_iMaxCycles = iMaxCycles; + m_bActive = true; } void CCron::StartMaxCycles( const timeval& tTimeSequence, u_int iMaxCycles ) @@ -706,6 +707,7 @@ void CCron::StartMaxCycles( const timeval& tTimeSequence, u_int iMaxCycles ) gettimeofday( &tNow, NULL ); timeradd( &tNow, &m_tTimeSequence, &m_tTime ); m_iMaxCycles = iMaxCycles; + m_bActive = true; } void CCron::Start( double dTimeSequence ) @@ -733,6 +735,12 @@ void CCron::UnPause() m_bPause = false; } +void CCron::Reset() +{ + Stop(); + Start(m_tTimeSequence); +} + timeval CCron::GetInterval() const { return( m_tTimeSequence ); } u_int CCron::GetMaxCycles() const { return( m_iMaxCycles ); } u_int CCron::GetCyclesLeft() const { return( ( m_iMaxCycles > m_iCycles ? ( m_iMaxCycles - m_iCycles ) : 0 ) ); } @@ -1867,13 +1875,12 @@ bool Csock::Write( const char *data, size_t len ) #else cs_ssize_t bytes = write( m_iWriteSock, m_sSend.data() + m_uSendBufferPos, iBytesToSend ); #endif /* _WIN32 */ - if( bytes > 0 ) - if( bytes == -1 && GetSockError() == ECONNREFUSED ) - { - ConnectionRefused(); - return( false ); - } + if( bytes == -1 && GetSockError() == ECONNREFUSED ) + { + ConnectionRefused(); + return( false ); + } #ifdef _WIN32 if( bytes <= 0 && GetSockError() != WSAEWOULDBLOCK )