Move the cleanup code from the signal handlers down to the new emergency handlers for the ue, epc and enb.

master
faluco 3 years ago committed by Andre Puschmann
parent 2c1e9c0c55
commit 9075251627

@ -31,22 +31,13 @@ extern "C" {
#define SRSRAN_TERM_TIMEOUT_S (5) #define SRSRAN_TERM_TIMEOUT_S (5)
// static vars required by signal handling // static vars required by signal handling
static srslog::sink* log_sink = nullptr; static std::atomic<bool> running = {true};
static std::atomic<bool> running = {true};
void srsran_dft_exit();
static void srsran_signal_handler(int signal) static void srsran_signal_handler(int signal)
{ {
switch (signal) { switch (signal) {
case SIGALRM: case SIGALRM:
fprintf(stderr, "Couldn't stop after %ds. Forcing exit.\n", SRSRAN_TERM_TIMEOUT_S); fprintf(stderr, "Couldn't stop after %ds. Forcing exit.\n", SRSRAN_TERM_TIMEOUT_S);
srslog::flush();
//: TODO: refactor the sighandler, should not depend on log utilities
if (log_sink) {
log_sink->flush();
}
srsran_dft_exit();
execute_emergency_cleanup_handlers(); execute_emergency_cleanup_handlers();
raise(SIGKILL); raise(SIGKILL);
default: default:

@ -45,8 +45,9 @@ namespace bpo = boost::program_options;
/********************************************************************** /**********************************************************************
* Program arguments processing * Program arguments processing
***********************************************************************/ ***********************************************************************/
string config_file; string config_file;
static bool stdout_ts_enable = false; static bool stdout_ts_enable = false;
static srslog::sink* log_sink = nullptr;
void parse_args(all_args_t* args, int argc, char* argv[]) void parse_args(all_args_t* args, int argc, char* argv[])
{ {
@ -534,9 +535,21 @@ static size_t fixup_log_file_maxsize(int x)
return (x < 0) ? 0 : size_t(x) * 1024u; return (x < 0) ? 0 : size_t(x) * 1024u;
} }
extern "C" void srsran_dft_exit();
static void emergency_cleanup_handler(void* data)
{
srslog::flush();
if (log_sink) {
log_sink->flush();
}
srsran_dft_exit();
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
srsran_register_signal_handler(); srsran_register_signal_handler();
add_emergency_cleanup_handler(emergency_cleanup_handler, nullptr);
all_args_t args = {}; all_args_t args = {};
srsran::metrics_hub<enb_metrics_t> metricshub; srsran::metrics_hub<enb_metrics_t> metricshub;
metrics_stdout metrics_screen; metrics_stdout metrics_screen;

@ -55,6 +55,8 @@ typedef struct {
log_args_t log_args; log_args_t log_args;
} all_args_t; } all_args_t;
static srslog::sink* log_sink = nullptr;
/********************************************************************** /**********************************************************************
* Program arguments processing * Program arguments processing
***********************************************************************/ ***********************************************************************/
@ -261,18 +263,18 @@ void parse_args(all_args_t* args, int argc, char* argv[])
cout << "Using default mme.integrity_algo: EIA1" << endl; cout << "Using default mme.integrity_algo: EIA1" << endl;
} }
args->mme_args.s1ap_args.mme_bind_addr = mme_bind_addr; args->mme_args.s1ap_args.mme_bind_addr = mme_bind_addr;
args->mme_args.s1ap_args.mme_name = mme_name; args->mme_args.s1ap_args.mme_name = mme_name;
args->mme_args.s1ap_args.dns_addr = dns_addr; args->mme_args.s1ap_args.dns_addr = dns_addr;
args->mme_args.s1ap_args.full_net_name = full_net_name; args->mme_args.s1ap_args.full_net_name = full_net_name;
args->mme_args.s1ap_args.short_net_name = short_net_name; args->mme_args.s1ap_args.short_net_name = short_net_name;
args->mme_args.s1ap_args.mme_apn = mme_apn; args->mme_args.s1ap_args.mme_apn = mme_apn;
args->mme_args.s1ap_args.paging_timer = paging_timer; args->mme_args.s1ap_args.paging_timer = paging_timer;
args->spgw_args.gtpu_bind_addr = spgw_bind_addr; args->spgw_args.gtpu_bind_addr = spgw_bind_addr;
args->spgw_args.sgi_if_addr = sgi_if_addr; args->spgw_args.sgi_if_addr = sgi_if_addr;
args->spgw_args.sgi_if_name = sgi_if_name; args->spgw_args.sgi_if_name = sgi_if_name;
args->spgw_args.max_paging_queue = max_paging_queue; args->spgw_args.max_paging_queue = max_paging_queue;
args->hss_args.db_file = hss_db_file; args->hss_args.db_file = hss_db_file;
// Apply all_level to any unset layers // Apply all_level to any unset layers
if (vm.count("log.all_level")) { if (vm.count("log.all_level")) {
@ -353,9 +355,18 @@ std::string get_build_string()
return ss.str(); return ss.str();
} }
static void emergency_cleanup_handler(void* data)
{
srslog::flush();
if (log_sink) {
log_sink->flush();
}
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
srsran_register_signal_handler(); srsran_register_signal_handler();
add_emergency_cleanup_handler(emergency_cleanup_handler, nullptr);
// print build info // print build info
cout << endl << get_build_string() << endl; cout << endl << get_build_string() << endl;

@ -47,6 +47,7 @@ namespace bpo = boost::program_options;
static bool do_metrics = false; static bool do_metrics = false;
static metrics_stdout* metrics_screen = nullptr; static metrics_stdout* metrics_screen = nullptr;
static srslog::sink* log_sink = nullptr;
/********************************************************************** /**********************************************************************
* Program arguments processing * Program arguments processing
@ -656,9 +657,20 @@ static size_t fixup_log_file_maxsize(int x)
return (x < 0) ? 0 : size_t(x) * 1024u; return (x < 0) ? 0 : size_t(x) * 1024u;
} }
extern "C" void srsran_dft_exit();
static void emergency_cleanup_handler(void* data)
{
srslog::flush();
if (log_sink) {
log_sink->flush();
}
srsran_dft_exit();
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
srsran_register_signal_handler(); srsran_register_signal_handler();
add_emergency_cleanup_handler(emergency_cleanup_handler, nullptr);
srsran_debug_handle_crash(argc, argv); srsran_debug_handle_crash(argc, argv);
all_args_t args = {}; all_args_t args = {};

Loading…
Cancel
Save