summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-29 16:33:31 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-29 16:33:31 +0000
commitad0f7f7afa7d28cb285bfdb8c01d95ccfe03996b (patch)
treeeccf878623202bdc72b30099e84da816825bad8d
parent2b12abfef2b7ad57a367f1761c4b3ed93d398a1e (diff)
downloadrsyslog-ad0f7f7afa7d28cb285bfdb8c01d95ccfe03996b.tar.gz
rsyslog-ad0f7f7afa7d28cb285bfdb8c01d95ccfe03996b.tar.xz
rsyslog-ad0f7f7afa7d28cb285bfdb8c01d95ccfe03996b.zip
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.
-rw-r--r--ChangeLog4
-rw-r--r--syslogd.c19
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();