diff options
author | antirez <antirez@gmail.com> | 2011-11-21 16:06:03 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2011-11-21 18:37:05 +0100 |
commit | 93babe4b4112752d28c6aa28004d84fa9fb1e543 (patch) | |
tree | edb57f654db669bab8a3a659bbe733687f0dc4f4 | |
parent | 713b4c5401a3f831bd04e43a39daa689d1411a64 (diff) | |
download | redis-93babe4b4112752d28c6aa28004d84fa9fb1e543.tar.gz |
show active events in client file descriptor in CLIENT LIST.
-rw-r--r-- | src/networking.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/networking.c b/src/networking.c index 9c57956a3..6c87797dc 100644 --- a/src/networking.c +++ b/src/networking.c @@ -885,9 +885,10 @@ void getClientsMaxBuffers(unsigned long *longest_output_list, /* Turn a Redis client into an sds string representing its state. */ sds getClientInfoString(redisClient *client) { - char ip[32], flags[16], *p; + char ip[32], flags[16], events[3], *p; int port; time_t now = time(NULL); + int emask; if (anetPeerToString(client->fd,ip,&port) == -1) { ip[0] = '?'; @@ -910,8 +911,14 @@ sds getClientInfoString(redisClient *client) { if (client->flags & REDIS_CLOSE_AFTER_REPLY) *p++ = 'c'; if (client->flags & REDIS_UNBLOCKED) *p++ = 'u'; *p++ = '\0'; + + emask = client->fd == -1 ? 0 : aeGetFileEvents(server.el,client->fd); + p = events; + if (emask & AE_READABLE) *p++ = 'r'; + 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", + "addr=%s:%d fd=%d idle=%ld flags=%s db=%d sub=%d psub=%d qbuf=%lu obl=%lu oll=%lu events=%s", ip,port,client->fd, (long)(now - client->lastinteraction), flags, @@ -920,7 +927,8 @@ sds getClientInfoString(redisClient *client) { (int) listLength(client->pubsub_patterns), (unsigned long) sdslen(client->querybuf), (unsigned long) client->bufpos, - (unsigned long) listLength(client->reply)); + (unsigned long) listLength(client->reply), + events); } void clientCommand(redisClient *c) { |