From 105d26bdfd0fdabf52f09a9ac5048ce2de5db40b Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Tue, 30 Apr 2019 13:49:49 -0600
Subject: [PATCH] Continuation of 2f162b7a7addf044

Since the slurmd will change an older protocol version to the current
version we need to make sure if an old srun sends a message we handle
things correctly.
---
 src/common/slurm_protocol_pack.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c
index 4092a9b4c98..976871a59bb 100644
--- a/src/common/slurm_protocol_pack.c
+++ b/src/common/slurm_protocol_pack.c
@@ -10167,9 +10167,14 @@ static void _pack_launch_tasks_request_msg(launch_tasks_request_msg_t *msg,
 				     buffer);
 		}
 		pack32(msg->pack_ntasks, buffer);
-		if (msg->pack_ntasks != NO_VAL)
+		if ((msg->pack_ntasks != NO_VAL) && msg->pack_tid_offsets) {
+			/* pack_tids == NULL if request from pre-v19.05 srun */
+			pack8((uint8_t) 1, buffer);
 			for (i = 0; i < msg->pack_ntasks; i++)
 				pack32(msg->pack_tid_offsets[i], buffer);
+		} else if (msg->pack_ntasks != NO_VAL)
+			pack8((uint8_t) 0, buffer);
+
 		pack32(msg->pack_offset, buffer);
 		pack32(msg->pack_step_cnt, buffer);
 		pack32(msg->pack_task_offset, buffer);
@@ -10479,7 +10484,9 @@ static int _unpack_launch_tasks_request_msg(launch_tasks_request_msg_t **msg_ptr
 				goto unpack_error;
 		}
 		safe_unpack32(&msg->pack_ntasks, buffer);
-		if (msg->pack_ntasks != NO_VAL) {
+		if (msg->pack_ntasks != NO_VAL)
+			safe_unpack8(&uint8_tmp, buffer);
+		if ((msg->pack_ntasks != NO_VAL) && (uint8_tmp == 1)) {
 			safe_xcalloc(msg->pack_tid_offsets, msg->pack_ntasks,
 				     sizeof(uint32_t));
 			for (i = 0; i < msg->pack_ntasks; i++)
-- 
GitLab