Skip to content
Permalink
Browse files

fixed #613 daemon crash on simultaneous API session status commands

  • Loading branch information
tomatolog committed Dec 24, 2018
1 parent cd9e4f1 commit 3f7e35d1482966cc45d5abbcb2de5de3508d66b0
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/searchd.cpp
@@ -476,9 +476,9 @@ enum


/// command names
static const char * g_dApiCommands[SEARCHD_COMMAND_TOTAL] =
static const char * g_dApiCommands[] =
{
"search", "excerpt", "update", "keywords", "persist", "status", "query", "flushattrs", "query", "ping", "delete", "set", "insert", "replace", "commit", "suggest", "json"
"search", "excerpt", "update", "keywords", "persist", "status", "query", "flushattrs", "query", "ping", "delete", "set", "insert", "replace", "commit", "suggest", "json", "callpq"
};

STATIC_ASSERT ( sizeof(g_dApiCommands)/sizeof(g_dApiCommands[0])==SEARCHD_COMMAND_TOTAL, SEARCHD_COMMAND_SHOULD_BE_SAME_AS_SEARCHD_COMMAND_TOTAL );
@@ -11168,12 +11168,15 @@ void BuildMeta ( VectorLike & dStatus, const CSphQueryResultMeta & tMeta )


int iWord = 0;
for ( tMeta.m_hWordStats.IterateStart (); tMeta.m_hWordStats.IterateNext(); )
// multiple readers might iterate word hash here from multiple client queries
// that invalidates internal hash iterator - need external iterator
void * pWordIt = nullptr;
while ( tMeta.m_hWordStats.IterateNext( &pWordIt ) )
{
const CSphQueryResultMeta::WordStat_t & tStat = tMeta.m_hWordStats.IterateGet();
const CSphQueryResultMeta::WordStat_t & tStat = tMeta.m_hWordStats.IterateGet ( &pWordIt );

if ( dStatus.MatchAddVa ( "keyword[%d]", iWord ) )
dStatus.Add ( tMeta.m_hWordStats.IterateGetKey() );
dStatus.Add ( tMeta.m_hWordStats.IterateGetKey ( &pWordIt ) );

if ( dStatus.MatchAddVa ( "docs[%d]", iWord ) )
dStatus.Add().SetSprintf ( INT64_FMT, tStat.m_iDocs );

0 comments on commit 3f7e35d

Please sign in to comment.