Browse Source

core file is limited by a system by default

pull/700/head
orignal 8 years ago
parent
commit
480ce6f522
  1. 2
      Config.cpp
  2. 25
      DaemonLinux.cpp
  3. 2
      docs/configuration.md

2
Config.cpp

@ -62,7 +62,7 @@ namespace config {
options_description limits("Limits options"); options_description limits("Limits options");
limits.add_options() limits.add_options()
("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - disable coredumps)") ("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - use system limit)")
("limits.openfiles", value<uint16_t>()->default_value(0), "Maximum number of open files (0 - use system default)") ("limits.openfiles", value<uint16_t>()->default_value(0), "Maximum number of open files (0 - use system default)")
("limits.transittunnels", value<uint16_t>()->default_value(2500), "Maximum active transit sessions (default:2500)") ("limits.transittunnels", value<uint16_t>()->default_value(2500), "Maximum active transit sessions (default:2500)")
; ;

25
DaemonLinux.cpp

@ -102,19 +102,22 @@ namespace i2p
LogPrint(eLogError, "Daemon: limits.openfiles exceeds system limit: ", limit.rlim_max); LogPrint(eLogError, "Daemon: limits.openfiles exceeds system limit: ", limit.rlim_max);
} }
uint32_t cfsize; i2p::config::GetOption("limits.coresize", cfsize); uint32_t cfsize; i2p::config::GetOption("limits.coresize", cfsize);
cfsize *= 1024; if (cfsize) // core file size set
getrlimit(RLIMIT_CORE, &limit); {
if (cfsize <= limit.rlim_max) { cfsize *= 1024;
limit.rlim_cur = cfsize; getrlimit(RLIMIT_CORE, &limit);
if (setrlimit(RLIMIT_CORE, &limit) != 0) { if (cfsize <= limit.rlim_max) {
LogPrint(eLogError, "Daemon: can't set max size of coredump: ", strerror(errno)); limit.rlim_cur = cfsize;
} else if (cfsize == 0) { if (setrlimit(RLIMIT_CORE, &limit) != 0) {
LogPrint(eLogInfo, "Daemon: coredumps disabled"); LogPrint(eLogError, "Daemon: can't set max size of coredump: ", strerror(errno));
} else if (cfsize == 0) {
LogPrint(eLogInfo, "Daemon: coredumps disabled");
} else {
LogPrint(eLogInfo, "Daemon: set max size of core files to ", cfsize / 1024, "Kb");
}
} else { } else {
LogPrint(eLogInfo, "Daemon: set max size of core files to ", cfsize / 1024, "Kb"); LogPrint(eLogError, "Daemon: limits.coresize exceeds system limit: ", limit.rlim_max);
} }
} else {
LogPrint(eLogError, "Daemon: limits.coresize exceeds system limit: ", limit.rlim_max);
} }
// Pidfile // Pidfile

2
docs/configuration.md

@ -88,6 +88,8 @@ All options below still possible in cmdline, but better write it in config file:
* --addressbook.subscriptions= - AddressBook subscriptions URLs, separated by comma * --addressbook.subscriptions= - AddressBook subscriptions URLs, separated by comma
* --limits.transittunnels= - Override maximum number of transit tunnels. 2500 by default * --limits.transittunnels= - Override maximum number of transit tunnels. 2500 by default
* --limits.openfiles= - Maximum size of corefile in Kb (0 - use system limit)
* --limits.coresize= - Maximum size of corefile in Kb (0 - use system limit)
Config files Config files
------------ ------------

Loading…
Cancel
Save