diff --git a/src/networking.c b/src/networking.c index c9286195c3fa05d57a4a8a9002e4f67977b38c4f..77a705b2bf5cee5df16c59e0e5dc44cfef5cf90e 100644 --- a/src/networking.c +++ b/src/networking.c @@ -36,7 +36,7 @@ redisClient *createClient(int fd) { c->reqtype = 0; c->argc = 0; c->argv = NULL; - c->cmd = NULL; + c->cmd = c->lastcmd = NULL; c->multibulklen = 0; c->bulklen = -1; c->sentlen = 0; @@ -966,7 +966,7 @@ sds getClientInfoString(redisClient *client) { if (emask & AE_WRITABLE) *p++ = 'w'; *p = '\0'; return sdscatprintf(sdsempty(), - "addr=%s:%d fd=%d idle=%ld flags=%s db=%d sub=%d psub=%d qbuf=%lu obl=%lu oll=%lu events=%s", + "addr=%s:%d fd=%d idle=%ld flags=%s db=%d sub=%d psub=%d qbuf=%lu obl=%lu oll=%lu events=%s cmd=%s", ip,port,client->fd, (long)(now - client->lastinteraction), flags, @@ -976,7 +976,8 @@ sds getClientInfoString(redisClient *client) { (unsigned long) sdslen(client->querybuf), (unsigned long) client->bufpos, (unsigned long) listLength(client->reply), - events); + events, + client->lastcmd ? client->lastcmd->name : "NULL"); } void clientCommand(redisClient *c) { diff --git a/src/redis.c b/src/redis.c index a4eb508091bc0559368e9e40d6b5a6df382cd677..eb391f1a7ba2b57263b329b85b4dce688446f387 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1174,7 +1174,7 @@ int processCommand(redisClient *c) { /* Now lookup the command and check ASAP about trivial error conditions * such as wrong arity, bad command name and so forth. */ - c->cmd = lookupCommand(c->argv[0]->ptr); + c->cmd = c->lastcmd = lookupCommand(c->argv[0]->ptr); if (!c->cmd) { addReplyErrorFormat(c,"unknown command '%s'", (char*)c->argv[0]->ptr); diff --git a/src/redis.h b/src/redis.h index 4a2f6e1e5f4d561a4fcb6942116f9f2051ef93e4..ae1e75ba6cf802e62691819c7d560e85c74ba444 100644 --- a/src/redis.h +++ b/src/redis.h @@ -294,7 +294,7 @@ typedef struct redisClient { sds querybuf; int argc; robj **argv; - struct redisCommand *cmd; + struct redisCommand *cmd, *lastcmd; int reqtype; int multibulklen; /* number of multi bulk arguments left to read */ long bulklen; /* length of bulk argument in multi bulk request */