Blob Blame History Raw
autofs-5.0.4 - fix direct map cache locking

From: Ian Kent <raven@themaw.net>

Some time during the recent round of updates some locking of the
null map and the direct map entry caches was removed. This patch
adds it back again.
---

 CHANGELOG       |    1 +
 daemon/direct.c |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index af7792d..82ebc83 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -60,6 +60,7 @@
 - don't block signals we expect to dump core.
 - fix pthread push order in expire_proc_direct().
 - fix libxml2 non-thread-safe calls.
+- fix direct map cache locking.
 
 4/11/2008 autofs-5.0.4
 -----------------------
diff --git a/daemon/direct.c b/daemon/direct.c
index 0f33d03..0c78627 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -470,6 +470,8 @@ int mount_autofs_direct(struct autofs_point *ap)
 	pthread_cleanup_push(master_source_lock_cleanup, ap->entry);
 	master_source_readlock(ap->entry);
 	nc = ap->entry->master->nc;
+	cache_readlock(nc);
+	pthread_cleanup_push(cache_lock_cleanup, nc);
 	map = ap->entry->maps;
 	while (map) {
 		/*
@@ -482,6 +484,8 @@ int mount_autofs_direct(struct autofs_point *ap)
 		}
 
 		mc = map->mc;
+		cache_readlock(mc);
+		pthread_cleanup_push(cache_lock_cleanup, mc);
 		me = cache_enumerate(mc, NULL);
 		while (me) {
 			ne = cache_lookup_distinct(nc, me->key);
@@ -509,10 +513,12 @@ int mount_autofs_direct(struct autofs_point *ap)
 
 			me = cache_enumerate(mc, me);
 		}
+		pthread_cleanup_pop(1);
 		map = map->next;
 	}
 	pthread_cleanup_pop(1);
 	pthread_cleanup_pop(1);
+	pthread_cleanup_pop(1);
 
 	return 0;
 }