From fd264dc1175efad9a274b03150f21a0a9e77dea7 Mon Sep 17 00:00:00 2001
From: Mark Grondona <mgrondona@llnl.gov>
Date: Wed, 2 Jun 2004 22:28:57 +0000
Subject: [PATCH]  o move mlockall() call after daemonization

---
 NEWS                |  1 +
 src/slurmd/slurmd.c | 27 ++++++++++++++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/NEWS b/NEWS
index e1d693c8fd9..d085da59356 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ documents those changes that are of interest to users and admins.
  -- If slurmd can't respond to ping (e.g. paging is keeping it from 
     responding in a timely fashion) then send a registration RPC
     to slurmctld.
+ -- Fix slurmd -M option to call mlockall() after daemonizing.
  -- Add "slurm_" prefix to slurm's hostlist_ function man pages.
  -- More AIX support added.
  -- Change get info calls from using show_all to more general show_flags
diff --git a/src/slurmd/slurmd.c b/src/slurmd/slurmd.c
index 3f90e9b6125..1badc7fb5e4 100644
--- a/src/slurmd/slurmd.c
+++ b/src/slurmd/slurmd.c
@@ -166,6 +166,20 @@ main (int argc, char *argv[])
 
 	_kill_old_slurmd();
 
+	if (conf->mlock_pages) {
+		/*
+		 * Call mlockall() if available to ensure slurmd
+		 *  doesn't get swapped out
+		 */
+#ifdef _POSIX_MEMLOCK
+		if (mlockall (MCL_FUTURE | MCL_CURRENT) < 0)
+			error ("failed to mlock() slurmd pages: %m");
+#else
+		error ("mlockall() system call does not appear to be available");
+#endif /* _POSIX_MEMLOCK */
+	}
+
+
 	/* 
 	 * Restore any saved revoked credential information
 	 */
@@ -660,19 +674,6 @@ _slurmd_init()
 		shm_cleanup();
 	}
 
-	if (conf->mlock_pages) {
-		/*
-		 * Call mlockall() if available to ensure slurmd
-		 *  doesn't get swapped out
-		 */
-#ifdef _POSIX_MEMLOCK
-		if (mlockall (MCL_FUTURE | MCL_CURRENT) < 0)
-			error ("failed to mlock() slurmd pages: %m");
-#else
-		error ("mlockall() system call does not appear to be available");
-#endif /* _POSIX_MEMLOCK */
-	}
-
 	/*
 	 * Initialize slurmd shared memory
 	 *  This *must* be called after _set_slurmd_spooldir()
-- 
GitLab