]> git.saurik.com Git - redis.git/commitdiff
minor refactoring to networking.c adding a separated function to get a string represe...
authorantirez <antirez@gmail.com>
Thu, 24 Nov 2011 14:04:42 +0000 (15:04 +0100)
committerantirez <antirez@gmail.com>
Thu, 24 Nov 2011 14:04:42 +0000 (15:04 +0100)
src/networking.c
src/redis.h

index 77a705b2bf5cee5df16c59e0e5dc44cfef5cf90e..c16e182f2653cf218c9a53b6f28de51ef608ecd9 100644 (file)
@@ -980,20 +980,28 @@ sds getClientInfoString(redisClient *client) {
         client->lastcmd ? client->lastcmd->name : "NULL");
 }
 
+sds getAllClientsInfoString(void) {
+    listNode *ln;
+    listIter li;
+    redisClient *client;
+    sds o = sdsempty();
+
+    listRewind(server.clients,&li);
+    while ((ln = listNext(&li)) != NULL) {
+        client = listNodeValue(ln);
+        o = sdscatsds(o,getClientInfoString(client));
+        o = sdscatlen(o,"\n",1);
+    }
+    return o;
+}
+
 void clientCommand(redisClient *c) {
     listNode *ln;
     listIter li;
     redisClient *client;
 
     if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
-        sds o = sdsempty();
-
-        listRewind(server.clients,&li);
-        while ((ln = listNext(&li)) != NULL) {
-            client = listNodeValue(ln);
-            o = sdscatsds(o,getClientInfoString(client));
-            o = sdscatlen(o,"\n",1);
-        }
+        sds o = getAllClientsInfoString();
         addReplyBulkCBuffer(c,o,sdslen(o));
         sdsfree(o);
     } else if (!strcasecmp(c->argv[1]->ptr,"kill") && c->argc == 3) {
index ae1e75ba6cf802e62691819c7d560e85c74ba444..218d72fbf13cd776ee3a378fcc2f93944e2fde2f 100644 (file)
@@ -769,6 +769,7 @@ void *dupClientReplyValue(void *o);
 void getClientsMaxBuffers(unsigned long *longest_output_list,
                           unsigned long *biggest_input_buffer);
 sds getClientInfoString(redisClient *client);
+sds getAllClientsInfoString(void);
 void rewriteClientCommandVector(redisClient *c, int argc, ...);
 void rewriteClientCommandArgument(redisClient *c, int i, robj *newval);