mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 06:43:28 +01:00
Merge pull request #4790
177a9d76
wallet: warn if lockable memory limit is too low (moneromooo-monero)
This commit is contained in:
commit
9aff9a5372
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user