From 46276a1a24bc40c39f8a7016df8bbad6673c2097 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Thu, 27 Feb 2014 15:45:18 -0800
Subject: [PATCH] switch/cray: Sync global state with recovered steps

If the switch/cray global state save/restore fails, avoid re-allocating
ports based upon the job steps that we can recover
---
 src/plugins/switch/cray/switch_cray.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/plugins/switch/cray/switch_cray.c b/src/plugins/switch/cray/switch_cray.c
index 6ab942e51bd..12ea0814066 100644
--- a/src/plugins/switch/cray/switch_cray.c
+++ b/src/plugins/switch/cray/switch_cray.c
@@ -712,6 +712,12 @@ int switch_p_unpack_jobinfo(switch_jobinfo_t *switch_job, Buf buffer,
 		goto unpack_error;
 	}
 	safe_unpack32(&job->port, buffer);
+#ifdef HAVE_NATIVE_CRAY
+	/* If the libstate save/restore failed, at least make sure that we
+	 * do not re-allocate ports assigned to job steps that we recover. */
+	if ((job->port >= MIN_PORT) && (job->port <= MAX_PORT))
+		port_resv[job->port - MIN_PORT] = 1;
+#endif
 
 	if (debug_flags & DEBUG_FLAG_SWITCH) {
 		info("(%s:%d: %s) switch_jobinfo_t contents:",
-- 
GitLab