From 1b89e1b359153b9b7634d0300a2b96b1d448b627 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Wed, 18 Jun 2003 17:03:31 +0000
Subject: [PATCH] Move retry_cnt initialization into while loop. Note and fix
 retry count errors rather than letting agent go off the end of an array.

---
 src/slurmctld/agent.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/slurmctld/agent.c b/src/slurmctld/agent.c
index f0b02e6cdf5..7c63c4856f0 100644
--- a/src/slurmctld/agent.c
+++ b/src/slurmctld/agent.c
@@ -329,7 +329,7 @@ static task_info_t *_make_task_data(agent_info_t *agent_info_ptr, int inx)
  */
 static void *_wdog(void *args)
 {
-	int fail_cnt, no_resp_cnt, retry_cnt = 0;
+	int fail_cnt, no_resp_cnt, retry_cnt;
 	bool work_done;
 	int i, delay, max_delay = 0;
 	agent_info_t *agent_ptr = (agent_info_t *) args;
@@ -347,6 +347,7 @@ static void *_wdog(void *args)
 		work_done   = true;	/* assume all threads complete */
 		fail_cnt    = 0;	/* assume no threads failures */
 		no_resp_cnt = 0;	/* assume all threads respond */
+		retry_cnt   = 0;	/* assume no required retries */
 
 		sleep(WDOG_POLL);
 
@@ -639,6 +640,11 @@ static void _queue_agent_retry(agent_info_t * agent_info_ptr, int count)
 		if ((++j) == count)
 			break;
 	}
+	if (count != j) {
+		error("agent: Retry count (%d) != actual count (%d)", 
+			count, j);
+		agent_arg_ptr->node_count = j;
+	}
 
 	/* add the requeust to a list */
 	slurm_mutex_lock(&retry_mutex);
-- 
GitLab