summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-12-05 16:40:32 -0500
committerJakub Hrozek <jhrozek@redhat.com>2012-12-05 23:24:50 +0100
commitddd46c1308d3acfded4b48b620b1b59ee0271b13 (patch)
tree32cea684eec8ec22c1bea7c42b6c1f8e5f3ccace
parentb9d9832829aae62aed1a4f76abf2f88d25133dca (diff)
downloadsssd-ddd46c1308d3acfded4b48b620b1b59ee0271b13.tar.gz
sssd-ddd46c1308d3acfded4b48b620b1b59ee0271b13.tar.xz
sssd-ddd46c1308d3acfded4b48b620b1b59ee0271b13.zip
Add memory barrier to mmap cache client code loop
Fixes https://fedorahosted.org/sssd/ticket/1694
-rw-r--r--src/sss_client/nss_mc_common.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c
index 39a00f86f..a361f57b9 100644
--- a/src/sss_client/nss_mc_common.c
+++ b/src/sss_client/nss_mc_common.c
@@ -46,6 +46,9 @@ errno_t sss_nss_check_header(struct sss_cli_mc_ctx *ctx)
/* retry barrier protected reading max 5 times then give up */
for (count = 5; count > 0; count--) {
memcpy(&h, ctx->mmap_base, sizeof(struct sss_mc_header));
+ /* we need a barrier here to make sure the compiler does not optimize
+ * too much and avoids updating the register for the next check */
+ __sync_synchronize();
if (MC_VALID_BARRIER(h.b1) && h.b1 == h.b2) {
/* record is consistent so we can proceed */
break;