Permalink
Browse files

Fix #386 stuck on exit because of stucked wait in netloop

  • Loading branch information...
klirichek committed Aug 13, 2018
1 parent 6e5b57e commit 39c740fef5bf71da0bee60a35f5dd9f471af850f
Showing with 20 additions and 0 deletions.
  1. +19 −0 src/searchdha.cpp
  2. +1 −0 src/searchdha.h
@@ -1762,6 +1762,11 @@ void AgentConn_t::HardTimeoutCallback ()
sphLogDebugA ( "%d <- hard timeout (ref=%d)", m_iStoreTag, ( int ) GetRefcount () );
}
void AgentConn_t::AbortCallback()
{
ReportFinish (false);
}
void AgentConn_t::ErrorCallback ( int64_t iWaited )
{
if ( !m_pPollerTask )
@@ -3540,6 +3545,19 @@ class LazyNetEvents_c : ISphNoncopyable, protected NetEventsFlavour_c
return bHasTimeout; /// means 'infinite'
}
/// abandon and release all events (on shutdown)
void AbortScheduled ()
{
while ( !m_dTimeouts.IsEmpty () )
{
auto pTask = m_dTimeouts.Root ();
m_dTimeouts.Pop ();
CSphRefcountedPtr<AgentConn_t> pKeepConn ( DeleteTask ( pTask, false ) );
if ( pKeepConn )
pKeepConn->AbortCallback ();
}
}
/// one event cycle.
/// \return false to stop event loop and exit.
bool EventTick () REQUIRES ( LazyThread )
@@ -3558,6 +3576,7 @@ class LazyNetEvents_c : ISphNoncopyable, protected NetEventsFlavour_c
if ( g_bShutdown )
{
AbortScheduled();
sphInfo ( "EventTick() exit because of shutdown=%d", g_bShutdown );
return false;
}
@@ -495,6 +495,7 @@ struct AgentConn_t : public ISphRefcountedMT
void RecvCallback ( int64_t iWaited, DWORD uReceived );
void SoftTimeoutCallback();
void HardTimeoutCallback();
void AbortCallback();
#if USE_WINDOWS
// move recv buffer to dOut, reinit mine.

0 comments on commit 39c740f

Please sign in to comment.