summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-25 12:53:00 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-25 12:53:00 +0200
commitd116f30a877c65b4f23dbb92601251402b0f957e (patch)
tree4670311037ee3862e64260044eaf4599a1ed4856
parente56a30372e807019618570ed70874a3389da2ac2 (diff)
downloadrsyslog-d116f30a877c65b4f23dbb92601251402b0f957e.tar.gz
rsyslog-d116f30a877c65b4f23dbb92601251402b0f957e.tar.xz
rsyslog-d116f30a877c65b4f23dbb92601251402b0f957e.zip
improvements/fixes in queue termination timeout handling
- bugfix: subtle (and usually irrelevant) issue in timout processing timeout could be one second too early if nanoseconds wrapped - set a more sensible timeout for shutdow, now 1.5 seconds to complete processing (this also removes those cases where the shutdown message was not written because the termination happened before it)
-rw-r--r--ChangeLog6
-rw-r--r--runtime/srutils.c4
-rw-r--r--runtime/wti.c8
-rw-r--r--tools/syslogd.c4
4 files changed, 17 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index ca1ea10a..0cef1a0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,12 @@ Version 5.1.1 [DEVEL] (rgerhards), 2009-06-??
- bugfix: huge memory leak in queue engine (made rsyslogd unusable in
production). Occured if at least one queue was in direct mode
(the default for action queues)
+- imported many performance optimizations from v4-devel (4.5.0)
+- bugfix: subtle (and usually irrelevant) issue in timout processing
+ timeout could be one second too early if nanoseconds wrapped
+- set a more sensible timeout for shutdow, now 1.5 seconds to complete
+ processing (this also removes those cases where the shutdown message
+ was not written because the termination happened before it)
---------------------------------------------------------------------------
Version 5.1.0 [DEVEL] (rgerhards), 2009-05-29
diff --git a/runtime/srutils.c b/runtime/srutils.c
index 5407531f..c403b312 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -366,6 +366,7 @@ int getNumberDigits(long lNum)
/* compute an absolute time timeout suitable for calls to pthread_cond_timedwait()
+ * iTimeout is in milliseconds
* rgerhards, 2008-01-14
*/
rsRetVal
@@ -375,11 +376,12 @@ timeoutComp(struct timespec *pt, long iTimeout)
assert(pt != NULL);
/* compute timeout */
clock_gettime(CLOCK_REALTIME, pt);
+ pt->tv_sec += iTimeout / 1000;
pt->tv_nsec += (iTimeout % 1000) * 1000000; /* think INTEGER arithmetic! */
if(pt->tv_nsec > 999999999) { /* overrun? */
pt->tv_nsec -= 1000000000;
+ ++pt->tv_sec;
}
- pt->tv_sec += iTimeout / 1000;
ENDfunc
return RS_RET_OK; /* so far, this is static... */
}
diff --git a/runtime/wti.c b/runtime/wti.c
index 9c137f57..917b456b 100644
--- a/runtime/wti.c
+++ b/runtime/wti.c
@@ -147,10 +147,12 @@ wtiSetState(wti_t *pThis, qWrkCmd_t tCmd, int bActiveOnly, int bLockMutex)
break;
}
/* apply the new state */
+dbgprintf("worker terminator will write stateval %d\n", tCmd);
unsigned val = ATOMIC_CAS_VAL(pThis->tCurrCmd, tCurrCmd, tCmd);
if(val != tCurrCmd) {
DBGPRINTF("wtiSetState PROBLEM, tCurrCmd %d overwritten with %d, wanted to set %d\n", tCurrCmd, val, tCmd);
}
+//dbgprintf("worker terminator has written stateval %d\n", tCmd);
}
END_MTX_PROTECTED_OPERATIONS(&pThis->mut);
@@ -158,7 +160,7 @@ wtiSetState(wti_t *pThis, qWrkCmd_t tCmd, int bActiveOnly, int bLockMutex)
}
-/* Cancel the thread. If the thread is already cancelled or termination,
+/* Cancel the thread. If the thread is already cancelled or terminated,
* we do not again cancel it. But it is save and legal to call wtiCancelThrd() in
* such situations.
* rgerhards, 2008-02-26
@@ -172,8 +174,10 @@ wtiCancelThrd(wti_t *pThis)
d_pthread_mutex_lock(&pThis->mut);
+ wtiProcessThrdChanges(pThis, MUTEX_ALREADY_LOCKED); /* process state change, so that we have current state vars */
+
if(pThis->tCurrCmd >= eWRKTHRD_TERMINATING) {
- dbgoprint((obj_t*) pThis, "canceling worker thread\n");
+ dbgoprint((obj_t*) pThis, "canceling worker thread, curr stat %d\n", pThis->tCurrCmd);
pthread_cancel(pThis->thrdID);
wtiSetState(pThis, eWRKTHRD_TERMINATING, 0, MUTEX_ALREADY_LOCKED);
ATOMIC_STORE_1_TO_INT(pThis->pWtp->bThrdStateChanged); /* indicate change, so harverster will be called */
diff --git a/tools/syslogd.c b/tools/syslogd.c
index ace08e58..6a3fa6c9 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -302,7 +302,7 @@ static uchar *pszMainMsgQFName = NULL; /* prefix for the main message queue f
static int64 iMainMsgQueMaxFileSize = 1024*1024;
static int iMainMsgQPersistUpdCnt = 0; /* persist queue info every n updates */
static int bMainMsgQSyncQeueFiles = 0; /* sync queue files on every write? */
-static int iMainMsgQtoQShutdown = 0; /* queue shutdown */
+static int iMainMsgQtoQShutdown = 1500; /* queue shutdown (ms) */
static int iMainMsgQtoActShutdown = 1000; /* action shutdown (in phase 2) */
static int iMainMsgQtoEnq = 2000; /* timeout for queue enque */
static int iMainMsgQtoWrkShutdown = 60000; /* timeout for worker thread shutdown */
@@ -367,7 +367,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
iMainMsgQueueNumWorkers = 1;
iMainMsgQPersistUpdCnt = 0;
bMainMsgQSyncQeueFiles = 0;
- iMainMsgQtoQShutdown = 0;
+ iMainMsgQtoQShutdown = 1500;
iMainMsgQtoActShutdown = 1000;
iMainMsgQtoEnq = 2000;
iMainMsgQtoWrkShutdown = 60000;