From cb6d1148d9a02ddd1b5e6d56d7fb1b378ac75229 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Thu, 2 Nov 2006 17:27:37 +0000
Subject: [PATCH] patch from Hongjia Cao forward race condition

---
 src/common/forward.c  | 44 ++++++++++++++++++++++++++-----------------
 src/sview/part_info.c |  2 +-
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/src/common/forward.c b/src/common/forward.c
index 2defafa41ed..9dc72f331c0 100644
--- a/src/common/forward.c
+++ b/src/common/forward.c
@@ -84,10 +84,12 @@ void *_forward_thread(void *arg)
 			slurm_mutex_lock(fwd_msg->forward_mutex);
 			mark_as_failed_forward(&fwd_msg->ret_list, name,
 					       SLURM_SOCKET_ERROR);
-			slurm_mutex_unlock(fwd_msg->forward_mutex);
-
-			free(name);
-			continue;
+ 			free(name);
+			if (hostlist_count(hl) > 0) {
+				slurm_mutex_unlock(fwd_msg->forward_mutex);
+				continue;
+			}
+			goto cleanup;			
 		}
 		if ((fd = slurm_open_msg_conn(&addr)) < 0) {
 			error("forward_thread to %s: %m", name);
@@ -95,10 +97,12 @@ void *_forward_thread(void *arg)
 			slurm_mutex_lock(fwd_msg->forward_mutex);
 			mark_as_failed_forward(&fwd_msg->ret_list, name,
 					       SLURM_SOCKET_ERROR);
-			slurm_mutex_unlock(fwd_msg->forward_mutex);
-
 			free(name);
-			continue;
+			if (hostlist_count(hl) > 0) {
+				slurm_mutex_unlock(fwd_msg->forward_mutex);
+				continue;
+			}
+			goto cleanup;			
 		}
 		hostlist_ranged_string(hl, sizeof(buf), buf);
 
@@ -137,12 +141,14 @@ void *_forward_thread(void *arg)
 			slurm_mutex_lock(fwd_msg->forward_mutex);
 			mark_as_failed_forward(&fwd_msg->ret_list, name, 
 					       errno);
-			slurm_mutex_unlock(fwd_msg->forward_mutex);
-			
-			free_buf(buffer);	
 			free(name);
-			buffer = init_buf(0);
-			continue;
+			if (hostlist_count(hl) > 0) {
+				free_buf(buffer);	
+				buffer = init_buf(0);
+				slurm_mutex_unlock(fwd_msg->forward_mutex);
+				continue;
+			}
+			goto cleanup;			
 		}
 
 		if ((fwd_msg->header.msg_type == REQUEST_SHUTDOWN) ||
@@ -178,12 +184,16 @@ void *_forward_thread(void *arg)
 			slurm_mutex_lock(fwd_msg->forward_mutex);
 			mark_as_failed_forward(&fwd_msg->ret_list, name, 
 					       errno);
-			slurm_mutex_unlock(fwd_msg->forward_mutex);
-			
-			free_buf(buffer);	
 			free(name);
-			buffer = init_buf(0);
-			continue;
+			if(ret_list)
+				list_destroy(ret_list);
+			if (hostlist_count(hl) > 0) {
+				free_buf(buffer);	
+				buffer = init_buf(0);
+				slurm_mutex_unlock(fwd_msg->forward_mutex);
+				continue;
+			}
+			goto cleanup;			
 		}
 		break;
 	}
diff --git a/src/sview/part_info.c b/src/sview/part_info.c
index d0465e92da7..1dbe066dbae 100644
--- a/src/sview/part_info.c
+++ b/src/sview/part_info.c
@@ -197,7 +197,7 @@ _build_min_max_32_string(char *buffer, int buf_size,
 	if (max == min)
 		return snprintf(buffer, buf_size, "%s", tmp_max);
 	else if (range) {
-		if (max == INFINITE)
+		if (max == (uint32_t) INFINITE)
 			return snprintf(buffer, buf_size, "%s-infinite", 
 					tmp_min);
 		else
-- 
GitLab