File nscd-prune.patch of Package glibc.18276

From 995db91eb235e6cd68b9bdb41a5b106ed98f9ec5 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Wed, 17 Jun 2020 16:05:13 +0200
Subject: [PATCH] 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.
---
 nscd/cache.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Index: glibc-2.26/nscd/cache.c
===================================================================
--- glibc-2.26.orig/nscd/cache.c
+++ glibc-2.26/nscd/cache.c
@@ -452,6 +452,11 @@ prune_cache (struct database_dyn *table,
 	  pthread_rwlock_wrlock (&table->lock);
 	}
 
+      /* Now we start modifying the data.  Make sure all readers of the
+	 data are aware of this and temporarily don't use the data.  */
+      ++table->head->gc_cycle;
+      assert ((table->head->gc_cycle & 1) == 1);
+
       while (first <= last)
 	{
 	  if (mark[first])
@@ -492,6 +497,10 @@ prune_cache (struct database_dyn *table,
 	  ++first;
 	}
 
+      /* Now we are done modifying the data.  */
+      ++table->head->gc_cycle;
+      assert ((table->head->gc_cycle & 1) == 0);
+
       /* It's all done.  */
       pthread_rwlock_unlock (&table->lock);
openSUSE Build Service is sponsored by