Fixed a few missing places for tv->flags access. Changed mutex init for packets slightly.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 968dc45d27
commit b6deadd2b4

@ -137,14 +137,12 @@ void * PerfMgmtThread(void *arg)
uint8_t run = 1;
struct timespec cond_time;
printf("PerfMgmtThread: spawned\n");
if (perf_op_ctx == NULL) {
printf("error: PerfInitCounterApi() has to be called first\n");
return NULL;
}
tv_local->flags |= THV_INIT_DONE;
TmThreadsSetFlag(tv_local, THV_INIT_DONE);
while (run) {
TmThreadTestThreadUnPaused(tv_local);
@ -155,12 +153,10 @@ void * PerfMgmtThread(void *arg)
pthread_cond_timedwait(tv_local->cond, tv_local->m, &cond_time);
pthread_mutex_unlock(tv_local->m);
// sleep(MGMTT_TTS);
PerfOutputCounters();
if (tv_local->flags & THV_KILL) {
tv_local->flags |= THV_CLOSED;
if (TmThreadsCheckFlag(tv_local, THV_KILL)) {
TmThreadsSetFlag(tv_local, THV_CLOSED);
run = 0;
}
}
@ -182,9 +178,7 @@ void * PerfWakeupThread(void *arg)
PacketQueue *q = NULL;
struct timespec cond_time;
printf("PerfWakeupThread: spawned\n");
tv_local->flags |= THV_INIT_DONE;
TmThreadsSetFlag(tv_local, THV_INIT_DONE);
while (run) {
TmThreadTestThreadUnPaused(tv_local);
@ -215,8 +209,8 @@ void * PerfWakeupThread(void *arg)
tv = tv->next;
}
if (tv_local->flags & THV_KILL) {
tv_local->flags |= THV_CLOSED;
if (TmThreadsCheckFlag(tv_local, THV_KILL)) {
TmThreadsSetFlag(tv_local, THV_CLOSED);
run = 0;
}
}

@ -342,7 +342,6 @@ typedef struct DecodeThreadVars_
(p)->pktlen = 0; \
(p)->tunnel_pkt = 0; \
(p)->tunnel_verdicted = 0; \
pthread_mutex_init(&(p)->mutex_rtv_cnt,NULL); \
(p)->rtv_cnt = 0; \
(p)->tpr_cnt = 0; \
(p)->root = NULL; \

@ -156,6 +156,8 @@ Packet *SetupPkt (void)
memset(p, 0, sizeof(Packet));
pthread_mutex_init(&p->mutex_rtv_cnt, NULL);
printf("SetupPkt: allocated a new packet...\n");
}
@ -1576,6 +1578,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(Packet));
pthread_mutex_init(&p->mutex_rtv_cnt, NULL);
PacketEnqueue(&packet_q,p);
}

@ -495,7 +495,7 @@ void *FlowManagerThread(void *td)
printf("%s started...\n", th_v->name);
th_v->flags |= THV_INIT_DONE;
TmThreadsSetFlag(th_v, THV_INIT_DONE);
while (1)
{
TmThreadTestThreadUnPaused(th_v);
@ -553,7 +553,7 @@ void *FlowManagerThread(void *td)
}
}
if (th_v->flags & THV_KILL) {
if (TmThreadsCheckFlag(th_v, THV_KILL)) {
PerfUpdateCounterArray(th_v->pca, &th_v->pctx, 0);
break;
}

@ -613,7 +613,8 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
tv->name = name;
/* default state for every newly created thread */
TmThreadsSetFlag(tv, THV_USE | THV_PAUSE);
TmThreadsSetFlag(tv, THV_PAUSE);
TmThreadsSetFlag(tv, THV_USE);
/* default aof for every newly created thread */
tv->aof = THV_RESTART_THREAD;
@ -1028,8 +1029,8 @@ static void TmThreadRestartThread(ThreadVars *tv)
return;
}
/** \todo consider a TmThreadUnsetFlag func? */
TmThreadsUnsetFlag(tv, THV_CLOSED | THV_FAILED);
TmThreadsUnsetFlag(tv, THV_CLOSED);
TmThreadsUnsetFlag(tv, THV_FAILED);
if (TmThreadSpawn(tv) != 0) {
printf("Error: TmThreadSpawn failed\n");

Loading…
Cancel
Save