BOOL CEDClients::OnAccept(CConnection* pConnection) { ASSERT( pConnection != NULL ); if ( Settings.Connection.RequireForTransfers && ! Settings.eDonkey.EnableToday ) { theApp.Message( MSG_ERROR, IDS_ED2K_CLIENT_DISABLED, (LPCTSTR)pConnection->m_sAddress ); return FALSE; } CSingleLock pLock( &Transfers.m_pSection ); if ( ! pLock.Lock( 250 ) ) return FALSE; if ( IsFull() ) { // Even if we're full, we still need to accept connections from clients we have queued, etc if ( ( GetByIP( &pConnection->m_pHost.sin_addr ) == NULL ) || ( IsOverloaded() ) ) { theApp.Message( MSG_DEBUG, _T("Rejecting ed2k connection from %s, max client connections reached."), (LPCTSTR)pConnection->m_sAddress ); return FALSE; } else { theApp.Message( MSG_DEBUG, _T("Accepting ed2k connection from %s despite client connection limit."), (LPCTSTR)pConnection->m_sAddress ); } } CEDClient* pClient = new CEDClient(); pClient->AttachTo( pConnection ); return TRUE; }