Skip to content

Commit

Permalink
Fix call() FORCE_REPL/AOF flags setting.
Browse files Browse the repository at this point in the history
This commit also inverts two stanzas of the code just becuase they are
more logical like that, not because currently it makes any difference.
  • Loading branch information
antirez committed Oct 30, 2015
1 parent 514a234 commit 2dabf82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 14 additions & 13 deletions src/scripting.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,19 @@ void evalGenericCommand(client *c, int evalsha) {
lua_pop(lua,1); /* Remove the error handler. */
}

/* If we are using single commands replication, emit EXEC if there
* was at least a write. */
if (server.lua_replicate_commands) {
preventCommandPropagation(c);
if (server.lua_multi_emitted) {
robj *propargv[1];
propargv[0] = createStringObject("EXEC",4);
alsoPropagate(server.execCommand,c->db->id,propargv,1,
PROPAGATE_AOF|PROPAGATE_REPL);
decrRefCount(propargv[0]);
}
}

/* EVALSHA should be propagated to Slave and AOF file as full EVAL, unless
* we are sure that the script was already in the context of all the
* attached slaves *and* the current AOF file if enabled.
Expand All @@ -1186,22 +1199,10 @@ void evalGenericCommand(client *c, int evalsha) {
rewriteClientCommandArgument(c,0,
resetRefCount(createStringObject("EVAL",4)));
rewriteClientCommandArgument(c,1,script);
printf("forceCommandPropagation\n");
forceCommandPropagation(c,PROPAGATE_REPL|PROPAGATE_AOF);
}
}

/* If we are using single commands replication, emit EXEC if there
* was at least a write. */
if (server.lua_replicate_commands) {
preventCommandPropagation(c);
if (server.lua_multi_emitted) {
robj *propargv[1];
propargv[0] = createStringObject("EXEC",4);
alsoPropagate(server.execCommand,c->db->id,propargv,1,
PROPAGATE_AOF|PROPAGATE_REPL);
decrRefCount(propargv[0]);
}
}
}

void evalCommand(client *c) {
Expand Down
4 changes: 2 additions & 2 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -2235,8 +2235,8 @@ void call(client *c, int flags) {

/* If the command forced AOF / replication of the command, set
* the flags regardless of the command effects on the data set. */
if (c->flags & CLIENT_FORCE_REPL) flags |= PROPAGATE_REPL;
if (c->flags & CLIENT_FORCE_AOF) flags |= PROPAGATE_AOF;
if (c->flags & CLIENT_FORCE_REPL) propagate_flags |= PROPAGATE_REPL;
if (c->flags & CLIENT_FORCE_AOF) propagate_flags |= PROPAGATE_AOF;

/* However prevent AOF / replication propagation if the command
* implementatino called preventCommandPropagation() or similar,
Expand Down

0 comments on commit 2dabf82

Please sign in to comment.