mirror of
https://github.com/matrix-construct/construct
synced 2024-09-29 12:18:54 +02:00
ircd: Move sys/resource / coredump related out of libircd.
This commit is contained in:
parent
8acdf52443
commit
84bbeecc83
3 changed files with 44 additions and 45 deletions
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <ircd/ircd.h>
|
#include <ircd/ircd.h>
|
||||||
#include <ircd/asio.h>
|
#include <ircd/asio.h>
|
||||||
|
#include <RB_INC_SYS_RESOURCE_H
|
||||||
#include "lgetopt.h"
|
#include "lgetopt.h"
|
||||||
#include "charybdis.h"
|
#include "charybdis.h"
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ namespace fs = ircd::fs;
|
||||||
|
|
||||||
static void sigfd_handler(const boost::system::error_code &, int);
|
static void sigfd_handler(const boost::system::error_code &, int);
|
||||||
static bool startup_checks();
|
static bool startup_checks();
|
||||||
|
static void enable_coredumps();
|
||||||
static void print_version();
|
static void print_version();
|
||||||
|
|
||||||
const char *const fatalerrstr
|
const char *const fatalerrstr
|
||||||
|
@ -90,6 +92,11 @@ try
|
||||||
if(!startup_checks())
|
if(!startup_checks())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
// cores are not dumped without consent of the user to maintain the privacy
|
||||||
|
// of cryptographic key material in memory at the time of the crash.
|
||||||
|
if(RB_DEBUG_LEVEL || ircd::debugmode)
|
||||||
|
enable_coredumps();
|
||||||
|
|
||||||
if(printversion)
|
if(printversion)
|
||||||
{
|
{
|
||||||
print_version();
|
print_version();
|
||||||
|
@ -213,6 +220,32 @@ catch(const std::exception &e)
|
||||||
|
|
||||||
static void handle_usr2();
|
static void handle_usr2();
|
||||||
static void handle_usr1();
|
static void handle_usr1();
|
||||||
|
void
|
||||||
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
|
enable_coredumps()
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Setup corefile size immediately after boot -kre
|
||||||
|
//
|
||||||
|
|
||||||
|
rlimit rlim; // resource limits
|
||||||
|
ircd::syscall(getrlimit, RLIMIT_CORE, &rlim);
|
||||||
|
|
||||||
|
// Set corefilesize to maximum
|
||||||
|
rlim.rlim_cur = rlim.rlim_max;
|
||||||
|
ircd::syscall(setrlimit, RLIMIT_CORE, &rlim);
|
||||||
|
}
|
||||||
|
catch(const std::exception &e)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to adjust rlimit: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
enable_coredumps()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void handle_quit();
|
static void handle_quit();
|
||||||
static void handle_interruption();
|
static void handle_interruption();
|
||||||
static void handle_termstop();
|
static void handle_termstop();
|
||||||
|
|
|
@ -45,14 +45,12 @@
|
||||||
// Generated by ./configure
|
// Generated by ./configure
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#include <RB_INC_ASSERT_H
|
#include <RB_INC_ASSERT_H
|
||||||
#include <RB_INC_STDARG_H
|
#include <RB_INC_STDARG_H
|
||||||
#include <RB_INC_SYS_TIME_H
|
#include <RB_INC_SYS_TIME_H
|
||||||
#include <RB_INC_SYS_RESOURCE_H
|
}
|
||||||
|
|
||||||
} // extern "C"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define WIN32_LEAN_AND_MEAN 1
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
|
32
ircd/ircd.cc
32
ircd/ircd.cc
|
@ -44,7 +44,6 @@ namespace ircd
|
||||||
ctx::ctx *main_context; // Main program loop
|
ctx::ctx *main_context; // Main program loop
|
||||||
bool debugmode; // meaningful ifdef RB_DEBUG
|
bool debugmode; // meaningful ifdef RB_DEBUG
|
||||||
|
|
||||||
void enable_coredumps();
|
|
||||||
std::string read_conf(std::string file);
|
std::string read_conf(std::string file);
|
||||||
void set_runlevel(const enum runlevel &);
|
void set_runlevel(const enum runlevel &);
|
||||||
void at_main_exit() noexcept;
|
void at_main_exit() noexcept;
|
||||||
|
@ -114,11 +113,6 @@ try
|
||||||
throw error("Cannot init() IRCd from runlevel %s",
|
throw error("Cannot init() IRCd from runlevel %s",
|
||||||
reflect(runlevel));
|
reflect(runlevel));
|
||||||
|
|
||||||
// cores are not dumped without consent of the user to maintain the privacy
|
|
||||||
// of cryptographic key material in memory at the time of the crash.
|
|
||||||
if(RB_DEBUG_LEVEL || debugmode)
|
|
||||||
enable_coredumps();
|
|
||||||
|
|
||||||
// Samples the thread this context was executed on which should be where
|
// Samples the thread this context was executed on which should be where
|
||||||
// the user ran ios.run(). The user may have invoked ios.run() on multiple
|
// the user ran ios.run(). The user may have invoked ios.run() on multiple
|
||||||
// threads, but we consider this one thread a main thread for now...
|
// threads, but we consider this one thread a main thread for now...
|
||||||
|
@ -443,32 +437,6 @@ catch(const std::exception &e)
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
#ifdef HAVE_SYS_RESOURCE_H
|
|
||||||
ircd::enable_coredumps()
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Setup corefile size immediately after boot -kre
|
|
||||||
//
|
|
||||||
|
|
||||||
rlimit rlim; // resource limits
|
|
||||||
syscall(getrlimit, RLIMIT_CORE, &rlim);
|
|
||||||
|
|
||||||
// Set corefilesize to maximum
|
|
||||||
rlim.rlim_cur = rlim.rlim_max;
|
|
||||||
syscall(setrlimit, RLIMIT_CORE, &rlim);
|
|
||||||
}
|
|
||||||
catch(const std::exception &e)
|
|
||||||
{
|
|
||||||
std::cerr << "Failed to adjust rlimit: " << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
ircd::enable_coredumps()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// namespace ircd {
|
// namespace ircd {
|
||||||
|
|
||||||
/* /quote set variables */
|
/* /quote set variables */
|
||||||
|
|
Loading…
Reference in a new issue