alsoPropagate: handle REDIS_CALL_PROPAGATE and AOF loading.

This commit is contained in:
antirez 2015-02-09 23:57:52 +01:00
parent cc7f0434b5
commit 55003f7a11
2 changed files with 10 additions and 5 deletions

View File

@ -2030,9 +2030,12 @@ void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc,
void alsoPropagate(struct redisCommand *cmd, int dbid, robj **argv, int argc,
int target)
{
robj **argvcopy = zmalloc(sizeof(robj*)*argc);
robj **argvcopy;
int j;
if (server.loading) return; /* No propagation during loading. */
argvcopy = zmalloc(sizeof(robj*)*argc);
for (j = 0; j < argc; j++) {
argvcopy[j] = argv[j];
incrRefCount(argv[j]);
@ -2132,9 +2135,11 @@ void call(redisClient *c, int flags) {
int j;
redisOp *rop;
for (j = 0; j < server.also_propagate.numops; j++) {
rop = &server.also_propagate.ops[j];
propagate(rop->cmd, rop->dbid, rop->argv, rop->argc, rop->target);
if (flags & REDIS_CALL_PROPAGATE) {
for (j = 0; j < server.also_propagate.numops; j++) {
rop = &server.also_propagate.ops[j];
propagate(rop->cmd,rop->dbid,rop->argv,rop->argc,rop->target);
}
}
redisOpArrayFree(&server.also_propagate);
}

View File

@ -204,7 +204,7 @@ tags {"aof"} {
}
}
## Test that SPOP with <count> (that modifies the client's argc/argv) is correctly free'd
## Uses the alsoPropagate() API.
create_aof {
append_to_aof [formatCommand sadd set foo]
append_to_aof [formatCommand sadd set bar]