ctdb-common: Move lockdown_memory to system utilities
authorAmitay Isaacs <amitay@gmail.com>
Tue, 10 Jun 2014 07:04:34 +0000 (17:04 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 12 Jun 2014 03:40:10 +0000 (05:40 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/common/ctdb_util.c
ctdb/common/system_util.c

index 94051a4818af12e19bc31d37b797180f9a39bbdf..21315ecdae6bd357c760d4c800db71fd88812a1a 100644 (file)
@@ -22,7 +22,6 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "system/wait.h"
-#include "system/shmem.h"
 #include "../include/ctdb_private.h"
 
 /*
@@ -404,32 +403,6 @@ unsigned ctdb_addr_to_port(ctdb_sock_addr *addr)
        return 0;
 }
 
-/* we don't lock future pages here; it would increase the chance that
- * we'd fail to mmap later on. */
-void lockdown_memory(bool valgrinding)
-{
-#if defined(HAVE_MLOCKALL) && !defined(_AIX_)
-       /* Extra stack, please! */
-       char dummy[10000];
-       memset(dummy, 0, sizeof(dummy));
-
-       if (valgrinding) {
-               return;
-       }
-
-       /* Ignore when running in local daemons mode */
-       if (getuid() != 0) {
-               return;
-       }
-
-       /* Avoid compiler optimizing out dummy. */
-       mlock(dummy, sizeof(dummy));
-       if (mlockall(MCL_CURRENT) != 0) {
-               DEBUG(DEBUG_WARNING,("Failed to lockdown memory: %s'\n",
-                                    strerror(errno)));
-       }
-#endif
-}
 
 const char *ctdb_eventscript_call_names[] = {
        "init",
index 4f6401690b3a3824e0bcb53047701c24d46a9830..d2d9b31e82044ffaf6e127e83db42e5dfa7d5327 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "includes.h"
 #include "system/filesys.h"
+#include "system/shmem.h"
 
 #include <libgen.h>
 
@@ -275,6 +276,33 @@ bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
        return ret;
 }
 
+/* we don't lock future pages here; it would increase the chance that
+ * we'd fail to mmap later on. */
+void lockdown_memory(bool valgrinding)
+{
+#if defined(HAVE_MLOCKALL) && !defined(_AIX_)
+       /* Extra stack, please! */
+       char dummy[10000];
+       memset(dummy, 0, sizeof(dummy));
+
+       if (valgrinding) {
+               return;
+       }
+
+       /* Ignore when running in local daemons mode */
+       if (getuid() != 0) {
+               return;
+       }
+
+       /* Avoid compiler optimizing out dummy. */
+       mlock(dummy, sizeof(dummy));
+       if (mlockall(MCL_CURRENT) != 0) {
+               DEBUG(DEBUG_WARNING,("Failed to lockdown memory: %s'\n",
+                                    strerror(errno)));
+       }
+#endif
+}
+
 int mkdir_p(const char *dir, int mode)
 {
        char t[PATH_MAX];