From 46fa98d0625613fffeb2bf58fa6e3e261e9aa45a Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 13 Mar 2006 23:26:57 +0000
Subject: [PATCH] fix for hostfile support

---
 src/common/dist_tasks.c | 4 ++--
 src/srun/launch.c       | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/common/dist_tasks.c b/src/common/dist_tasks.c
index 4d5d0fd8359..85e23fc4c4e 100644
--- a/src/common/dist_tasks.c
+++ b/src/common/dist_tasks.c
@@ -222,7 +222,7 @@ extern slurm_step_layout_t *step_layout_create(
 		 * one of the allocated nodes. */
 		step_layout->num_hosts = 1;
 #else
-		step_layout->num_hosts = step_req->node_count;
+		step_layout->num_hosts = hostlist_count(step_layout->hl);
 #endif
 		step_layout->task_dist	= step_req->task_dist;
 		step_layout->num_tasks  = step_req->num_tasks;
@@ -285,7 +285,7 @@ extern int task_layout(slurm_step_layout_t *step_layout)
 			cpu_cnt = 0;
 		}
 	}
-	step_layout->tasks = xmalloc(sizeof(uint32_t)   
+	step_layout->tasks = xmalloc(sizeof(uint32_t) 
 				     * step_layout->num_hosts);
 	step_layout->tids  = xmalloc(sizeof(uint32_t *) 
 				     * step_layout->num_hosts);
diff --git a/src/srun/launch.c b/src/srun/launch.c
index 911b1fa9385..401901c3085 100644
--- a/src/srun/launch.c
+++ b/src/srun/launch.c
@@ -182,6 +182,8 @@ launch(void *arg)
 	itr = hostlist_iterator_create(hostlist);
 	job->thr_count = 0;
 	for (i = 0; i < job->step_layout->num_hosts; i++) {
+		if(!job->step_layout->host[i])
+			break;
 		slurm_msg_t                *m = &msg_array_ptr[job->thr_count];
 		
 		m->srun_node_id    = (uint32_t)i;			
@@ -190,7 +192,7 @@ launch(void *arg)
 		m->ret_list = NULL;
 		m->orig_addr.sin_addr.s_addr = 0;
 		m->buffer = buffer;
-
+		
 		j=0; 
 		while((host = hostlist_next(itr)) != NULL) { 
 			if(!strcmp(host,job->step_layout->host[i])) {
@@ -201,7 +203,7 @@ launch(void *arg)
 			free(host);
   		}
 		hostlist_iterator_reset(itr);
-		/* debug2("using %d %s with %d tasks\n", j,  */
+		/* debug2("using %d %s with %d tasks\n", j, */
 /* 		       job->step_layout->host[i], */
 /* 		       r.nprocs); */
 		memcpy(&m->address, 
@@ -215,13 +217,11 @@ launch(void *arg)
 				   job->slurmd_addr,
 				   itr,
 				   opt.msg_timeout);
-		
 		job->thr_count++;
 	}
 	xfree(span);
 	hostlist_iterator_destroy(itr);
 	hostlist_destroy(hostlist);
-	
 	_p_launch(msg_array_ptr, job);
 	
 	if (fail_launch_cnt) {
-- 
GitLab