From d0262188cd6cdd67beec401b1e0b26f4fc72daa8 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Wed, 25 Jun 2008 19:44:48 +0000
Subject: [PATCH] fixed bad math for forward timeout's

---
 src/common/forward.c            | 11 ++++++++++-
 src/common/slurm_protocol_api.c |  6 +++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/common/forward.c b/src/common/forward.c
index 05b62d6619a..f892f578b2c 100644
--- a/src/common/forward.c
+++ b/src/common/forward.c
@@ -174,12 +174,15 @@ void *_forward_thread(void *arg)
 		if(fwd_msg->header.forward.cnt > 0) {
 			static int message_timeout = -1;
 			if (message_timeout < 0)
-				message_timeout = slurm_get_msg_timeout() * 1000;
+				message_timeout = 
+					slurm_get_msg_timeout() * 1000;
 			steps = (fwd_msg->header.forward.cnt+1) /
 				slurm_get_tree_width();
 			fwd_msg->timeout = (message_timeout*steps);
+/* 			info("got %d * %d = %d", message_timeout, steps, fwd_msg->timeout); */
 			steps++;
 			fwd_msg->timeout += (start_timeout*steps);
+/* 			info("now  + %d*%d = %d", start_timeout, steps, fwd_msg->timeout); */
 		}	
 		
 		ret_list = slurm_receive_msgs(fd, steps, fwd_msg->timeout);
@@ -349,6 +352,12 @@ extern int forward_msg(forward_struct_t *forward_struct,
 		forward_msg->ret_list = forward_struct->ret_list;
 		
 		forward_msg->timeout = forward_struct->timeout;
+		
+		if(forward_msg->timeout <= 0) {
+			/* convert secs to msec */
+			forward_msg->timeout  = slurm_get_msg_timeout() * 1000; 
+		}
+
 		forward_msg->notify = &forward_struct->notify;
 		forward_msg->forward_mutex = &forward_struct->forward_mutex;
 		forward_msg->buf_len = forward_struct->buf_len;
diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c
index 299d2678399..139b8e44454 100644
--- a/src/common/slurm_protocol_api.c
+++ b/src/common/slurm_protocol_api.c
@@ -1473,6 +1473,9 @@ List slurm_receive_msgs(slurm_fd fd, int steps, int timeout)
 
 	debug4("orig_timeout was %d we have %d steps and a timeout of %d",
 	       orig_timeout, steps, timeout);
+	/* we compare to the orig_timeout here because that is really
+	 *  what we are going to wait for each step
+	 */
 	if(orig_timeout >= (slurm_get_msg_timeout() * 10000)) {
 		debug("slurm_receive_msgs: "
 		      "You are sending a message with timeout's greater "
@@ -1482,7 +1485,8 @@ List slurm_receive_msgs(slurm_fd fd, int steps, int timeout)
 	} else if(orig_timeout < 1000) {
 		debug("slurm_receive_msgs: "
 		      "You are sending a message with a very short timeout of "
-		      "%d milliseconds", timeout);
+		      "%d milliseconds each step in the tree has %d "
+		      "milliseconds", timeout, orig_timeout);
 	} 
 	
 
-- 
GitLab