aboutsummaryrefslogtreecommitdiff
path: root/nscd/mem.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2020-06-17 16:05:13 +0200
committerAndreas Schwab <schwab@suse.de>2020-09-17 17:59:11 +0200
commit5e74e6f85842892bc25da8e8c70d8dadd485941a (patch)
treeecccee562fbf549b47bdecfc07aa3fa41b065b2b /nscd/mem.c
parent94cd37ebb293321115a36a422b091fdb72d2fb08 (diff)
downloadglibc-5e74e6f85842892bc25da8e8c70d8dadd485941a.tar
glibc-5e74e6f85842892bc25da8e8c70d8dadd485941a.tar.gz
glibc-5e74e6f85842892bc25da8e8c70d8dadd485941a.tar.bz2
glibc-5e74e6f85842892bc25da8e8c70d8dadd485941a.zip
nscd: bump GC cycle during cache pruning (bug 26130)
While nscd prunes a cache it becomes inconsistent temporarily, which is visible to clients if that cache is shared. Bump the GC cycle counter so that the clients notice the modification window. Uniformly use atomic_fetch_add to modify the GC cycle counter.
Diffstat (limited to 'nscd/mem.c')
-rw-r--r--nscd/mem.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/nscd/mem.c b/nscd/mem.c
index 3d10bb9b46..de5bd12db5 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -264,7 +264,7 @@ gc (struct database_dyn *db)
/* Now we start modifying the data. Make sure all readers of the
data are aware of this and temporarily don't use the data. */
- ++db->head->gc_cycle;
+ atomic_fetch_add_relaxed (&db->head->gc_cycle, 1);
assert ((db->head->gc_cycle & 1) == 1);
@@ -490,7 +490,7 @@ gc (struct database_dyn *db)
/* Now we are done modifying the data. */
- ++db->head->gc_cycle;
+ atomic_fetch_add_relaxed (&db->head->gc_cycle, 1);
assert ((db->head->gc_cycle & 1) == 0);
/* We are done. */