From ad0f7f7afa7d28cb285bfdb8c01d95ccfe03996b Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Sun, 29 Jul 2007 16:33:31 +0000 Subject: fixed a problem with shutting down the worker thread and freeing the selector_t list - this caused messages to be lost, because the message queue was not properly drained before the selectors got destroyed. --- ChangeLog | 4 ++++ syslogd.c | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e57ac5f8..ffb69cc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ Version 1.17.5 (rgerhards), 2007-07-2? - continued to work on modularization - fixed a missing file bug - thanks to Andrea Montanari for reporting this problem +- fixed a problem with shutting down the worker thread and freeing the + selector_t list - this caused messages to be lost, because the + message queue was not properly drained before the selectors got + destroyed. --------------------------------------------------------------------------- Version 1.17.4 (rgerhards), 2007-07-27 - continued to work on modularization diff --git a/syslogd.c b/syslogd.c index 4f8b0411..681f7383 100644 --- a/syslogd.c +++ b/syslogd.c @@ -3308,9 +3308,9 @@ static void die(int sig) freeSelectors(); #ifdef USE_PTHREADS - stopWorker(); + /* Worker threads are stopped by freeSelectors() */ queueDelete(pMsgQueue); /* delete fifo here! */ - pMsgQueue = 0; + pMsgQueue = NULL; #endif /* now clean up the listener part */ @@ -3899,13 +3899,24 @@ static void freeSelectors(void) if(Files != NULL) { dprintf("Freeing log structures.\n"); + /* we need first to flush, then wait for all messages to be processed + * (stopWoker() does that), then we can free the structures. + */ f = Files; while (f != NULL) { /* flush any pending output */ if(f->f_prevcount) { fprintlog(f); } + f = f->f_next; + } + +# ifdef USE_PTHREADS + stopWorker(); +# endif + f = Files; + while (f != NULL) { /* free the action instances */ f->pMod->freeInstance(f->pModData); @@ -5228,9 +5239,7 @@ static void mainloop(void) } if(restart) { dprintf("\nReceived SIGHUP, reloading rsyslogd.\n"); -# ifdef USE_PTHREADS - stopWorker(); -# endif + /* worker thread is stopped as part of init() */ init(); # ifdef USE_PTHREADS startWorker(); -- cgit v1.2.3