Small threading update.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent f35d9f0437
commit 7c5f95db01

@ -24,6 +24,9 @@ Tmq* TmqCreateQueue(char *name) {
if (tmq_id >= TMQ_MAX_QUEUES)
goto error;
#ifdef DEBUG
printf("TmqCreateQueue: created queue \'%s\'...\n", name);
#endif
Tmq *q = &tmqs[tmq_id];
q->name = name;
q->id = tmq_id++;
@ -66,19 +69,25 @@ void TmqResetQueues(void) {
void TmValidateQueueState(void)
{
int i = 0;
char err = FALSE;
for (i = 0; i < tmq_id; i++) {
mutex_lock(&trans_q[tmqs[i].id].mutex_q);
if (tmqs[i].reader_cnt == 0) {
printf("Error: Queue \"%s\" doesn't have a reader\n", tmqs[i].name);
goto error;
err = TRUE;
} else if (tmqs[i].writer_cnt == 0) {
printf("Error: Queue \"%s\" doesn't have a writer\n", tmqs[i].name);
goto error;
err = TRUE;
}
mutex_unlock(&trans_q[tmqs[i].id].mutex_q);
if (err == TRUE)
goto error;
}
return;
error:
error:
exit(EXIT_FAILURE);
}

@ -576,7 +576,7 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
tv->aof = THV_RESTART_THREAD;
/* set the incoming queue */
if (inq_name != NULL) {
if (inq_name != NULL && strcmp(inq_name,"packetpool") != 0) {
tmq = TmqGetQueueByName(inq_name);
if (tmq == NULL) {
tmq = TmqCreateQueue(inq_name);
@ -603,9 +603,10 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
tv->tmqh_out = tmqh->OutHandler;
//printf("TmThreadCreate: tv->tmqh_out %p\n", tv->tmqh_out);
if (outq_name != NULL) {
if (outq_name != NULL && strcmp(outq_name,"packetpool") != 0) {
if (tmqh->OutHandlerCtxSetup != NULL) {
tv->outctx = tmqh->OutHandlerCtxSetup(outq_name);
tv->outq = NULL;
} else {
tmq = TmqGetQueueByName(outq_name);
if (tmq == NULL) {
@ -614,6 +615,7 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
}
tv->outq = tmq;
tv->outctx = NULL;
tv->outq->writer_cnt++;
}
//printf("TmThreadCreate: tv->outq->id %" PRIu32 "\n", tv->outq->id);

Loading…
Cancel
Save