From a662a226b19e099df742b8717888287cb6f311b6 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Tue, 4 Apr 2017 13:28:05 -0600
Subject: [PATCH] Fix potential infinite loop when talking to the DBD when
 shutting down the slurmctld.

---
 NEWS                            | 2 ++
 src/common/slurm_persist_conn.c | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 49679503dd1..0ec24fa8db2 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,8 @@ documents those changes that are of interest to users and administrators.
  -- Allow AdminComment field to be changed by any Administrator.
  -- Fix key words in jobcomp select.
  -- MYSQL - Streamline job flush sql when doing a clean start on the slurmctld.
+ -- Fix potential infinite loop when talking to the DBD when shutting down
+    the slurmctld.
 
 * Changes in Slurm 17.02.1-2
 ============================
diff --git a/src/common/slurm_persist_conn.c b/src/common/slurm_persist_conn.c
index e1f4d09e2fe..1806ae76806 100644
--- a/src/common/slurm_persist_conn.c
+++ b/src/common/slurm_persist_conn.c
@@ -891,11 +891,12 @@ extern Buf slurm_persist_recv_msg(slurm_persist_conn_t *persist_conn)
 	return buffer;
 
 endit:
-	/* Close it since we abondoned it.  If the connection does still exist
+	/* Close it since we abandoned it.  If the connection does still exist
 	 * on the other end we can't rely on it after this point since we didn't
 	 * listen long enough for this response.
 	 */
-	if (persist_conn->flags & PERSIST_FLAG_RECONNECT)
+	if (!(*persist_conn->shutdown) &&
+	    persist_conn->flags & PERSIST_FLAG_RECONNECT)
 		slurm_persist_conn_reopen(persist_conn, true);
 
 	return NULL;
-- 
GitLab