summaryrefslogtreecommitdiffstats
path: root/src/sss_client
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:22:58 +0100
commitfb0de650e7454e1dfa76136e325e62a00748238b (patch)
treec39e05988deea0edfa4e9c8c500da535cc9ac9ac /src/sss_client
parent18afc11a02abda49e25450fdcc553a2e8d6d93b4 (diff)
downloadsssd-fb0de650e7454e1dfa76136e325e62a00748238b.tar.gz
sssd-fb0de650e7454e1dfa76136e325e62a00748238b.tar.xz
sssd-fb0de650e7454e1dfa76136e325e62a00748238b.zip
Add memory barrier to mmap cache client code loop
Fixes https://fedorahosted.org/sssd/ticket/1694
Diffstat (limited to 'src/sss_client')
-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;