Commit 45e7a1ce authored by antirez's avatar antirez
Browse files

minor refactoring to networking.c adding a separated function to get a string...

minor refactoring to networking.c adding a separated function to get a string representing the current state of all the connected clients.
parent 2c74a9f9
......@@ -980,12 +980,10 @@ sds getClientInfoString(redisClient *client) {
client->lastcmd ? client->lastcmd->name : "NULL");
}
void clientCommand(redisClient *c) {
sds getAllClientsInfoString(void) {
listNode *ln;
listIter li;
redisClient *client;
if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
sds o = sdsempty();
listRewind(server.clients,&li);
......@@ -994,6 +992,16 @@ void clientCommand(redisClient *c) {
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 = getAllClientsInfoString();
addReplyBulkCBuffer(c,o,sdslen(o));
sdsfree(o);
} else if (!strcasecmp(c->argv[1]->ptr,"kill") && c->argc == 3) {
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment