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.
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. */
+ atomic_fetch_add_relaxed (&table->head->gc_cycle, 1);
+ assert ((table->head->gc_cycle & 1) == 1);
+
while (first <= last)
{
if (mark[first])
++first;
}
+ /* Now we are done modifying the data. */
+ atomic_fetch_add_relaxed (&table->head->gc_cycle, 1);
+ assert ((table->head->gc_cycle & 1) == 0);
+
/* It's all done. */
pthread_rwlock_unlock (&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. */
- ++db->head->gc_cycle;
+ atomic_fetch_add_relaxed (&db->head->gc_cycle, 1);
assert ((db->head->gc_cycle & 1) == 1);
/* 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. */