aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-11-16 11:08:07 +0200
committerRiccardo Spagni <ric@spagni.net>2018-11-16 11:08:07 +0200
commit9aff9a5372fb243757b22dd94874e155d2fd8083 (patch)
treec729f3b6b40da528ded04bc6df22115cb5025c66
parentMerge pull request #4789 (diff)
parentwallet: warn if lockable memory limit is too low (diff)
downloadmonero-9aff9a5372fb243757b22dd94874e155d2fd8083.tar.xz
Merge pull request #4790
177a9d76 wallet: warn if lockable memory limit is too low (moneromooo-monero)
-rw-r--r--src/common/util.cpp15
-rw-r--r--src/common/util.h2
-rw-r--r--src/wallet/wallet_args.cpp8
3 files changed, 25 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 43973c511..58b0d8210 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -728,6 +728,21 @@ std::string get_nix_version_display_string()
return true;
}
+ ssize_t get_lockable_memory()
+ {
+#ifdef __GLIBC__
+ struct rlimit rlim;
+ if (getrlimit(RLIMIT_MEMLOCK, &rlim) < 0)
+ {
+ MERROR("Failed to determine the lockable memory limit");
+ return -1;
+ }
+ return rlim.rlim_cur;
+#else
+ return -1;
+#endif
+ }
+
bool on_startup()
{
mlog_configure("", true);
diff --git a/src/common/util.h b/src/common/util.h
index e793a42b5..1c5c5f4e7 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -221,6 +221,8 @@ namespace tools
void set_strict_default_file_permissions(bool strict);
+ ssize_t get_lockable_memory();
+
void set_max_concurrency(unsigned n);
unsigned get_max_concurrency();
diff --git a/src/wallet/wallet_args.cpp b/src/wallet/wallet_args.cpp
index 95a4e0ad6..b9d0a6a75 100644
--- a/src/wallet/wallet_args.cpp
+++ b/src/wallet/wallet_args.cpp
@@ -211,6 +211,14 @@ namespace wallet_args
Print(print) << boost::format(wallet_args::tr("Logging to %s")) % log_path;
+ const ssize_t lockable_memory = tools::get_lockable_memory();
+ if (lockable_memory >= 0 && lockable_memory < 256 * 4096) // 256 pages -> at least 256 secret keys and other such small/medium objects
+ Print(print) << tr("WARNING: You may not have a high enough lockable memory limit")
+#ifdef ELPP_OS_UNIX
+ << ", " << tr("see ulimit -l")
+#endif
+ ;
+
return {std::move(vm), should_terminate};
}
}