提交 45e7a1ce 编写于 作者: A antirez

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.
上级 2c74a9f9
......@@ -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) {
......
......@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册