diff options
author | Amitay Isaacs <amitay@gmail.com> | 2014-06-10 17:04:34 +1000 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2014-06-12 05:40:10 +0200 |
commit | 507207e40b193ba753604666c56dfa29c29b7145 (patch) | |
tree | 748e4cae54252ba849a398bba6c66b53dff50623 | |
parent | 8c8ef5640e17c1acbda99921277a41442bcc4801 (diff) | |
download | samba-507207e40b193ba753604666c56dfa29c29b7145.tar.gz samba-507207e40b193ba753604666c56dfa29c29b7145.tar.xz samba-507207e40b193ba753604666c56dfa29c29b7145.zip |
ctdb-common: Move lockdown_memory to system utilities
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
-rw-r--r-- | ctdb/common/ctdb_util.c | 27 | ||||
-rw-r--r-- | ctdb/common/system_util.c | 28 |
2 files changed, 28 insertions, 27 deletions
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c index 94051a4818a..21315ecdae6 100644 --- a/ctdb/common/ctdb_util.c +++ b/ctdb/common/ctdb_util.c @@ -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", diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c index 4f6401690b3..d2d9b31e820 100644 --- a/ctdb/common/system_util.c +++ b/ctdb/common/system_util.c @@ -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]; |