Modules fork: improve SIGUSR1 handling, fix include.
We can't expect SIGUSR1 to have any specific value range, so let's define an exit code that we can handle in a special way. This also fixes an #include <wait.h> that is not standard.
This commit is contained in:
parent
80ab4ce38b
commit
e885d74018
@ -31,7 +31,7 @@
|
|||||||
#include "cluster.h"
|
#include "cluster.h"
|
||||||
#include "rdb.h"
|
#include "rdb.h"
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#define REDISMODULE_CORE 1
|
#define REDISMODULE_CORE 1
|
||||||
#include "redismodule.h"
|
#include "redismodule.h"
|
||||||
|
14
src/server.c
14
src/server.c
@ -1913,8 +1913,11 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
|
|||||||
if (WIFSIGNALED(statloc)) bysignal = WTERMSIG(statloc);
|
if (WIFSIGNALED(statloc)) bysignal = WTERMSIG(statloc);
|
||||||
|
|
||||||
/* sigKillChildHandler catches the signal and calls exit(), but we
|
/* sigKillChildHandler catches the signal and calls exit(), but we
|
||||||
* must make sure not to flag lastbgsave_status, etc incorrectly. */
|
* must make sure not to flag lastbgsave_status, etc incorrectly.
|
||||||
if (exitcode == SIGUSR1) {
|
* We could directly terminate the child process via SIGUSR1
|
||||||
|
* without handling it, but in this case Valgrind will log an
|
||||||
|
* annoying error. */
|
||||||
|
if (exitcode == SERVER_CHILD_NOERROR_RETVAL) {
|
||||||
bysignal = SIGUSR1;
|
bysignal = SIGUSR1;
|
||||||
exitcode = 1;
|
exitcode = 1;
|
||||||
}
|
}
|
||||||
@ -4618,11 +4621,14 @@ void setupSignalHandlers(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is the signal handler for children process. It is currently useful
|
||||||
|
* in order to track the SIGUSR1, that we send to a child in order to terminate
|
||||||
|
* it in a clean way, without the parent detecting an error and stop
|
||||||
|
* accepting writes because of a write error condition. */
|
||||||
static void sigKillChildHandler(int sig) {
|
static void sigKillChildHandler(int sig) {
|
||||||
UNUSED(sig);
|
UNUSED(sig);
|
||||||
/* this handler is needed to resolve a valgrind warning */
|
|
||||||
serverLogFromHandler(LL_WARNING, "Received SIGUSR1 in child, exiting now.");
|
serverLogFromHandler(LL_WARNING, "Received SIGUSR1 in child, exiting now.");
|
||||||
exitFromChild(SIGUSR1);
|
exitFromChild(SERVER_CHILD_NOERROR_RETVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupChildSignalHandlers(void) {
|
void setupChildSignalHandlers(void) {
|
||||||
|
@ -179,6 +179,14 @@ typedef long long mstime_t; /* millisecond time type. */
|
|||||||
#define ACTIVE_EXPIRE_CYCLE_SLOW 0
|
#define ACTIVE_EXPIRE_CYCLE_SLOW 0
|
||||||
#define ACTIVE_EXPIRE_CYCLE_FAST 1
|
#define ACTIVE_EXPIRE_CYCLE_FAST 1
|
||||||
|
|
||||||
|
/* Children process will exit with this status code to signal that the
|
||||||
|
* process terminated without an error: this is useful in order to kill
|
||||||
|
* a saving child (RDB or AOF one), without triggering in the parent the
|
||||||
|
* write protection that is normally turned on on write errors.
|
||||||
|
* Usually children that are terminated with SIGUSR1 will exit with this
|
||||||
|
* special code. */
|
||||||
|
#define SERVER_CHILD_NOERROR_RETVAL 255
|
||||||
|
|
||||||
/* Instantaneous metrics tracking. */
|
/* Instantaneous metrics tracking. */
|
||||||
#define STATS_METRIC_SAMPLES 16 /* Number of samples per metric. */
|
#define STATS_METRIC_SAMPLES 16 /* Number of samples per metric. */
|
||||||
#define STATS_METRIC_COMMAND 0 /* Number of commands executed. */
|
#define STATS_METRIC_COMMAND 0 /* Number of commands executed. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user