Skip to content

Commit

Permalink
Fix #385 leak of preread thread (keep valgrind silent on exit)
Browse files Browse the repository at this point in the history
  • Loading branch information
klirichek committed Aug 14, 2018
1 parent c74d0b4 commit 6e5b57e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/searchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23237,6 +23237,12 @@ void OpenDaemonLog ( const CSphConfigSection & hSearchd, bool bCloseIfOpened=fal
g_bLogTty = isatty ( g_iLogFile )!=0;
}

SphThread_t g_thPreread;
void JoinPrereadThread ()
{
sphThreadJoin ( &g_thPreread );
}

int WINAPI ServiceMain ( int argc, char **argv ) REQUIRES (!MainThread)
{
ScopedRole_c thMain (MainThread);
Expand Down Expand Up @@ -24018,9 +24024,10 @@ int WINAPI ServiceMain ( int argc, char **argv ) REQUIRES (!MainThread)
PrereadFunc ( NULL );
} else
{
SphThread_t tTmpPreread;
if ( !sphThreadCreate ( &tTmpPreread, PrereadFunc, 0, true ) )
if ( !sphThreadCreate ( &g_thPreread, PrereadFunc, 0, true ) )
sphWarning ( "failed to create preread thread" );
else
atexit( &JoinPrereadThread );
}

// almost ready, time to start listening
Expand Down

0 comments on commit 6e5b57e

Please sign in to comment.