|
|
|
|
@ -92,6 +92,7 @@ void *TmThreadsSlot1NoIn(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadInit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadInit(tv, s->s.slot_initdata, &s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoIn: init r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
EngineKill();
|
|
|
|
|
|
|
|
|
|
@ -107,7 +108,7 @@ void *TmThreadsSlot1NoIn(void *td) {
|
|
|
|
|
TmThreadTestThreadUnPaused(tv);
|
|
|
|
|
|
|
|
|
|
r = s->s.SlotFunc(tv, p, s->s.slot_data, &s->s.slot_pq);
|
|
|
|
|
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoIn: func r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
/* handle error */
|
|
|
|
|
if (r == TM_ECODE_FAILED) {
|
|
|
|
|
TmqhReleasePacketsToPacketPool(&s->s.slot_pq);
|
|
|
|
|
@ -135,6 +136,7 @@ void *TmThreadsSlot1NoIn(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadDeinit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadDeinit(tv, s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoIn: deinit r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
TmThreadsSetFlag(tv, THV_CLOSED);
|
|
|
|
|
pthread_exit((void *) -1);
|
|
|
|
|
@ -157,6 +159,7 @@ void *TmThreadsSlot1NoOut(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadInit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadInit(tv, s->s.slot_initdata, &s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoOut: init r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
EngineKill();
|
|
|
|
|
|
|
|
|
|
@ -174,7 +177,7 @@ void *TmThreadsSlot1NoOut(void *td) {
|
|
|
|
|
p = tv->tmqh_in(tv);
|
|
|
|
|
|
|
|
|
|
r = s->s.SlotFunc(tv, p, s->s.slot_data, /* no outqh no pq */NULL);
|
|
|
|
|
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoOut: func r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
/* handle error */
|
|
|
|
|
if (r == TM_ECODE_FAILED) {
|
|
|
|
|
TmqhOutputPacketpool(tv, p);
|
|
|
|
|
@ -194,6 +197,7 @@ void *TmThreadsSlot1NoOut(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadDeinit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadDeinit(tv, s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoOut: r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
TmThreadsSetFlag(tv, THV_CLOSED);
|
|
|
|
|
pthread_exit((void *) -1);
|
|
|
|
|
@ -217,6 +221,7 @@ void *TmThreadsSlot1NoInOut(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadInit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadInit(tv, s->s.slot_initdata, &s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoInOut: init r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
EngineKill();
|
|
|
|
|
|
|
|
|
|
@ -231,6 +236,7 @@ void *TmThreadsSlot1NoInOut(void *td) {
|
|
|
|
|
TmThreadTestThreadUnPaused(tv);
|
|
|
|
|
|
|
|
|
|
r = s->s.SlotFunc(tv, NULL, s->s.slot_data, /* no outqh, no pq */NULL);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoInOut: func r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoInNoOut: r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
|
|
|
|
|
/* handle error */
|
|
|
|
|
@ -252,6 +258,7 @@ void *TmThreadsSlot1NoInOut(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadDeinit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadDeinit(tv, s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1NoInOut: deinit r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
TmThreadsSetFlag(tv, THV_CLOSED);
|
|
|
|
|
pthread_exit((void *) -1);
|
|
|
|
|
@ -277,6 +284,7 @@ void *TmThreadsSlot1(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadInit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadInit(tv, s->s.slot_initdata, &s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1: init r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
EngineKill();
|
|
|
|
|
|
|
|
|
|
@ -297,7 +305,7 @@ void *TmThreadsSlot1(void *td) {
|
|
|
|
|
//printf("%s: TmThreadsSlot1: p == NULL\n", tv->name);
|
|
|
|
|
} else {
|
|
|
|
|
r = s->s.SlotFunc(tv, p, s->s.slot_data, &s->s.slot_pq);
|
|
|
|
|
|
|
|
|
|
printf("%s: TmThreadsSlot1: func r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
/* handle error */
|
|
|
|
|
if (r == TM_ECODE_FAILED) {
|
|
|
|
|
TmqhReleasePacketsToPacketPool(&s->s.slot_pq);
|
|
|
|
|
@ -331,6 +339,7 @@ void *TmThreadsSlot1(void *td) {
|
|
|
|
|
|
|
|
|
|
if (s->s.SlotThreadDeinit != NULL) {
|
|
|
|
|
r = s->s.SlotThreadDeinit(tv, s->s.slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlot1: deinit r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
TmThreadsSetFlag(tv, THV_CLOSED);
|
|
|
|
|
pthread_exit((void *) -1);
|
|
|
|
|
@ -349,6 +358,7 @@ static inline TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *sl
|
|
|
|
|
|
|
|
|
|
for (s = slot; s != NULL; s = s->slot_next) {
|
|
|
|
|
r = s->SlotFunc(tv, p, s->slot_data, &s->slot_pq);
|
|
|
|
|
//printf("TmThreadsSlotVarRun: s->SlotFunc %p returned r %" PRId32 "\n", s->SlotFunc, r);
|
|
|
|
|
/* handle error */
|
|
|
|
|
if (r == TM_ECODE_FAILED) {
|
|
|
|
|
//printf("TmThreadsSlotVarRun: s->SlotFunc %p returned 1\n", s->SlotFunc);
|
|
|
|
|
@ -365,6 +375,7 @@ static inline TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *sl
|
|
|
|
|
/* see if we need to process the packet */
|
|
|
|
|
if (s->slot_next != NULL) {
|
|
|
|
|
r = TmThreadsSlotVarRun(tv, extra_p, s->slot_next);
|
|
|
|
|
//printf("%s: TmThreadsSlotvarrun: run r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
/* XXX handle error */
|
|
|
|
|
if (r == TM_ECODE_FAILED) {
|
|
|
|
|
//printf("TmThreadsSlotVarRun: recursive TmThreadsSlotVarRun returned 1\n");
|
|
|
|
|
@ -397,6 +408,7 @@ void *TmThreadsSlotVar(void *td) {
|
|
|
|
|
for (slot = s->s; slot != NULL; slot = slot->slot_next) {
|
|
|
|
|
if (slot->SlotThreadInit != NULL) {
|
|
|
|
|
r = slot->SlotThreadInit(tv, slot->slot_initdata, &slot->slot_data);
|
|
|
|
|
//printf("%s: TmThreadsSlotvar: init r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
if (r != TM_ECODE_OK) {
|
|
|
|
|
EngineKill();
|
|
|
|
|
|
|
|
|
|
@ -420,6 +432,7 @@ void *TmThreadsSlotVar(void *td) {
|
|
|
|
|
//printf("%s: TmThreadsSlot1: p == NULL\n", tv->name);
|
|
|
|
|
} else {
|
|
|
|
|
r = TmThreadsSlotVarRun(tv, p, s->s);
|
|
|
|
|
//printf("%s: TmThreadsSlotvar: var run r %" PRId32 "\n", tv->name, r);
|
|
|
|
|
/* XXX handle error */
|
|
|
|
|
if (r == TM_ECODE_FAILED) {
|
|
|
|
|
//printf("TmThreadsSlotVar: TmThreadsSlotVarRun returned 1, breaking out of the loop.\n");
|
|
|
|
|
@ -598,7 +611,7 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
|
|
|
|
|
Tmq *tmq = NULL;
|
|
|
|
|
Tmqh *tmqh = NULL;
|
|
|
|
|
|
|
|
|
|
SCLogDebug("creating thread \"%s\"...", name);
|
|
|
|
|
printf("creating thread \"%s\"...\n", name);
|
|
|
|
|
|
|
|
|
|
/* XXX create separate function for this: allocate a thread container */
|
|
|
|
|
tv = malloc(sizeof(ThreadVars));
|
|
|
|
|
@ -776,7 +789,7 @@ void TmThreadKillThreads(void) {
|
|
|
|
|
|
|
|
|
|
while (tv) {
|
|
|
|
|
TmThreadsSetFlag(tv, THV_KILL);
|
|
|
|
|
SCLogDebug("told thread %s to stop", tv->name);
|
|
|
|
|
printf("told thread %s to stop\n", tv->name);
|
|
|
|
|
|
|
|
|
|
/* XXX hack */
|
|
|
|
|
StreamMsgSignalQueueHack();
|
|
|
|
|
@ -798,7 +811,7 @@ void TmThreadKillThreads(void) {
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
while (1) {
|
|
|
|
|
if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
|
|
|
|
|
SCLogDebug("signalled the thread %" PRId32 " times", cnt);
|
|
|
|
|
printf("signalled the thread %" PRId32 " times\n", cnt);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -810,14 +823,14 @@ void TmThreadKillThreads(void) {
|
|
|
|
|
usleep(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SCLogDebug("signalled tv->inq->id %" PRIu32 "", tv->inq->id);
|
|
|
|
|
printf("signalled tv->inq->id %" PRIu32 "\n", tv->inq->id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tv->cond != NULL ) {
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
while (1) {
|
|
|
|
|
if (TmThreadsCheckFlag(tv, THV_CLOSED)) {
|
|
|
|
|
SCLogDebug("signalled the thread %" PRId32 " times", cnt);
|
|
|
|
|
printf("signalled the thread %" PRId32 " times\n", cnt);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -831,7 +844,7 @@ void TmThreadKillThreads(void) {
|
|
|
|
|
|
|
|
|
|
/* join it */
|
|
|
|
|
pthread_join(tv->t, NULL);
|
|
|
|
|
SCLogDebug("thread %s stopped", tv->name);
|
|
|
|
|
printf("thread %s stopped\n", tv->name);
|
|
|
|
|
|
|
|
|
|
tv = tv->next;
|
|
|
|
|
}
|
|
|
|
|
@ -1012,7 +1025,7 @@ static void TmThreadRestartThread(ThreadVars *tv)
|
|
|
|
|
{
|
|
|
|
|
if (tv->restarted >= THV_MAX_RESTARTS) {
|
|
|
|
|
printf("Warning: thread restarts exceeded threshhold limit for thread"
|
|
|
|
|
"\"%s\"", tv->name);
|
|
|
|
|
"\"%s\"\n", tv->name);
|
|
|
|
|
/* makes sense to reset the tv_aof to engine_exit?! */
|
|
|
|
|
// tv->aof = THV_ENGINE_EXIT;
|
|
|
|
|
return;
|
|
|
|
|
@ -1027,7 +1040,7 @@ static void TmThreadRestartThread(ThreadVars *tv)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tv->restarted++;
|
|
|
|
|
SCLogInfo("thread \"%s\" restarted", tv->name);
|
|
|
|
|
printf("thread \"%s\" restarted\n", tv->name);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|