Skip to content

Commit

Permalink
Fix #386 stuck on exit because of stucked wait in netloop
Browse files Browse the repository at this point in the history
  • Loading branch information
klirichek committed Aug 14, 2018
1 parent 6e5b57e commit 39c740f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/searchdha.cpp
Expand Up @@ -1762,6 +1762,11 @@ void AgentConn_t::HardTimeoutCallback ()
sphLogDebugA ( "%d <- hard timeout (ref=%d)", m_iStoreTag, ( int ) GetRefcount () ); sphLogDebugA ( "%d <- hard timeout (ref=%d)", m_iStoreTag, ( int ) GetRefcount () );
} }


void AgentConn_t::AbortCallback()
{
ReportFinish (false);
}

void AgentConn_t::ErrorCallback ( int64_t iWaited ) void AgentConn_t::ErrorCallback ( int64_t iWaited )
{ {
if ( !m_pPollerTask ) if ( !m_pPollerTask )
Expand Down Expand Up @@ -3540,6 +3545,19 @@ class LazyNetEvents_c : ISphNoncopyable, protected NetEventsFlavour_c
return bHasTimeout; /// means 'infinite' 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. /// one event cycle.
/// \return false to stop event loop and exit. /// \return false to stop event loop and exit.
bool EventTick () REQUIRES ( LazyThread ) bool EventTick () REQUIRES ( LazyThread )
Expand All @@ -3558,6 +3576,7 @@ class LazyNetEvents_c : ISphNoncopyable, protected NetEventsFlavour_c


if ( g_bShutdown ) if ( g_bShutdown )
{ {
AbortScheduled();
sphInfo ( "EventTick() exit because of shutdown=%d", g_bShutdown ); sphInfo ( "EventTick() exit because of shutdown=%d", g_bShutdown );
return false; return false;
} }
Expand Down
1 change: 1 addition & 0 deletions src/searchdha.h
Expand Up @@ -495,6 +495,7 @@ struct AgentConn_t : public ISphRefcountedMT
void RecvCallback ( int64_t iWaited, DWORD uReceived ); void RecvCallback ( int64_t iWaited, DWORD uReceived );
void SoftTimeoutCallback(); void SoftTimeoutCallback();
void HardTimeoutCallback(); void HardTimeoutCallback();
void AbortCallback();


#if USE_WINDOWS #if USE_WINDOWS
// move recv buffer to dOut, reinit mine. // move recv buffer to dOut, reinit mine.
Expand Down

0 comments on commit 39c740f

Please sign in to comment.