summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-25 12:05:25 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-25 12:05:25 +0200
commite56a30372e807019618570ed70874a3389da2ac2 (patch)
tree58f5bb1fba50ec022a5ad46c0e62f3ef3e533a3a
parent46024834449840dabf399dda196c9dd11cf78ace (diff)
parentd12b9e0c67cc72c9b1631bf2a5611d383e7ad69d (diff)
downloadrsyslog-e56a30372e807019618570ed70874a3389da2ac2.tar.gz
rsyslog-e56a30372e807019618570ed70874a3389da2ac2.tar.xz
rsyslog-e56a30372e807019618570ed70874a3389da2ac2.zip
Merge branch 'master' into v5-devel
Conflicts: runtime/atomic.h runtime/wti.c
-rw-r--r--ChangeLog1
-rw-r--r--runtime/atomic.h1
-rw-r--r--runtime/wti.c7
3 files changed, 7 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 9dc72bd8..ca1ea10a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -61,6 +61,7 @@ Version 4.5.0 [DEVEL] (rgerhards), 2009-??-??
* $OMFileFlushOnTXEnd
* $MainMsgQueueSyncQueueFiles
* $ActionQueueSyncQueueFiles
+- done some memory accesses explicitely atomic
---------------------------------------------------------------------------
Version 4.3.2 [beta] (rgerhards), 2009-06-24
- removed long-obsoleted property UxTradMsg
diff --git a/runtime/atomic.h b/runtime/atomic.h
index 4cb832f2..f5ae9357 100644
--- a/runtime/atomic.h
+++ b/runtime/atomic.h
@@ -50,6 +50,7 @@
# define ATOMIC_STORE_1_TO_INT(data) __sync_fetch_and_or(&(data), 1)
# define ATOMIC_STORE_INT_TO_INT(data, val) __sync_fetch_and_or(&(data), (val))
# define ATOMIC_CAS(data, oldVal, newVal) __sync_bool_compare_and_swap(&(data), (oldVal), (newVal));
+# define ATOMIC_CAS_VAL(data, oldVal, newVal) __sync_val_compare_and_swap(&(data), (oldVal), (newVal));
#else
/* note that we gained parctical proof that theoretical problems DO occur
* if we do not properly address them. See this blog post for details:
diff --git a/runtime/wti.c b/runtime/wti.c
index c9fc4879..9c137f57 100644
--- a/runtime/wti.c
+++ b/runtime/wti.c
@@ -146,8 +146,11 @@ wtiSetState(wti_t *pThis, qWrkCmd_t tCmd, int bActiveOnly, int bLockMutex)
/* DO NOTHING */
break;
}
- /* better do a CAS? */
- ATOMIC_STORE_INT_TO_INT(pThis->tCurrCmd, tCmd); /* apply the new state */
+ /* apply the new state */
+ 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);
+ }
}
END_MTX_PROTECTED_OPERATIONS(&pThis->mut);