From c2232dc7e810c64c45adcf34105c16b04c053e5c Mon Sep 17 00:00:00 2001
From: "Christopher J. Morrone" <morrone2@llnl.gov>
Date: Wed, 6 Sep 2006 23:41:27 +0000
Subject: [PATCH] Ok, sattach is showing standard IO now (for real this time).

Need to make port numbers be in host byte order by default so that this
confusion doesn't happen again.
---
 src/api/step_io.c     | 4 +++-
 src/api/step_launch.c | 2 +-
 src/srun/launch.c     | 2 +-
 src/srun/reattach.c   | 4 ++--
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/api/step_io.c b/src/api/step_io.c
index d0889b56155..722961b13ca 100644
--- a/src/api/step_io.c
+++ b/src/api/step_io.c
@@ -1195,11 +1195,13 @@ client_io_handler_create(slurm_step_io_fds_t fds,
 
 	for (i = 0; i < cio->num_listen; i++) {
 		eio_obj_t *obj;
+		short port;
 
 		if (net_stream_listen(&cio->listensock[i],
-				      (short *)&cio->listenport[i]) < 0) {
+				      &port) < 0) {
 			fatal("unable to initialize stdio listen socket: %m");
 		}
+		cio->listenport[i] = ntohs(port);
 		debug("initialized stdio listening socket, port %d\n",
 		      ntohs(cio->listenport[i]));
 		/*net_set_low_water(cio->listensock[i], 140);*/
diff --git a/src/api/step_launch.c b/src/api/step_launch.c
index 321c4446752..a9b2e8277a1 100644
--- a/src/api/step_launch.c
+++ b/src/api/step_launch.c
@@ -228,7 +228,7 @@ int slurm_step_launch (slurm_step_ctx ctx,
 	launch.io_port = xmalloc(sizeof(uint16_t) * launch.num_io_port);
 	for (i = 0; i < launch.num_io_port; i++) {
 		launch.io_port[i] =
-			ntohs(ctx->launch_state->client_io->listenport[i]);
+			ctx->launch_state->client_io->listenport[i];
 	}
 	
 	launch.num_resp_port = ctx->launch_state->num_resp_port;
diff --git a/src/srun/launch.c b/src/srun/launch.c
index ae88be750db..19915c1dc37 100644
--- a/src/srun/launch.c
+++ b/src/srun/launch.c
@@ -197,7 +197,7 @@ launch(void *arg)
 	r.num_io_port = job->client_io->num_listen;
 	r.io_port = xmalloc(sizeof(uint16_t) * r.num_io_port);
 	for (i = 0; i < r.num_io_port; i++) {
-		r.io_port[i] = ntohs(job->client_io->listenport[i]);
+		r.io_port[i] = job->client_io->listenport[i];
 	}
 
 	msg_array_ptr[0].msg_type = REQUEST_LAUNCH_TASKS;
diff --git a/src/srun/reattach.c b/src/srun/reattach.c
index e0419d0dfd5..9a727315b53 100644
--- a/src/srun/reattach.c
+++ b/src/srun/reattach.c
@@ -333,8 +333,8 @@ _attach_to_job(srun_job_t *job)
 		r->job_step_id     = job->stepid;
 		r->num_io_port     = 1;
 		r->io_port         = (uint16_t *)xmalloc(sizeof(uint16_t));
-		r->io_port[0]      = ntohs(job->client_io->listenport[
-					   i%job->client_io->num_listen]);
+		r->io_port[0]      = job->client_io->listenport[
+					   i%job->client_io->num_listen];
 		r->num_resp_port   = 1;
 		r->resp_port	   = (uint16_t *)xmalloc(sizeof(uint16_t));
 		r->resp_port[0]    = ntohs(job->jaddr[i%job->njfds].sin_port);
-- 
GitLab