summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-12-08 20:53:19 +0000
committerPeter Powell <petpow@saberuk.com>2019-12-08 20:53:19 +0000
commit191ad98fb554d4c000d7048deb03f7fad91170ad (patch)
tree713cf267d860261d4538daaa26da86dbad77a2d3
parent399abe05ea337848da5d6b731217f7bb33a764f6 (diff)
Extract the core dump size increasing code to a function.
-rw-r--r--src/inspircd.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 45649810b..b3198de57 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -137,6 +137,24 @@ namespace
#endif
}
+ // Increase the size of a core dump file to improve debugging problems.
+ void IncreaseCoreDumpSize()
+ {
+#ifndef _WIN32
+ errno = 0;
+ rlimit rl;
+ if (getrlimit(RLIMIT_CORE, &rl) == -1)
+ {
+ ServerInstance->Logs->Log("STARTUP", LOG_DEFAULT, "Unable to increase core dump size: getrlimit(RLIMIT_CORE) failed: %s", strerror(errno));
+ return;
+ }
+
+ rl.rlim_cur = rl.rlim_max;
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ ServerInstance->Logs->Log("STARTUP", LOG_DEFAULT, "Unable to increase core dump size: setrlimit(RLIMIT_CORE) failed: %s", strerror(errno));
+#endif
+ }
+
// Seeds the random number generator if applicable.
void SeedRng(timespec ts)
{
@@ -233,18 +251,7 @@ bool InspIRCd::DaemonSeed()
std::cout << "InspIRCd Process ID: " << con_green << getpid() << con_reset << std::endl;
signal(SIGTERM, InspIRCd::SetSignal);
-
- rlimit rl;
- if (getrlimit(RLIMIT_CORE, &rl) == -1)
- {
- this->Logs->Log("STARTUP", LOG_DEFAULT, "Failed to getrlimit()!");
- return false;
- }
- rl.rlim_cur = rl.rlim_max;
-
- if (setrlimit(RLIMIT_CORE, &rl) == -1)
- this->Logs->Log("STARTUP", LOG_DEFAULT, "setrlimit() failed, cannot increase coredump size.");
-
+ IncreaseCoreDumpSize();
return true;
#endif
}