From fb0de650e7454e1dfa76136e325e62a00748238b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 5 Dec 2012 16:40:32 -0500 Subject: Add memory barrier to mmap cache client code loop Fixes https://fedorahosted.org/sssd/ticket/1694 --- src/sss_client/nss_mc_common.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/sss_client') diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c index 39a00f86..a361f57b 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; -- cgit