Kill the engine if one of the threads fails to initialize.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 051f21e797
commit 7c36b315fd

@ -205,8 +205,10 @@ int AlertDebuglogThreadInit(ThreadVars *t, void *initdata, void **data)
memset(aft, 0, sizeof(AlertDebuglogThread));
/* XXX */
aft->fp = fopen("/var/log/eidps/alert-debug.log", "w");
char *path = "/var/log/eidps/alert-debug.log";
aft->fp = fopen(path, "w");
if (aft->fp == NULL) {
printf("ERROR: failed to open %s: %s\n", path, strerror(errno));
return -1;
}

@ -156,8 +156,10 @@ int AlertFastlogThreadInit(ThreadVars *t, void *initdata, void **data)
memset(aft, 0, sizeof(AlertFastlogThread));
/* XXX */
aft->fp = fopen("/var/log/eidps/fast.log", "w");
char *path = "/var/log/eidps/fast.log";
aft->fp = fopen(path, "w");
if (aft->fp == NULL) {
printf("ERROR: failed to open %s: %s\n", path, strerror(errno));
return -1;
}

@ -103,7 +103,7 @@ int AlertUnifiedAlertCreateFile(ThreadVars *t, AlertUnifiedAlertThread *aun) {
/* XXX filename & location */
aun->fp = fopen(filename, "wb");
if (aun->fp == NULL) {
printf("Error: fopen failed: %s\n", strerror(errno)); /* XXX errno threadsafety? */
printf("Error: fopen %s failed: %s\n", filename, strerror(errno)); /* XXX errno threadsafety? */
return -1;
}

@ -105,7 +105,7 @@ int AlertUnifiedLogCreateFile(ThreadVars *t, AlertUnifiedLogThread *aun) {
/* XXX filename & location */
aun->fp = fopen(filename, "wb");
if (aun->fp == NULL) {
printf("Error: fopen failed: %s\n", strerror(errno)); /* XXX errno threadsafety? */
printf("Error: fopen %s failed: %s\n", filename, strerror(errno)); /* XXX errno threadsafety? */
return -1;
}

@ -181,8 +181,10 @@ int LogHttplogThreadInit(ThreadVars *t, void *initdata, void **data)
memset(aft, 0, sizeof(LogHttplogThread));
/* XXX */
aft->fp = fopen("/var/log/eidps/http.log", "w");
char *path = "/var/log/eidps/http.log";
aft->fp = fopen(path, "w");
if (aft->fp == NULL) {
printf("ERROR: failed to open %s: %s\n", path, strerror(errno));
return -1;
}

@ -70,6 +70,8 @@ void *TmThreadsSlot1NoIn(void *td) {
if (s->s.SlotInit != NULL) {
r = s->s.SlotInit(tv, s->s.slot_initdata, &s->s.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -123,6 +125,8 @@ void *TmThreadsSlot1NoOut(void *td) {
if (s->s.SlotInit != NULL) {
r = s->s.SlotInit(tv, s->s.slot_initdata, &s->s.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -172,6 +176,8 @@ void *TmThreadsSlot1NoInOut(void *td) {
if (s->s.SlotInit != NULL) {
r = s->s.SlotInit(tv, s->s.slot_initdata, &s->s.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -224,6 +230,8 @@ void *TmThreadsSlot1(void *td) {
if (s->s.SlotInit != NULL) {
r = s->s.SlotInit(tv, s->s.slot_initdata, &s->s.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -292,6 +300,8 @@ void *TmThreadsSlot2(void *td) {
if (s->s1.SlotInit != NULL) {
r = s->s1.SlotInit(tv, s->s1.slot_initdata, &s->s1.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -299,6 +309,8 @@ void *TmThreadsSlot2(void *td) {
if (s->s2.SlotInit != NULL) {
r = s->s2.SlotInit(tv, s->s2.slot_initdata, &s->s2.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -399,6 +411,8 @@ void *TmThreadsSlot3(void *td) {
if (s->s1.SlotInit != NULL) {
r = s->s1.SlotInit(tv, s->s1.slot_initdata, &s->s1.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -406,6 +420,8 @@ void *TmThreadsSlot3(void *td) {
if (s->s2.SlotInit != NULL) {
r = s->s2.SlotInit(tv, s->s2.slot_initdata, &s->s2.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -413,6 +429,8 @@ void *TmThreadsSlot3(void *td) {
if (s->s3.SlotInit != NULL) {
r = s->s3.SlotInit(tv, s->s3.slot_initdata, &s->s3.slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -590,6 +608,8 @@ void *TmThreadsSlotVar(void *td) {
if (slot->SlotInit != NULL) {
r = slot->SlotInit(tv, slot->slot_initdata, &slot->slot_data);
if (r != 0) {
EngineKill();
tv->flags |= THV_CLOSED;
pthread_exit((void *) -1);
}
@ -910,7 +930,7 @@ void TmThreadKillThreads(void) {
while (t) {
t->flags |= THV_KILL;
printf("TmThreadKillThreads: told thread %s to stop\n", t->name);
//printf("TmThreadKillThreads: told thread %s to stop\n", t->name);
/* XXX hack */
StreamMsgSignalQueueHack();
@ -918,7 +938,7 @@ void TmThreadKillThreads(void) {
if (t->inq != NULL) {
int i;
printf("TmThreadKillThreads: t->inq->usecnt %u\n", t->inq->usecnt);
//printf("TmThreadKillThreads: t->inq->usecnt %u\n", t->inq->usecnt);
/* make sure our packet pending counter doesn't block */
pthread_cond_signal(&cond_pending);
@ -931,7 +951,7 @@ void TmThreadKillThreads(void) {
int cnt = 0;
while (1) {
if (t->flags & THV_CLOSED) {
printf("signalled the thread %d times\n", cnt);
//printf("signalled the thread %d times\n", cnt);
break;
}
@ -943,7 +963,7 @@ void TmThreadKillThreads(void) {
usleep(100);
}
printf("TmThreadKillThreads: signalled t->inq->id %u\n", t->inq->id);
//printf("TmThreadKillThreads: signalled t->inq->id %u\n", t->inq->id);
}
/* join it */

Loading…
Cancel
Save