diff options
author | Simo Sorce <simo@redhat.com> | 2012-12-05 16:40:32 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-12-05 23:22:58 +0100 |
commit | fb0de650e7454e1dfa76136e325e62a00748238b (patch) | |
tree | c39e05988deea0edfa4e9c8c500da535cc9ac9ac /src | |
parent | 18afc11a02abda49e25450fdcc553a2e8d6d93b4 (diff) | |
download | sssd-fb0de650e7454e1dfa76136e325e62a00748238b.tar.gz sssd-fb0de650e7454e1dfa76136e325e62a00748238b.tar.bz2 sssd-fb0de650e7454e1dfa76136e325e62a00748238b.zip |
Add memory barrier to mmap cache client code loop
Fixes https://fedorahosted.org/sssd/ticket/1694
Diffstat (limited to 'src')
-rw-r--r-- | src/sss_client/nss_mc_common.c | 3 |
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 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; |