diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-21 13:26:33 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-21 13:26:33 +0000 |
commit | 760dada7ebf216f2c326a8b25d31c5c8cf26f1f9 (patch) | |
tree | 26628c34d48991c0b11001eb99bdeae6af84ed37 /srUtils.c | |
parent | c876b04da21a40e9cfe6588d89c15c226504d26e (diff) | |
download | rsyslog-760dada7ebf216f2c326a8b25d31c5c8cf26f1f9.tar.gz rsyslog-760dada7ebf216f2c326a8b25d31c5c8cf26f1f9.tar.xz rsyslog-760dada7ebf216f2c326a8b25d31c5c8cf26f1f9.zip |
added some mutex-support to srUtils
Diffstat (limited to 'srUtils.c')
-rwxr-xr-x | srUtils.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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: */ |