bugfix: replace lastcmd with cmd when rewrite BRPOPLPUSH as RPOPLPUSH

There are two problems if we use lastcmd:

1. BRPOPLPUSH cannot be rewrited as RPOPLPUSH in multi/exec
    In mulit/exec context, the lastcmd is exec.
2. Redis will crash when execute RPOPLPUSH loading from AOF
    In fakeClient, the lastcmd is NULL.
This commit is contained in:
zhaozhao.zz 2018-09-28 12:06:43 +08:00
parent 0d6f11f4d1
commit fc9b4e7958

View File

@ -596,7 +596,7 @@ void rpoplpushCommand(client *c) {
signalModifiedKey(c->db,touchedkey);
decrRefCount(touchedkey);
server.dirty++;
if (c->lastcmd->proc == brpoplpushCommand) {
if (c->cmd->proc == brpoplpushCommand) {
rewriteClientCommandVector(c,3,shared.rpoplpush,c->argv[1],c->argv[2]);
}
}