bool CEDClients::IsFull(const CEDClient* pCheckThis) { CQuickLock oLock( m_pSection ); // Count the number of connected clients DWORD nCount = 0; for ( CEDClient* pClient = m_pFirst ; pClient ; pClient = pClient->m_pEdNext ) { if ( pClient->IsValid() ) ++nCount; } // Get current time const DWORD tNow = GetTickCount(); // If there are more clients current connected than there should be, set full timer if ( nCount >= Settings.eDonkey.MaxLinks ) m_tLastMaxClients = tNow; // If we have not been full in the past 2 seconds, then we're okay to start new connections if ( tNow - m_tLastMaxClients > 2ul * 1000ul ) return false; // If we're checking a client that's already connected, say we aren't full. (don't drop it) if ( pCheckThis && pCheckThis->IsValid() ) return false; // We're too full to start new connections return true; }
BOOL CEDClients::IsOverloaded() const { CQuickLock oLock( m_pSection ); DWORD nCount = 0; for ( CEDClient* pClient = m_pFirst ; pClient ; pClient = pClient->m_pEdNext ) { if ( pClient->IsValid() ) nCount++; } return ( nCount >= ( Settings.eDonkey.MaxLinks + 25 ) ); }