Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 173

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

diff --git a/CHANGELOG b/CHANGELOG
index a0f9350..9bebe79 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -29,6 +29,7 @@
 - deal with changed semantics of mkdir in 2.6.19.
 - fix macro table locking.
 - fix nsswitch parser locking.
+- allow only one master map read task at a time.
 
 1/9/2006 autofs-5.0.1 rc2
 -------------------------
diff --git a/daemon/automount.c b/daemon/automount.c
index ccb8021..4e776ca 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -935,6 +935,7 @@ static void *do_read_master(void *arg)
 	if (status) {
 		error(master->default_logging,
 		      "failed to signal master read map condition");
+		master->reading = 0;
 		status = pthread_mutex_unlock(&mrc.mutex);
 		if (status)
 			fatal(status);
@@ -947,6 +948,8 @@ static void *do_read_master(void *arg)
 
 	status = master_read_master(master, age, readall);
 
+	master->reading = 0;
+
 	return NULL;
 }
 
@@ -959,10 +962,20 @@ static int do_hup_signal(struct master *
 	if (status)
 		fatal(status);
 
+	if (master->reading) {
+		status = pthread_mutex_unlock(&mrc.mutex);
+		if (status)
+			fatal(status);
+		return 1;
+	}
+
+	master->reading = 1;
+
 	status = pthread_create(&thid, &thread_attr, do_read_master, NULL);
 	if (status) {
 		error(master->default_logging,
 		      "master read map thread create failed");
+		master->reading = 0;
 		status = pthread_mutex_unlock(&mrc.mutex);
 		if (status)
 			fatal(status);
diff --git a/daemon/state.c b/daemon/state.c
index ea13114..ca091ad 100644
--- a/daemon/state.c
+++ b/daemon/state.c
@@ -682,8 +682,8 @@ int st_add_task(struct autofs_point *ap,
 
 		empty = 0;
 
-		/* Don't add duplicate shutdown tasks */
-		if (task->state == state &&
+		/* Don't add duplicate tasks */
+		if (task->state == state ||
 		   (ap_state == ST_SHUTDOWN_PENDING ||
 		    ap_state == ST_SHUTDOWN_FORCE))
 			break;
@@ -701,7 +701,7 @@ int st_add_task(struct autofs_point *ap,
 
 			p_task = list_entry(q, struct state_queue, pending);
 
-			if (p_task->state == state &&
+			if (p_task->state == state ||
 			   (ap_state == ST_SHUTDOWN_PENDING ||
 			    ap_state == ST_SHUTDOWN_FORCE))
 				goto done;
diff --git a/include/master.h b/include/master.h
index e25626d..f1f675c 100644
--- a/include/master.h
+++ b/include/master.h
@@ -57,6 +57,7 @@ struct master {
 	char *name;
 	unsigned int recurse;
 	unsigned int depth;
+	unsigned int reading;
 	unsigned int default_ghost;
 	unsigned int default_logging;
 	unsigned int default_timeout;
diff --git a/lib/master.c b/lib/master.c
index 0c3c343..f0fdb62 100644
--- a/lib/master.c
+++ b/lib/master.c
@@ -699,6 +699,7 @@ struct master *master_new(const char *na
 
 	master->recurse = 0;
 	master->depth = 0;
+	master->reading = 0;
 	master->default_ghost = ghost;
 	master->default_timeout = timeout;
 	master->default_logging = defaults_get_logging();