summaryrefslogtreecommitdiffstats
path: root/runtime/srUtils.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-05-27 19:43:28 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-05-27 19:43:28 +0200
commitd4564f8399f4362c7e79066370049f909cef996c (patch)
tree88f07eb0a76a5ca55a1948cccc0c3c38e6c517f3 /runtime/srUtils.h
parentaffa217cc2d22fa8037a50b8d40d3372694ff855 (diff)
downloadrsyslog-d4564f8399f4362c7e79066370049f909cef996c.tar.gz
rsyslog-d4564f8399f4362c7e79066370049f909cef996c.tar.xz
rsyslog-d4564f8399f4362c7e79066370049f909cef996c.zip
interim commit: working on failure cases
slightly improved situation, would like to save it before carrying on
Diffstat (limited to 'runtime/srUtils.h')
-rw-r--r--runtime/srUtils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/srUtils.h b/runtime/srUtils.h
index bfce4cbb..288e9dd7 100644
--- a/runtime/srUtils.h
+++ b/runtime/srUtils.h
@@ -117,11 +117,23 @@ int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep);
if(bMustLock == LOCK_MUTEX) { \
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); \
d_pthread_mutex_lock(mut); \
+ assert(bLockedOpIsLocked == 0); \
bLockedOpIsLocked = 1; \
}
#define END_MTX_PROTECTED_OPERATIONS(mut) \
if(bLockedOpIsLocked) { \
d_pthread_mutex_unlock(mut); \
+ bLockedOpIsLocked = 0; \
pthread_setcancelstate(iCancelStateSave, NULL); \
}
+/* The unconditional versions of the macro always lock the mutex. They are preferred in
+ * complex scenarios, where the simple ones might get mixed up by multiple calls.
+ */
+#define BEGIN_MTX_PROTECTED_OPERATIONS_UNCOND(mut) \
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); \
+ d_pthread_mutex_lock(mut);
+#define END_MTX_PROTECTED_OPERATIONS_UNCOND(mut) \
+ d_pthread_mutex_unlock(mut); \
+ pthread_setcancelstate(iCancelStateSave, NULL);
+
#endif