summaryrefslogtreecommitdiffstats
path: root/runtime/srutils.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-25 12:59:13 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-25 12:59:13 +0200
commit5af5b1e42868d00dfbc5fa47028768d0a03f8e32 (patch)
treeb967f080a0ae440cabda11d36475894e9fa43916 /runtime/srutils.c
parentd12b9e0c67cc72c9b1631bf2a5611d383e7ad69d (diff)
downloadrsyslog-5af5b1e42868d00dfbc5fa47028768d0a03f8e32.tar.gz
rsyslog-5af5b1e42868d00dfbc5fa47028768d0a03f8e32.tar.xz
rsyslog-5af5b1e42868d00dfbc5fa47028768d0a03f8e32.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)
Diffstat (limited to 'runtime/srutils.c')
-rw-r--r--runtime/srutils.c4
1 files changed, 3 insertions, 1 deletions
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... */
}