summaryrefslogtreecommitdiffstats
path: root/srUtils.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-21 13:26:33 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-21 13:26:33 +0000
commit760dada7ebf216f2c326a8b25d31c5c8cf26f1f9 (patch)
tree26628c34d48991c0b11001eb99bdeae6af84ed37 /srUtils.c
parentc876b04da21a40e9cfe6588d89c15c226504d26e (diff)
downloadrsyslog-760dada7ebf216f2c326a8b25d31c5c8cf26f1f9.tar.gz
rsyslog-760dada7ebf216f2c326a8b25d31c5c8cf26f1f9.tar.xz
rsyslog-760dada7ebf216f2c326a8b25d31c5c8cf26f1f9.zip
added some mutex-support to srUtils
Diffstat (limited to 'srUtils.c')
-rwxr-xr-xsrUtils.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/srUtils.c b/srUtils.c
index 4e363e79..82567985 100755
--- a/srUtils.c
+++ b/srUtils.c
@@ -311,6 +311,36 @@ int getNumberDigits(long lNum)
}
+/* compute an absolute time timeout suitable for calls to pthread_cond_timedwait()
+ * rgerhards, 2008-01-14
+ */
+rsRetVal
+timeoutComp(struct timespec *pt, int iTimeout)
+{
+ assert(pt != NULL);
+ /* compute timeout */
+ clock_gettime(CLOCK_REALTIME, pt);
+ 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;
+ return RS_RET_OK; /* so far, this is static... */
+}
+
+
+/* cancellation cleanup handler - frees provided mutex
+ * rgerhards, 2008-01-14
+ */
+void
+mutexCancelCleanup(void *arg)
+{
+ assert(arg != NULL);
+ d_pthread_mutex_unlock((pthread_mutex_t*) arg);
+}
+
+
/*
* vi:set ai:
*/