Skip to content

Commit 0807240

Browse files
committed
fixed #129 crash of daemon on shutdown
1 parent 7fd3d25 commit 0807240

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/searchd.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ static CSphVector<SphThread_t> g_dTickPoolThread;
397397
/// flush parameters of rt indexes
398398
static SphThread_t g_tRtFlushThread;
399399
static SphThread_t g_tBinlogFlushThread;
400+
static BinlogFlushInfo_t g_tBinlogAutoflush;
400401

401402
// optimize thread
402403
static SphThread_t g_tOptimizeThread;
@@ -1497,7 +1498,8 @@ void Shutdown ()
14971498

14981499
// tell flush-rt thread to shutdown, and wait until it does
14991500
sphThreadJoin ( &g_tRtFlushThread );
1500-
sphThreadJoin ( &g_tBinlogFlushThread );
1501+
if ( g_tBinlogAutoflush.m_fnWork )
1502+
sphThreadJoin ( &g_tBinlogFlushThread );
15011503

15021504
// tell rotation thread to shutdown, and wait until it does
15031505
if ( g_bSeamlessRotate )
@@ -9543,8 +9545,8 @@ struct SqlParser_c : ISphNoncopyable
95439545
#ifdef CMAKE_GENERATED_LEXER
95449546

95459547
#ifdef __GNUC__
9546-
#pragma GCC diagnostic push
9547-
#pragma GCC diagnostic ignored "-Wsign-compare"
9548+
#pragma GCC diagnostic push
9549+
#pragma GCC diagnostic ignored "-Wsign-compare"
95489550
#endif
95499551

95509552
#include "flexsphinxql.c"
@@ -18275,7 +18277,6 @@ static void RtFlushThreadFunc ( void * )
1827518277
}
1827618278
}
1827718279

18278-
static BinlogFlushInfo_t g_tBinlogAutoflush;
1827918280
static void RtBinlogAutoflushThreadFunc ( void * )
1828018281
{
1828118282
assert ( g_tBinlogAutoflush.m_pLog && g_tBinlogAutoflush.m_fnWork );
@@ -23947,7 +23948,10 @@ int WINAPI ServiceMain ( int argc, char **argv )
2394723948
::unlink ( sNewState.cstr() );
2394823949

2394923950
if ( !bCanWrite )
23951+
{
2395023952
sphWarning ( "sphinxql_state flush disabled: %s", sError.cstr() );
23953+
g_sSphinxqlState = ""; // need to disable thread join on shutdown
23954+
}
2395123955
else if ( !sphThreadCreate ( &g_tSphinxqlStateFlushThread, SphinxqlStateThreadFunc, NULL ) )
2395223956
sphDie ( "failed to create sphinxql_state writer thread" );
2395323957
}

0 commit comments

Comments
 (0)