summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-06-27 13:51:06 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-06-27 13:51:06 +0200
commita924cfe6c2da54829f4729d6d56f8a1cc402475e (patch)
treebb2e99c5ca43eafb8d804ae69df61ef202b5c99d
parent8488d8c3c1e65cb4dacb1dddc71c9186ec9f8f37 (diff)
downloadrsyslog-a924cfe6c2da54829f4729d6d56f8a1cc402475e.tar.gz
rsyslog-a924cfe6c2da54829f4729d6d56f8a1cc402475e.tar.xz
rsyslog-a924cfe6c2da54829f4729d6d56f8a1cc402475e.zip
reduced sporadic failures during make check
the imdiag implementation of "queue empty" was a bit racy, which sometimes lead to too-early termination of rsyslogd and thus some small memory leaks (which in turn showed up as problems during make check). The current architecture is not able to 100% guard against this, but the probleme probability has been reduced (and it showed to improve in practice).
-rw-r--r--plugins/imdiag/imdiag.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/imdiag/imdiag.c b/plugins/imdiag/imdiag.c
index 770b3437..b0025464 100644
--- a/plugins/imdiag/imdiag.c
+++ b/plugins/imdiag/imdiag.c
@@ -259,6 +259,8 @@ finalize_it:
/* This function waits until the main queue is drained (size = 0)
+ * To make sure it really is drained, we check three times. Otherwise we
+ * may just see races.
*/
static rsRetVal
waitMainQEmpty(tcps_sess_t *pSess)
@@ -268,19 +270,22 @@ waitMainQEmpty(tcps_sess_t *pSess)
DEFiRet;
CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize));
- while(iMsgQueueSize > 0) {
- /* DEV DEBUG ONLY if(iPrint++ % 500)
- printf("imdiag: main msg queue size: %d\n", iMsgQueueSize);
- */
- if(iPrint++ % 500 == 0)
- dbgprintf("imdiag sleeping, wait mainq drain, curr size %d\n", iMsgQueueSize);
- srSleep(0,2); /* wait a little bit */
- CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize));
+ while(1) {
if(iMsgQueueSize == 0) {
/* verify that queue is still empty (else it could just be a race!) */
- srSleep(1,5); /* wait a little bit */
+ srSleep(0,250000);/* wait a little bit */
CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize));
+ if(iMsgQueueSize == 0) {
+ srSleep(0,500000);/* wait a little bit */
+ CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize));
+ }
}
+ if(iMsgQueueSize == 0)
+ break;
+ if(iPrint++ % 500 == 0)
+ dbgprintf("imdiag sleeping, wait mainq drain, curr size %d\n", iMsgQueueSize);
+ srSleep(0,200000);/* wait a little bit */
+ CHKiRet(diagGetMainMsgQSize(&iMsgQueueSize));
}
CHKiRet(sendResponse(pSess, "mainqueue empty\n"));