setup to only call time() if a cron is actually in use, also fix copy.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@788 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
imaginos
2007-01-20 12:10:26 +00:00
parent 30cf3a30db
commit 2bbdb72a97
2 changed files with 16 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 1999-2006 Jim Hull <imaginos@imaginos.net>
* Copyright (c) 1999-2007 Jim Hull <imaginos@imaginos.net>
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -303,11 +303,14 @@ CCron::CCron()
m_bPause = false;
}
void CCron::run( time_t iNow )
void CCron::run( time_t & iNow )
{
if ( m_bPause )
return;
if( iNow == 0 )
iNow = time( NULL );
if ( ( m_bActive ) && ( iNow >= m_iTime ) )
{
RunJob();
@@ -988,10 +991,13 @@ bool Csock::ConnectSSL( const CS_STRING & sBindhost )
#endif /* HAVE_LIBSSL */
}
bool Csock::AllowWrite( unsigned long long iNOW ) const
bool Csock::AllowWrite( unsigned long long & iNOW ) const
{
if ( ( m_iMaxBytes > 0 ) && ( m_iMaxMilliSeconds > 0 ) )
{
if( iNOW == 0 )
iNOW = millitime();
if( m_iLastSend < m_iMaxBytes )
return( true ); // allow sending if our out buffer was less than what we can send
if ( ( iNOW - m_iLastSendTime ) < m_iMaxMilliSeconds )
@@ -1657,7 +1663,8 @@ unsigned long long Csock::GetRateTime() { return( m_iMaxMilliSeconds ); }
void Csock::Cron()
{
time_t iNow = time( NULL );
time_t iNow = 0;
for( vector<CCron *>::size_type a = 0; a < m_vcCrons.size(); a++ )
{
CCron *pcCron = m_vcCrons[a];