Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
de1f82aa
Commit
de1f82aa
authored
Sep 27, 2019
by
antirez
Browse files
Function renamed hasForkChild() -> hasActiveChildProcess().
parent
82845f8d
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
de1f82aa
...
...
@@ -264,7 +264,7 @@ int startAppendOnly(void) {
strerror
(
errno
));
return
C_ERR
;
}
if
(
has
ForkChild
()
&&
server
.
aof_child_pid
==
-
1
)
{
if
(
has
ActiveChildProcess
()
&&
server
.
aof_child_pid
==
-
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."
);
}
else
{
...
...
@@ -395,7 +395,7 @@ void flushAppendOnlyFile(int force) {
* useful for graphing / monitoring purposes. */
if
(
sync_in_progress
)
{
latencyAddSampleIfNeeded
(
"aof-write-pending-fsync"
,
latency
);
}
else
if
(
has
ForkChild
())
{
}
else
if
(
has
ActiveChildProcess
())
{
latencyAddSampleIfNeeded
(
"aof-write-active-child"
,
latency
);
}
else
{
latencyAddSampleIfNeeded
(
"aof-write-alone"
,
latency
);
...
...
@@ -491,7 +491,7 @@ void flushAppendOnlyFile(int force) {
try_fsync:
/* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are
* children doing I/O in the background. */
if
(
server
.
aof_no_fsync_on_rewrite
&&
has
ForkChild
())
if
(
server
.
aof_no_fsync_on_rewrite
&&
has
ActiveChildProcess
())
return
;
/* Perform the fsync if needed. */
...
...
@@ -1563,7 +1563,7 @@ void aofClosePipes(void) {
int
rewriteAppendOnlyFileBackground
(
void
)
{
pid_t
childpid
;
if
(
has
ForkChild
())
return
C_ERR
;
if
(
has
ActiveChildProcess
())
return
C_ERR
;
if
(
aofCreatePipes
()
!=
C_OK
)
return
C_ERR
;
openChildInfoPipe
();
if
((
childpid
=
redisFork
())
==
0
)
{
...
...
@@ -1607,7 +1607,7 @@ int rewriteAppendOnlyFileBackground(void) {
void
bgrewriteaofCommand
(
client
*
c
)
{
if
(
server
.
aof_child_pid
!=
-
1
)
{
addReplyError
(
c
,
"Background append only file rewriting already in progress"
);
}
else
if
(
has
ForkChild
())
{
}
else
if
(
has
ActiveChildProcess
())
{
server
.
aof_rewrite_scheduled
=
1
;
addReplyStatus
(
c
,
"Background append only file rewriting scheduled"
);
}
else
if
(
rewriteAppendOnlyFileBackground
()
==
C_OK
)
{
...
...
src/db.c
View file @
de1f82aa
...
...
@@ -60,7 +60,7 @@ robj *lookupKey(redisDb *db, robj *key, int flags) {
/* Update the access time for the ageing algorithm.
* Don't do it if we have a saving child, as this will trigger
* a copy on write madness. */
if
(
!
has
ForkChild
()
&&
!
(
flags
&
LOOKUP_NOTOUCH
)){
if
(
!
has
ActiveChildProcess
()
&&
!
(
flags
&
LOOKUP_NOTOUCH
)){
if
(
server
.
maxmemory_policy
&
MAXMEMORY_FLAG_LFU
)
{
updateLFU
(
val
);
}
else
{
...
...
src/defrag.c
View file @
de1f82aa
...
...
@@ -1039,7 +1039,7 @@ void activeDefragCycle(void) {
mstime_t
latency
;
int
quit
=
0
;
if
(
has
ForkChild
())
if
(
has
ActiveChildProcess
())
return
;
/* Defragging memory while there's a fork will just do damage. */
/* Once a second, check if we the fragmentation justfies starting a scan
...
...
src/module.c
View file @
de1f82aa
...
...
@@ -5157,7 +5157,7 @@ int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos)
int
RM_Fork
(
RedisModuleForkDoneHandler
cb
,
void
*
user_data
)
{
pid_t
childpid
;
if
(
has
ForkChild
())
{
if
(
has
ActiveChildProcess
())
{
return
-
1
;
}
...
...
src/rdb.c
View file @
de1f82aa
...
...
@@ -1336,7 +1336,7 @@ werr:
int
rdbSaveBackground
(
char
*
filename
,
rdbSaveInfo
*
rsi
)
{
pid_t
childpid
;
if
(
has
ForkChild
())
return
C_ERR
;
if
(
has
ActiveChildProcess
())
return
C_ERR
;
server
.
dirty_before_bgsave
=
server
.
dirty
;
server
.
lastbgsave_try
=
time
(
NULL
);
...
...
@@ -2417,7 +2417,7 @@ int rdbSaveToSlavesSockets(rdbSaveInfo *rsi) {
pid_t
childpid
;
int
pipefds
[
2
];
if
(
has
ForkChild
())
return
C_ERR
;
if
(
has
ActiveChildProcess
())
return
C_ERR
;
/* 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
...
...
@@ -2584,7 +2584,7 @@ void bgsaveCommand(client *c) {
if
(
server
.
rdb_child_pid
!=
-
1
)
{
addReplyError
(
c
,
"Background save already in progress"
);
}
else
if
(
has
ForkChild
())
{
}
else
if
(
has
ActiveChildProcess
())
{
if
(
schedule
)
{
server
.
rdb_bgsave_scheduled
=
1
;
addReplyStatus
(
c
,
"Background saving scheduled"
);
...
...
src/replication.c
View file @
de1f82aa
...
...
@@ -751,7 +751,7 @@ void syncCommand(client *c) {
/* Target is disk (or the slave is not capable of supporting
* diskless replication) and we don't have a BGSAVE in progress,
* let's start one. */
if
(
!
has
ForkChild
())
{
if
(
!
has
ActiveChildProcess
())
{
startBgsaveForReplication
(
c
->
slave_capa
);
}
else
{
serverLog
(
LL_NOTICE
,
...
...
@@ -2930,7 +2930,7 @@ void replicationCron(void) {
* In case of diskless replication, we make sure to wait the specified
* number of seconds (according to configuration) so that other slaves
* have the time to arrive before we start streaming. */
if
(
!
has
ForkChild
())
{
if
(
!
has
ActiveChildProcess
())
{
time_t
idle
,
max_idle
=
0
;
int
slaves_waiting
=
0
;
int
mincapa
=
-
1
;
...
...
src/server.c
View file @
de1f82aa
...
...
@@ -1449,13 +1449,13 @@ int incrementallyRehash(int dbid) {
* for dict.c to resize the hash tables accordingly to the fact we have o not
* running childs. */
void
updateDictResizePolicy
(
void
)
{
if
(
!
has
ForkChild
())
if
(
!
has
ActiveChildProcess
())
dictEnableResize
();
else
dictDisableResize
();
}
int
has
ForkChild
()
{
int
has
ActiveChildProcess
()
{
return
server
.
rdb_child_pid
!=
-
1
||
server
.
aof_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
* other processes saving the DB on disk. Otherwise rehashing is bad
* as will cause a lot of copy-on-write of memory pages. */
if
(
!
has
ForkChild
())
{
if
(
!
has
ActiveChildProcess
())
{
/* 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
* 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
* a BGSAVE was in progress. */
if
(
!
has
ForkChild
()
&&
if
(
!
has
ActiveChildProcess
()
&&
server
.
aof_rewrite_scheduled
)
{
rewriteAppendOnlyFileBackground
();
}
/* Check if a background saving or AOF rewrite in progress terminated. */
if
(
has
ForkChild
()
||
ldbPendingChildren
())
if
(
has
ActiveChildProcess
()
||
ldbPendingChildren
())
{
int
statloc
;
pid_t
pid
;
...
...
@@ -1975,7 +1975,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* Trigger an AOF rewrite if needed. */
if
(
server
.
aof_state
==
AOF_ON
&&
!
has
ForkChild
()
&&
!
has
ActiveChildProcess
()
&&
server
.
aof_rewrite_perc
&&
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
* make sure when refactoring this file to keep this order. This is useful
* because we want to give priority to RDB savings for replication. */
if
(
!
has
ForkChild
()
&&
if
(
!
has
ActiveChildProcess
()
&&
server
.
rdb_bgsave_scheduled
&&
(
server
.
unixtime
-
server
.
lastbgsave_try
>
CONFIG_BGSAVE_RETRY_DELAY
||
server
.
lastbgsave_status
==
C_OK
))
...
...
src/server.h
View file @
de1f82aa
...
...
@@ -1818,7 +1818,7 @@ void receiveChildInfo(void);
/* Fork helpers */
int
redisFork
();
int
has
ForkChild
();
int
has
ActiveChildProcess
();
void
sendChildCOWInfo
(
int
ptype
,
char
*
pname
);
/* acl.c -- Authentication related prototypes. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment