diff --git a/src/t_string.c b/src/t_string.c index e121df73..db6f7aa6 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -301,24 +301,22 @@ void mgetCommand(client *c) { } void msetGenericCommand(client *c, int nx) { - int j, busykeys = 0; + int j; if ((c->argc % 2) == 0) { addReplyError(c,"wrong number of arguments for MSET"); return; } + /* Handle the NX flag. The MSETNX semantic is to return zero and don't - * set nothing at all if at least one already key exists. */ + * set anything if at least one key alerady exists. */ if (nx) { for (j = 1; j < c->argc; j += 2) { if (lookupKeyWrite(c->db,c->argv[j]) != NULL) { - busykeys++; + addReply(c, shared.czero); + return; } } - if (busykeys) { - addReply(c, shared.czero); - return; - } } for (j = 1; j < c->argc; j += 2) {