Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/searchdha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,22 @@ void PersistentConnectionsPool_c::ReturnConnection ( int iSocket )
m_dSockets[Step ( &m_iWit )] = iSocket;
}

void PersistentConnectionsPool_c::CloseIdleConnections ()
{
ScopedMutex_t tGuard ( m_dDataLock );

int iRead = m_iRit;
for ( int i = 0; i<m_iFreeWindow; ++i )
{
int & iSock = m_dSockets[Step ( &iRead )];
if ( iSock>=0 )
{
sphSockClose ( iSock );
iSock = -1;
}
}
}

// close all the sockets in the pool.
void PersistentConnectionsPool_c::Shutdown ()
{
Expand Down Expand Up @@ -1662,6 +1678,8 @@ bool AgentConn_t::Fatal ( AgentStats_e eStat, const char * sMessage, ... )
va_end ( ap );
sphLogDebugv ( "%d FATAL: %s", m_iStoreTag, m_sFailure.cstr () ); // want to log failure at extended log mode wo recompile of daemon
State ( Agent_e::RETRY );
if ( IsPersistent () )
m_tDesc.m_pDash->m_pPersPool->CloseIdleConnections ();
Finish ( true );
agent_stats_inc ( *this, eStat );
return false;
Expand Down Expand Up @@ -3894,4 +3912,3 @@ bool sphNBSockEof ( int iSock )
return true;
return false;
}

1 change: 1 addition & 0 deletions src/searchdha.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class PersistentConnectionsPool_c
void ReInit ( int iPoolSize ) REQUIRES ( !m_dDataLock );
int RentConnection () REQUIRES ( !m_dDataLock );
void ReturnConnection ( int iSocket ) REQUIRES ( !m_dDataLock );
void CloseIdleConnections () REQUIRES ( !m_dDataLock );
void Shutdown () REQUIRES ( !m_dDataLock );
};

Expand Down
Loading