summaryrefslogtreecommitdiffstats
path: root/wti.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-25 10:45:25 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-25 10:45:25 +0000
commit167abdb5b3fa6900edd6bbdb1cc7d586896a268c (patch)
treebed714a9789bd3f7bd2c86039dfdd4196471b85a /wti.c
parent5c686c8adcc473cbdbb14e4b2d736f9123210ee6 (diff)
downloadrsyslog-167abdb5b3fa6900edd6bbdb1cc7d586896a268c.tar.gz
rsyslog-167abdb5b3fa6900edd6bbdb1cc7d586896a268c.tar.xz
rsyslog-167abdb5b3fa6900edd6bbdb1cc7d586896a268c.zip
restructured queue shutdown so that the queue timeout is properly applied
before terminatiing the queue
Diffstat (limited to 'wti.c')
-rw-r--r--wti.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/wti.c b/wti.c
index 045330c6..2e1dd548 100644
--- a/wti.c
+++ b/wti.c
@@ -159,6 +159,16 @@ rsRetVal wtiDestruct(wti_t **ppThis)
/* we can not be canceled, that would have a myriad of side-effects */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave);
+ /* if we reach this point, we must make sure the associated worker has terminated. It is
+ * the callers duty to make sure the worker has already terminated.
+ * TODO: is it *really* the caller's duty? ...mmmhhhh.... smells bad... rgerhards, 2008-01-25
+ */
+ wtiProcessThrdChanges(pThis, LOCK_MUTEX); /* process state change one last time */
+
+ d_pthread_mutex_lock(&pThis->mut);
+ assert(wtiGetState(pThis, MUTEX_ALREADY_LOCKED) <= eWRKTHRD_TERMINATING); // I knew it smelled bad...
+ d_pthread_mutex_unlock(&pThis->mut);
+
/* actual destruction */
pthread_cond_destroy(&pThis->condInitDone);
pthread_mutex_destroy(&pThis->mut);
@@ -166,7 +176,7 @@ rsRetVal wtiDestruct(wti_t **ppThis)
if(pThis->pszDbgHdr != NULL)
free(pThis->pszDbgHdr);
- /* and finally delete the queue objet itself */
+ /* and finally delete the wti object itself */
free(pThis);
*ppThis = NULL;