Function renamed hasForkChild() -> hasActiveChildProcess().

This commit is contained in:
antirez 2019-09-27 12:03:09 +02:00
parent 82845f8d04
commit de1f82aa33
8 changed files with 21 additions and 21 deletions

View File

@ -264,7 +264,7 @@ int startAppendOnly(void) {
strerror(errno)); strerror(errno));
return C_ERR; return C_ERR;
} }
if (hasForkChild() && server.aof_child_pid == -1) { if (hasActiveChildProcess() && server.aof_child_pid == -1) {
server.aof_rewrite_scheduled = 1; server.aof_rewrite_scheduled = 1;
serverLog(LL_WARNING,"AOF was enabled but there is already another background operation. An AOF background was scheduled to start when possible."); serverLog(LL_WARNING,"AOF was enabled but there is already another background operation. An AOF background was scheduled to start when possible.");
} else { } else {
@ -395,7 +395,7 @@ void flushAppendOnlyFile(int force) {
* useful for graphing / monitoring purposes. */ * useful for graphing / monitoring purposes. */
if (sync_in_progress) { if (sync_in_progress) {
latencyAddSampleIfNeeded("aof-write-pending-fsync",latency); latencyAddSampleIfNeeded("aof-write-pending-fsync",latency);
} else if (hasForkChild()) { } else if (hasActiveChildProcess()) {
latencyAddSampleIfNeeded("aof-write-active-child",latency); latencyAddSampleIfNeeded("aof-write-active-child",latency);
} else { } else {
latencyAddSampleIfNeeded("aof-write-alone",latency); latencyAddSampleIfNeeded("aof-write-alone",latency);
@ -491,7 +491,7 @@ void flushAppendOnlyFile(int force) {
try_fsync: try_fsync:
/* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are /* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are
* children doing I/O in the background. */ * children doing I/O in the background. */
if (server.aof_no_fsync_on_rewrite && hasForkChild()) if (server.aof_no_fsync_on_rewrite && hasActiveChildProcess())
return; return;
/* Perform the fsync if needed. */ /* Perform the fsync if needed. */
@ -1563,7 +1563,7 @@ void aofClosePipes(void) {
int rewriteAppendOnlyFileBackground(void) { int rewriteAppendOnlyFileBackground(void) {
pid_t childpid; pid_t childpid;
if (hasForkChild()) return C_ERR; if (hasActiveChildProcess()) return C_ERR;
if (aofCreatePipes() != C_OK) return C_ERR; if (aofCreatePipes() != C_OK) return C_ERR;
openChildInfoPipe(); openChildInfoPipe();
if ((childpid = redisFork()) == 0) { if ((childpid = redisFork()) == 0) {
@ -1607,7 +1607,7 @@ int rewriteAppendOnlyFileBackground(void) {
void bgrewriteaofCommand(client *c) { void bgrewriteaofCommand(client *c) {
if (server.aof_child_pid != -1) { if (server.aof_child_pid != -1) {
addReplyError(c,"Background append only file rewriting already in progress"); addReplyError(c,"Background append only file rewriting already in progress");
} else if (hasForkChild()) { } else if (hasActiveChildProcess()) {
server.aof_rewrite_scheduled = 1; server.aof_rewrite_scheduled = 1;
addReplyStatus(c,"Background append only file rewriting scheduled"); addReplyStatus(c,"Background append only file rewriting scheduled");
} else if (rewriteAppendOnlyFileBackground() == C_OK) { } else if (rewriteAppendOnlyFileBackground() == C_OK) {

View File

@ -60,7 +60,7 @@ robj *lookupKey(redisDb *db, robj *key, int flags) {
/* Update the access time for the ageing algorithm. /* Update the access time for the ageing algorithm.
* Don't do it if we have a saving child, as this will trigger * Don't do it if we have a saving child, as this will trigger
* a copy on write madness. */ * a copy on write madness. */
if (!hasForkChild() && !(flags & LOOKUP_NOTOUCH)){ if (!hasActiveChildProcess() && !(flags & LOOKUP_NOTOUCH)){
if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) { if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) {
updateLFU(val); updateLFU(val);
} else { } else {

View File

@ -1039,7 +1039,7 @@ void activeDefragCycle(void) {
mstime_t latency; mstime_t latency;
int quit = 0; int quit = 0;
if (hasForkChild()) if (hasActiveChildProcess())
return; /* Defragging memory while there's a fork will just do damage. */ return; /* Defragging memory while there's a fork will just do damage. */
/* Once a second, check if we the fragmentation justfies starting a scan /* Once a second, check if we the fragmentation justfies starting a scan

View File

@ -5157,7 +5157,7 @@ int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos)
int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data)
{ {
pid_t childpid; pid_t childpid;
if (hasForkChild()) { if (hasActiveChildProcess()) {
return -1; return -1;
} }

View File

@ -1336,7 +1336,7 @@ werr:
int rdbSaveBackground(char *filename, rdbSaveInfo *rsi) { int rdbSaveBackground(char *filename, rdbSaveInfo *rsi) {
pid_t childpid; pid_t childpid;
if (hasForkChild()) return C_ERR; if (hasActiveChildProcess()) return C_ERR;
server.dirty_before_bgsave = server.dirty; server.dirty_before_bgsave = server.dirty;
server.lastbgsave_try = time(NULL); server.lastbgsave_try = time(NULL);
@ -2417,7 +2417,7 @@ int rdbSaveToSlavesSockets(rdbSaveInfo *rsi) {
pid_t childpid; pid_t childpid;
int pipefds[2]; int pipefds[2];
if (hasForkChild()) return C_ERR; if (hasActiveChildProcess()) return C_ERR;
/* Before to fork, create a pipe that will be used in order to /* Before to fork, create a pipe that will be used in order to
* send back to the parent the IDs of the slaves that successfully * send back to the parent the IDs of the slaves that successfully
@ -2584,7 +2584,7 @@ void bgsaveCommand(client *c) {
if (server.rdb_child_pid != -1) { if (server.rdb_child_pid != -1) {
addReplyError(c,"Background save already in progress"); addReplyError(c,"Background save already in progress");
} else if (hasForkChild()) { } else if (hasActiveChildProcess()) {
if (schedule) { if (schedule) {
server.rdb_bgsave_scheduled = 1; server.rdb_bgsave_scheduled = 1;
addReplyStatus(c,"Background saving scheduled"); addReplyStatus(c,"Background saving scheduled");

View File

@ -751,7 +751,7 @@ void syncCommand(client *c) {
/* Target is disk (or the slave is not capable of supporting /* Target is disk (or the slave is not capable of supporting
* diskless replication) and we don't have a BGSAVE in progress, * diskless replication) and we don't have a BGSAVE in progress,
* let's start one. */ * let's start one. */
if (!hasForkChild()) { if (!hasActiveChildProcess()) {
startBgsaveForReplication(c->slave_capa); startBgsaveForReplication(c->slave_capa);
} else { } else {
serverLog(LL_NOTICE, serverLog(LL_NOTICE,
@ -2930,7 +2930,7 @@ void replicationCron(void) {
* In case of diskless replication, we make sure to wait the specified * In case of diskless replication, we make sure to wait the specified
* number of seconds (according to configuration) so that other slaves * number of seconds (according to configuration) so that other slaves
* have the time to arrive before we start streaming. */ * have the time to arrive before we start streaming. */
if (!hasForkChild()) { if (!hasActiveChildProcess()) {
time_t idle, max_idle = 0; time_t idle, max_idle = 0;
int slaves_waiting = 0; int slaves_waiting = 0;
int mincapa = -1; int mincapa = -1;

View File

@ -1449,13 +1449,13 @@ int incrementallyRehash(int dbid) {
* for dict.c to resize the hash tables accordingly to the fact we have o not * for dict.c to resize the hash tables accordingly to the fact we have o not
* running childs. */ * running childs. */
void updateDictResizePolicy(void) { void updateDictResizePolicy(void) {
if (!hasForkChild()) if (!hasActiveChildProcess())
dictEnableResize(); dictEnableResize();
else else
dictDisableResize(); dictDisableResize();
} }
int hasForkChild() { int hasActiveChildProcess() {
return server.rdb_child_pid != -1 || return server.rdb_child_pid != -1 ||
server.aof_child_pid != -1 || server.aof_child_pid != -1 ||
server.module_child_pid != -1; server.module_child_pid != -1;
@ -1697,7 +1697,7 @@ void databasesCron(void) {
/* Perform hash tables rehashing if needed, but only if there are no /* Perform hash tables rehashing if needed, but only if there are no
* other processes saving the DB on disk. Otherwise rehashing is bad * other processes saving the DB on disk. Otherwise rehashing is bad
* as will cause a lot of copy-on-write of memory pages. */ * as will cause a lot of copy-on-write of memory pages. */
if (!hasForkChild()) { if (!hasActiveChildProcess()) {
/* We use global counters so if we stop the computation at a given /* We use global counters so if we stop the computation at a given
* DB we'll be able to start from the successive in the next * DB we'll be able to start from the successive in the next
* cron loop iteration. */ * cron loop iteration. */
@ -1894,14 +1894,14 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* Start a scheduled AOF rewrite if this was requested by the user while /* Start a scheduled AOF rewrite if this was requested by the user while
* a BGSAVE was in progress. */ * a BGSAVE was in progress. */
if (!hasForkChild() && if (!hasActiveChildProcess() &&
server.aof_rewrite_scheduled) server.aof_rewrite_scheduled)
{ {
rewriteAppendOnlyFileBackground(); rewriteAppendOnlyFileBackground();
} }
/* Check if a background saving or AOF rewrite in progress terminated. */ /* Check if a background saving or AOF rewrite in progress terminated. */
if (hasForkChild() || ldbPendingChildren()) if (hasActiveChildProcess() || ldbPendingChildren())
{ {
int statloc; int statloc;
pid_t pid; pid_t pid;
@ -1975,7 +1975,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* Trigger an AOF rewrite if needed. */ /* Trigger an AOF rewrite if needed. */
if (server.aof_state == AOF_ON && if (server.aof_state == AOF_ON &&
!hasForkChild() && !hasActiveChildProcess() &&
server.aof_rewrite_perc && server.aof_rewrite_perc &&
server.aof_current_size > server.aof_rewrite_min_size) server.aof_current_size > server.aof_rewrite_min_size)
{ {
@ -2033,7 +2033,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
* Note: this code must be after the replicationCron() call above so * Note: this code must be after the replicationCron() call above so
* make sure when refactoring this file to keep this order. This is useful * make sure when refactoring this file to keep this order. This is useful
* because we want to give priority to RDB savings for replication. */ * because we want to give priority to RDB savings for replication. */
if (!hasForkChild() && if (!hasActiveChildProcess() &&
server.rdb_bgsave_scheduled && server.rdb_bgsave_scheduled &&
(server.unixtime-server.lastbgsave_try > CONFIG_BGSAVE_RETRY_DELAY || (server.unixtime-server.lastbgsave_try > CONFIG_BGSAVE_RETRY_DELAY ||
server.lastbgsave_status == C_OK)) server.lastbgsave_status == C_OK))

View File

@ -1818,7 +1818,7 @@ void receiveChildInfo(void);
/* Fork helpers */ /* Fork helpers */
int redisFork(); int redisFork();
int hasForkChild(); int hasActiveChildProcess();
void sendChildCOWInfo(int ptype, char *pname); void sendChildCOWInfo(int ptype, char *pname);
/* acl.c -- Authentication related prototypes. */ /* acl.c -- Authentication related prototypes. */