threads: merge unpause test into wait for pause function

TmThreadTestThreadUnPaused was only being used by
TmThreadsWaitForUnpause and is still enough to just become one
function.
pull/11948/head
Jason Ish 5 months ago committed by Victor Julien
parent 3f8c3698db
commit 7492fb6a91

@ -358,11 +358,21 @@ error:
return NULL; return NULL;
} }
/**
* Also returns if the kill flag is set.
*/
void TmThreadsWaitForUnpause(ThreadVars *tv) void TmThreadsWaitForUnpause(ThreadVars *tv)
{ {
if (TmThreadsCheckFlag(tv, THV_PAUSE)) { if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
TmThreadsSetFlag(tv, THV_PAUSED); TmThreadsSetFlag(tv, THV_PAUSED);
TmThreadTestThreadUnPaused(tv);
while (TmThreadsCheckFlag(tv, THV_PAUSE)) {
SleepUsec(100);
if (TmThreadsCheckFlag(tv, THV_KILL))
break;
}
TmThreadsUnsetFlag(tv, THV_PAUSED); TmThreadsUnsetFlag(tv, THV_PAUSED);
} }
} }
@ -1737,24 +1747,6 @@ static void TmThreadDeinitMC(ThreadVars *tv)
} }
} }
/**
* \brief Tests if the thread represented in the arg has been unpaused or not.
*
* The function would return if the thread tv has been unpaused or if the
* kill flag for the thread has been set.
*
* \param tv Pointer to the TV instance.
*/
void TmThreadTestThreadUnPaused(ThreadVars *tv)
{
while (TmThreadsCheckFlag(tv, THV_PAUSE)) {
SleepUsec(100);
if (TmThreadsCheckFlag(tv, THV_KILL))
break;
}
}
/** /**
* \brief Waits till the specified flag(s) is(are) set. We don't bother if * \brief Waits till the specified flag(s) is(are) set. We don't bother if
* the kill flag has been set or not on the thread. * the kill flag has been set or not on the thread.

@ -108,7 +108,6 @@ void TmThreadSetPrio(ThreadVars *);
int TmThreadGetNbThreads(uint8_t type); int TmThreadGetNbThreads(uint8_t type);
void TmThreadInitMC(ThreadVars *); void TmThreadInitMC(ThreadVars *);
void TmThreadTestThreadUnPaused(ThreadVars *);
void TmThreadContinue(ThreadVars *); void TmThreadContinue(ThreadVars *);
void TmThreadContinueThreads(void); void TmThreadContinueThreads(void);
void TmThreadCheckThreadState(void); void TmThreadCheckThreadState(void);
@ -288,7 +287,11 @@ void TmThreadsGetMinimalTimestamp(struct timeval *ts);
uint16_t TmThreadsGetWorkerThreadMax(void); uint16_t TmThreadsGetWorkerThreadMax(void);
bool TmThreadsTimeSubsysIsReady(void); bool TmThreadsTimeSubsysIsReady(void);
/** \brief Wait for a thread to become unpaused. */ /** \brief Wait for a thread to become unpaused.
*
* Check if a thread should wait to be unpaused and wait if so, or
* until the thread kill flag is set.
*/
void TmThreadsWaitForUnpause(ThreadVars *tv); void TmThreadsWaitForUnpause(ThreadVars *tv);
#endif /* SURICATA_TM_THREADS_H */ #endif /* SURICATA_TM_THREADS_H */

Loading…
Cancel
Save