<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">diff --git a/daemon/state.c b/daemon/state.c
index d5eca8b..2fa78aa 100644
--- a/daemon/state.c
+++ b/daemon/state.c
@@ -190,10 +190,10 @@ void expire_cleanup(void *arg)
 	if (next != ST_INVAL)
 		nextstate(statefd, next);
 
-	state_mutex_unlock(ap);
-
 	st_set_done(ap);
 
+	state_mutex_unlock(ap);
+
 	return;
 }
 
@@ -326,11 +326,10 @@ static void do_readmap_cleanup(void *arg)
 	state_mutex_lock(ap);
 
 	nextstate(ap-&gt;state_pipe[1], ST_READY);
+	st_set_done(ap);
 
 	state_mutex_unlock(ap);
 
-	st_set_done(ap);
-
 	if (!ap-&gt;submount)
 		alarm_add(ap, ap-&gt;exp_runfreq);
 
@@ -480,10 +479,6 @@ static unsigned int st_readmap(struct autofs_point *ap)
 	assert(ap-&gt;state == ST_READY);
 	assert(ap-&gt;readmap_thread == 0);
 
-	/* Turn off timeouts for this mountpoint */
-	if (!ap-&gt;submount)
-		alarm_delete(ap);
-
 	ap-&gt;state = ST_READMAP;
 
 	ra = malloc(sizeof(struct readmap_args));
@@ -549,10 +544,6 @@ static unsigned int st_prepare_shutdown(struct autofs_point *ap)
 
 	debug(ap-&gt;logopt, "state %d path %s", ap-&gt;state, ap-&gt;path);
 
-	/* Turn off timeouts for this mountpoint */
-	if (!ap-&gt;submount)
-		alarm_delete(ap);
-
 	assert(ap-&gt;state == ST_READY || ap-&gt;state == ST_EXPIRE);
 	ap-&gt;state = ST_SHUTDOWN_PENDING;
 
@@ -579,10 +570,6 @@ static unsigned int st_force_shutdown(struct autofs_point *ap)
 
 	debug(ap-&gt;logopt, "state %d path %s", ap-&gt;state, ap-&gt;path);
 
-	/* Turn off timeouts for this mountpoint */
-	if (!ap-&gt;submount)
-		alarm_delete(ap);
-
 	assert(ap-&gt;state == ST_READY || ap-&gt;state == ST_EXPIRE);
 	ap-&gt;state = ST_SHUTDOWN_FORCE;
 
@@ -610,10 +597,6 @@ static unsigned int st_prune(struct autofs_point *ap)
 	assert(ap-&gt;state == ST_READY);
 	ap-&gt;state = ST_PRUNE;
 
-	/* Turn off timeouts while we prune */
-	if (!ap-&gt;submount)
-		alarm_delete(ap);
-
 	switch (expire_proc(ap, 1)) {
 	case EXP_ERROR:
 	case EXP_PARTIAL:
@@ -635,10 +618,6 @@ static unsigned int st_expire(struct autofs_point *ap)
 	assert(ap-&gt;state == ST_READY);
 	ap-&gt;state = ST_EXPIRE;
 
-	/* Turn off timeouts while we expire */
-	if (!ap-&gt;submount)
-		alarm_delete(ap);
-
 	switch (expire_proc(ap, 0)) {
 	case EXP_ERROR:
 	case EXP_PARTIAL:
@@ -723,7 +702,7 @@ int st_add_task(struct autofs_point *ap, enum states state)
 		empty = 0;
 
 		/* Don't add duplicate tasks */
-		if (task-&gt;state == state ||
+		if ((task-&gt;state == state &amp;&amp; !task-&gt;done) ||
 		   (ap_state == ST_SHUTDOWN_PENDING ||
 		    ap_state == ST_SHUTDOWN_FORCE))
 			break;
@@ -888,6 +867,7 @@ static void st_set_thid(struct autofs_point *ap, pthread_t thid)
 	return;
 }
 
+/* Requires state mutex to be held */
 static void st_set_done(struct autofs_point *ap)
 {
 	struct list_head *p, *head;
</pre></body></html>