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
54f5ecfd
Commit
54f5ecfd
authored
Nov 10, 2015
by
antirez
Browse files
call() deserves a good top-comment.
parent
c950facf
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/server.c
View file @
54f5ecfd
...
@@ -2164,7 +2164,43 @@ void preventCommandReplication(client *c) {
...
@@ -2164,7 +2164,43 @@ void preventCommandReplication(client *c) {
c
->
flags
|=
CLIENT_PREVENT_REPL_PROP
;
c
->
flags
|=
CLIENT_PREVENT_REPL_PROP
;
}
}
/* Call() is the core of Redis execution of a command */
/* Call() is the core of Redis execution of a command.
*
* The following flags can be passed:
* CMD_CALL_NONE No flags.
* CMD_CALL_SLOWLOG Check command speed and log in the slow log if needed.
* CMD_CALL_STATS Populate command stats.
* CMD_CALL_PROPAGATE_AOF Append command to AOF if it modified the dataset
* or if the client flags are forcing propagation.
* CMD_CALL_PROPAGATE_REPL Send command to salves if it modified the dataset
* or if the client flags are forcing propagation.
* CMD_CALL_PROPAGATE Alias for PROPAGATE_AOF|PROPAGATE_REPL.
* CMD_CALL_FULL Alias for SLOWLOG|STATS|PROPAGATE.
*
* The exact propagation behavior depends on the client flags.
* Specifically:
*
* 1. If the client flags CLIENT_FORCE_AOF or CLIENT_FORCE_REPL are set
* and assuming the corresponding CMD_CALL_PROPAGATE_AOF/REPL is set
* in the call flags, then the command is propagated even if the
* dataset was not affected by the command.
* 2. If the client flags CLIENT_PREVENT_REPL_PROP or CLIENT_PREVENT_AOF_PROP
* are set, the propagation into AOF or to slaves is not performed even
* if the command modified the dataset.
*
* Note that regardless of the client flags, if CMD_CALL_PROPAGATE_AOF
* or CMD_CALL_PROPAGATE_REPL are not set, then respectively AOF or
* slaves propagation will never occur.
*
* Client flags are modified by the implementation of a given command
* using the following API:
*
* forceCommandPropagation(client *c, int flags);
* preventCommandPropagation(client *c);
* preventCommandAOF(client *c);
* preventCommandReplication(client *c);
*
*/
void
call
(
client
*
c
,
int
flags
)
{
void
call
(
client
*
c
,
int
flags
)
{
long
long
dirty
,
start
,
duration
;
long
long
dirty
,
start
,
duration
;
int
client_old_flags
=
c
->
flags
;
int
client_old_flags
=
c
->
flags
;
...
@@ -2229,7 +2265,7 @@ void call(client *c, int flags) {
...
@@ -2229,7 +2265,7 @@ void call(client *c, int flags) {
* set for replication / AOF propagation. */
* set for replication / AOF propagation. */
if
(
dirty
)
propagate_flags
|=
(
PROPAGATE_AOF
|
PROPAGATE_REPL
);
if
(
dirty
)
propagate_flags
|=
(
PROPAGATE_AOF
|
PROPAGATE_REPL
);
/* If the c
ommand
forced AOF / replication of the command, set
/* If the c
lient
forced AOF / replication of the command, set
* the flags regardless of the command effects on the data set. */
* the flags regardless of the command effects on the data set. */
if
(
c
->
flags
&
CLIENT_FORCE_REPL
)
propagate_flags
|=
PROPAGATE_REPL
;
if
(
c
->
flags
&
CLIENT_FORCE_REPL
)
propagate_flags
|=
PROPAGATE_REPL
;
if
(
c
->
flags
&
CLIENT_FORCE_AOF
)
propagate_flags
|=
PROPAGATE_AOF
;
if
(
c
->
flags
&
CLIENT_FORCE_AOF
)
propagate_flags
|=
PROPAGATE_AOF
;
...
...
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