threads: add func to count running threads of types

pull/1716/head
Victor Julien 10 years ago
parent ca3916881f
commit 8d06d7bccc

@ -2034,6 +2034,29 @@ ThreadVars *TmThreadsGetCallingThread(void)
return NULL;
}
/**
* \brief returns a count of all the threads that match the flag
*/
uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags)
{
ThreadVars *tv = NULL;
int i = 0;
uint32_t cnt = 0;
SCMutexLock(&tv_root_lock);
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
while (tv != NULL) {
if ((tv->tmm_flags & flags) == flags)
cnt++;
tv = tv->next;
}
}
SCMutexUnlock(&tv_root_lock);
return cnt;
}
typedef struct Thread_ {
ThreadVars *tv; /**< threadvars structure */
const char *name;

@ -132,6 +132,8 @@ void TmThreadDisablePacketThreads(void);
void TmThreadDisableReceiveThreads(void);
TmSlot *TmThreadGetFirstTmSlotForPartialPattern(const char *);
uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags);
/**
* \brief Process the rest of the functions (if any) and queue.
*/

Loading…
Cancel
Save