diff --git a/src/server.c b/src/server.c index 78aee5db..fd65bb18 100644 --- a/src/server.c +++ b/src/server.c @@ -2410,7 +2410,7 @@ void call(client *c, int flags) { int client_old_flags = c->flags; struct redisCommand *real_cmd = c->cmd; - /* Sent the command to clients in MONITOR mode, only if the commands are + /* Send the command to clients in MONITOR mode, only if the commands are * not generated from reading an AOF. */ if (listLength(server.monitors) && !server.loading && @@ -2419,6 +2419,18 @@ void call(client *c, int flags) { replicationFeedMonitors(c,server.monitors,c->db->id,c->argv,c->argc); } + /* If the client is in the context of a transaction, reply with + * +QUEUED and just accumulate the command in the client transaction + * commands vector. */ + if (c->flags & CLIENT_MULTI && + c->cmd->proc != execCommand && c->cmd->proc != discardCommand && + c->cmd->proc != multiCommand && c->cmd->proc != watchCommand) + { + queueMultiCommand(c); + addReply(c,shared.queued); + return; + } + /* Initialization: clear the flags that must be set by the command on * demand, and initialize the array for additional commands propagation. */ c->flags &= ~(CLIENT_FORCE_AOF|CLIENT_FORCE_REPL|CLIENT_PREVENT_PROP); @@ -2714,18 +2726,9 @@ int processCommand(client *c) { } /* Exec the command */ - if (c->flags & CLIENT_MULTI && - c->cmd->proc != execCommand && c->cmd->proc != discardCommand && - c->cmd->proc != multiCommand && c->cmd->proc != watchCommand) - { - queueMultiCommand(c); - addReply(c,shared.queued); - } else { - call(c,CMD_CALL_FULL); - c->woff = server.master_repl_offset; - if (listLength(server.ready_keys)) - handleClientsBlockedOnKeys(); - } + call(c,CMD_CALL_FULL); + c->woff = server.master_repl_offset; + if (listLength(server.ready_keys)) handleClientsBlockedOnKeys(); return C_OK; }