@ -1797,27 +1797,17 @@ void TmThreadContinue(ThreadVars *tv)
return ;
return ;
}
}
/**
static TmEcode WaitOnThreadsRunningByType ( const int t )
* \ brief Waits for all threads to be in a running state
*
* \ retval TM_ECODE_OK if all are running or error if a thread failed
*/
TmEcode TmThreadWaitOnThreadRunning ( void )
{
{
uint16_t RX_num = 0 ;
uint16_t W_num = 0 ;
uint16_t FM_num = 0 ;
uint16_t FR_num = 0 ;
uint16_t TX_num = 0 ;
struct timeval start_ts ;
struct timeval start_ts ;
struct timeval cur_ts ;
struct timeval cur_ts ;
gettimeofday ( & start_ts , NULL ) ;
gettimeofday ( & start_ts , NULL ) ;
/* on retries, this will init to the last thread that started up already */
ThreadVars * tv_start = tv_root [ t ] ;
again :
again :
SCMutexLock ( & tv_root_lock ) ;
SCMutexLock ( & tv_root_lock ) ;
for ( int i = 0 ; i < TVT_MAX ; i + + ) {
ThreadVars * tv = tv_start ;
ThreadVars * tv = tv_root [ i ] ;
while ( tv ! = NULL ) {
while ( tv ! = NULL ) {
if ( TmThreadsCheckFlag ( tv , ( THV_FAILED | THV_CLOSED | THV_DEAD ) ) ) {
if ( TmThreadsCheckFlag ( tv , ( THV_FAILED | THV_CLOSED | THV_DEAD ) ) ) {
SCMutexUnlock ( & tv_root_lock ) ;
SCMutexUnlock ( & tv_root_lock ) ;
@ -1846,9 +1836,33 @@ again:
SleepUsec ( 100 ) ;
SleepUsec ( 100 ) ;
goto again ;
goto again ;
}
}
tv_start = tv ;
tv = tv - > next ;
tv = tv - > next ;
}
}
SCMutexUnlock ( & tv_root_lock ) ;
return TM_ECODE_OK ;
}
/**
* \ brief Waits for all threads to be in a running state
*
* \ retval TM_ECODE_OK if all are running or error if a thread failed
*/
TmEcode TmThreadWaitOnThreadRunning ( void )
{
uint16_t RX_num = 0 ;
uint16_t W_num = 0 ;
uint16_t FM_num = 0 ;
uint16_t FR_num = 0 ;
uint16_t TX_num = 0 ;
for ( int i = 0 ; i < TVT_MAX ; i + + ) {
if ( WaitOnThreadsRunningByType ( i ) ! = TM_ECODE_OK )
return TM_ECODE_FAILED ;
}
}
SCMutexLock ( & tv_root_lock ) ;
for ( int i = 0 ; i < TVT_MAX ; i + + ) {
for ( int i = 0 ; i < TVT_MAX ; i + + ) {
for ( ThreadVars * tv = tv_root [ i ] ; tv ! = NULL ; tv = tv - > next ) {
for ( ThreadVars * tv = tv_root [ i ] ; tv ! = NULL ; tv = tv - > next ) {
if ( strncmp ( thread_name_autofp , tv - > name , strlen ( thread_name_autofp ) ) = = 0 )
if ( strncmp ( thread_name_autofp , tv - > name , strlen ( thread_name_autofp ) ) = = 0 )