ThreadVars *tv = NULL;
+again:
SCMutexLock(&tv_root_lock);
/* all receive threads are part of packet processing threads */
if (!(strlen(tv->inq->name) == strlen("packetpool") &&
strcasecmp(tv->inq->name, "packetpool") == 0)) {
PacketQueue *q = &trans_q[tv->inq->id];
- while (q->len != 0) {
+ if (q->len != 0) {
+ SCMutexUnlock(&tv_root_lock);
+ /* don't sleep while holding a lock */
usleep(1000);
+ goto again;
}
}
}
ThreadVars *tv = NULL;
+again:
SCMutexLock(&tv_root_lock);
/* all receive threads are part of packet processing threads */
if (!(strlen(tv->inq->name) == strlen("packetpool") &&
strcasecmp(tv->inq->name, "packetpool") == 0)) {
PacketQueue *q = &trans_q[tv->inq->id];
- while (q->len != 0) {
+ if (q->len != 0) {
+ SCMutexUnlock(&tv_root_lock);
+ /* don't sleep while holding a lock */
usleep(1000);
+ goto again;
}
}
}
if ((family < 0) || (family >= TVT_MAX))
return;
+ SCMutexLock(&tv_root_lock);
tv = tv_root[family];
while (tv) {
TmThreadFree(ptv);
}
tv_root[family] = NULL;
+ SCMutexUnlock(&tv_root_lock);
}
/**
ThreadVars *tv = NULL;
int i = 0;
+ SCMutexLock(&tv_root_lock);
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
while (tv != NULL) {
tv = tv->next;
}
}
+ SCMutexUnlock(&tv_root_lock);
return;
}
TmThreadsListThreads();
+ SCMutexLock(&tv_root_lock);
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
while (tv != NULL) {
tv = tv->next;
}
}
+ SCMutexUnlock(&tv_root_lock);
return;
}
ThreadVars *tv = NULL;
int i = 0;
+ SCMutexLock(&tv_root_lock);
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
pthread_join(tv->t, NULL);
if ((tv_aof & THV_ENGINE_EXIT) || (tv->aof & THV_ENGINE_EXIT)) {
EngineKill();
- return;
+ goto end;
} else {
/* if the engine kill-stop has been received by now, chuck
* restarting and return to kill the engine */
if ((suricata_ctl_flags & SURICATA_KILL) ||
(suricata_ctl_flags & SURICATA_STOP)) {
- return;
+ goto end;
}
TmThreadRestartThread(tv);
}
tv = tv->next;
}
}
-
+end:
+ SCMutexUnlock(&tv_root_lock);
return;
}
uint16_t mgt_num = 0;
uint16_t ppt_num = 0;
+ SCMutexLock(&tv_root_lock);
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
while (tv != NULL) {
}
if (TmThreadsCheckFlag(tv, THV_FAILED)) {
+ SCMutexUnlock(&tv_root_lock);
SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
"initialize.", tv->name);
return TM_ECODE_FAILED;
}
if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
+ SCMutexUnlock(&tv_root_lock);
SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" closed on "
"initialization.", tv->name);
return TM_ECODE_FAILED;
tv = tv->next;
}
}
+ SCMutexUnlock(&tv_root_lock);
SCLogNotice("all %"PRIu16" packet processing threads, %"PRIu16" management "
"threads initialized, engine started.", ppt_num, mgt_num);