about summary refs log tree commit diff
path: root/nscd/mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/mem.c')
-rw-r--r--nscd/mem.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/nscd/mem.c b/nscd/mem.c
index a4e30535c8..5207efc2de 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -230,6 +230,12 @@ gc (struct database_dyn *db)
     ++next_data;
 
 
+  /* 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;
+  assert ((db->head->gc_cycle & 1) == 1);
+
+
   /* We do not perform the move operations right away since the
      he_data array is not sorted by the address of the data.  */
   struct moveinfo
@@ -445,6 +451,11 @@ gc (struct database_dyn *db)
     msync (db->head, db->data + db->head->first_free - (char *) db->head,
 	   MS_ASYNC);
 
+
+  /* Now we are done modifying the data.  */
+  ++db->head->gc_cycle;
+  assert ((db->head->gc_cycle & 1) == 0);
+
   /* We are done.  */
  out:
   pthread_mutex_unlock (&db->memlock);