Commit 2ae5802c authored by Geoff Simmons's avatar Geoff Simmons

add a signal handler to tell VSL to flush pending transactions

parent d3884da5
...@@ -99,7 +99,7 @@ static unsigned long seen = 0, submitted = 0, len_overflows = 0, no_data = 0, ...@@ -99,7 +99,7 @@ static unsigned long seen = 0, submitted = 0, len_overflows = 0, no_data = 0,
static volatile sig_atomic_t flush = 0, term = 0; static volatile sig_atomic_t flush = 0, term = 0;
static struct sigaction terminate_action, dump_action; static struct sigaction terminate_action, dump_action, flush_action;
/* Local freelist */ /* Local freelist */
static struct freehead_s reader_freelist = static struct freehead_s reader_freelist =
...@@ -140,6 +140,14 @@ term_s(int sig) ...@@ -140,6 +140,14 @@ term_s(int sig)
flush = 1; flush = 1;
} }
static void
sigflush(int sig)
{
flush = 1;
LOG_Log(LOG_NOTICE, "Received signal %d (%s), "
"flushing pending transactions", sig, strsignal(sig));
}
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
/* efficiently retrieve a single data entry */ /* efficiently retrieve a single data entry */
...@@ -487,6 +495,10 @@ CHILD_Main(int readconfig) ...@@ -487,6 +495,10 @@ CHILD_Main(int readconfig)
AZ(sigemptyset(&terminate_action.sa_mask)); AZ(sigemptyset(&terminate_action.sa_mask));
terminate_action.sa_flags &= ~SA_RESTART; terminate_action.sa_flags &= ~SA_RESTART;
flush_action.sa_handler = sigflush;
AZ(sigemptyset(&flush_action.sa_mask));
flush_action.sa_flags |= SA_RESTART;
#define CHILD(SIG,disp) SIGDISP(SIG,disp) #define CHILD(SIG,disp) SIGDISP(SIG,disp)
#define PARENT(SIG,disp) ((void) 0) #define PARENT(SIG,disp) ((void) 0)
#include "signals.h" #include "signals.h"
......
...@@ -44,7 +44,7 @@ CHILD(SIGTERM, terminate_action); ...@@ -44,7 +44,7 @@ CHILD(SIGTERM, terminate_action);
CHILD(SIGINT, terminate_action); CHILD(SIGINT, terminate_action);
CHILD(SIGUSR1, dump_action); CHILD(SIGUSR1, dump_action);
CHILD(SIGUSR2, ignore_action); CHILD(SIGUSR2, ignore_action);
CHILD(SIGHUP, ignore_action); CHILD(SIGHUP, flush_action);
#ifndef DISABLE_STACKTRACE #ifndef DISABLE_STACKTRACE
CHILD(SIGABRT, stacktrace_action); CHILD(SIGABRT, stacktrace_action);
CHILD(SIGSEGV, stacktrace_action); CHILD(SIGSEGV, stacktrace_action);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment