Fix detection of failed thread startup. Cleanup startup output a bit.

remotes/origin/master-1.0.x
Victor Julien 17 years ago
parent ab09e80205
commit 597d0e9a20

@ -387,7 +387,9 @@ void AppLayerDetectProtoThreadSpawn()
exit(1); exit(1);
} }
#ifdef DEBUG
printf("AppLayerDetectProtoThread thread created\n"); printf("AppLayerDetectProtoThread thread created\n");
#endif
return; return;
} }

@ -469,8 +469,11 @@ int main(int argc, char **argv)
/* Check if the alloted queues have at least 1 reader and writer */ /* Check if the alloted queues have at least 1 reader and writer */
TmValidateQueueState(); TmValidateQueueState();
/* Waits till all the threads have been initialized */ /* Wait till all the threads have been initialized */
TmThreadWaitOnThreadInit(); if (TmThreadWaitOnThreadInit() == -1) {
printf("ERROR: Engine initialization failed, aborting...\n");
exit(EXIT_FAILURE);
}
/* Un-pause all the paused threads */ /* Un-pause all the paused threads */
TmThreadContinueThreads(); TmThreadContinueThreads();

@ -493,7 +493,9 @@ void *FlowManagerThread(void *td)
uint32_t sleeping = 0; uint32_t sleeping = 0;
uint8_t emerg = FALSE; uint8_t emerg = FALSE;
#ifdef DEBUG
printf("%s started...\n", th_v->name); printf("%s started...\n", th_v->name);
#endif
TmThreadsSetFlag(th_v, THV_INIT_DONE); TmThreadsSetFlag(th_v, THV_INIT_DONE);
while (1) while (1)

@ -178,8 +178,8 @@ void StreamTcpSessionPoolFree(void *s) {
void StreamTcpInitConfig(char quiet) { void StreamTcpInitConfig(char quiet) {
if (quiet == FALSE) //if (quiet == FALSE)
printf("Initializing Stream:\n"); // printf("Initializing Stream:\n");
memset(&stream_config, 0, sizeof(stream_config)); memset(&stream_config, 0, sizeof(stream_config));

@ -597,7 +597,9 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
Tmq *tmq = NULL; Tmq *tmq = NULL;
Tmqh *tmqh = NULL; Tmqh *tmqh = NULL;
#ifdef DEBUG
printf("TmThreadCreate: creating thread \"%s\"...\n", name); printf("TmThreadCreate: creating thread \"%s\"...\n", name);
#endif
/* XXX create separate function for this: allocate a thread container */ /* XXX create separate function for this: allocate a thread container */
tv = malloc(sizeof(ThreadVars)); tv = malloc(sizeof(ThreadVars));
@ -1074,20 +1076,41 @@ void TmThreadCheckThreadState(void)
/** \brief Used to check if all threads have finished their initialization. On /** \brief Used to check if all threads have finished their initialization. On
* finding an un-initialized thread, it waits till that thread completes * finding an un-initialized thread, it waits till that thread completes
* its initialization, before proceeding to the next thread. * its initialization, before proceeding to the next thread.
* \retval 0 all initialized properly
* \retval -1 failure
*/ */
void TmThreadWaitOnThreadInit(void) int TmThreadWaitOnThreadInit(void)
{ {
ThreadVars *tv = NULL; ThreadVars *tv = NULL;
int i = 0; int i = 0;
uint16_t mgt_num = 0;
uint16_t ppt_num = 0;
for (i = 0; i < TVT_MAX; i++) { for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i]; tv = tv_root[i];
while (tv != NULL) { while (tv != NULL) {
while (!(TmThreadsCheckFlag(tv, THV_INIT_DONE))) char started = FALSE;
; while (started == FALSE) {
if (TmThreadsCheckFlag(tv, THV_INIT_DONE)) {
started = TRUE;
}
if (TmThreadsCheckFlag(tv, THV_CLOSED) ||
TmThreadsCheckFlag(tv, THV_FAILED))
{
printf("Thread \"%s\" failed to initialize...\n", tv->name);
return -1;
}
}
if (i == TVT_MGMT) mgt_num++;
else if (i == TVT_PPT) ppt_num++;
tv = tv->next; tv = tv->next;
} }
} }
return; printf("All %"PRIu16" packet processing threads, %"PRIu16" management "
"threads initialized, engine started.\n", ppt_num, mgt_num);
return 0;
} }

@ -52,7 +52,7 @@ void TmThreadPauseThreads(void);
void TmThreadCheckThreadState(void); void TmThreadCheckThreadState(void);
void TmThreadWaitOnThreadInit(void); int TmThreadWaitOnThreadInit(void);
inline int TmThreadsCheckFlag(ThreadVars *, uint8_t); inline int TmThreadsCheckFlag(ThreadVars *, uint8_t);
inline void TmThreadsSetFlag(ThreadVars *, uint8_t); inline void TmThreadsSetFlag(ThreadVars *, uint8_t);

Loading…
Cancel
Save