mirror of
https://github.com/fluencelabs/redis
synced 2025-04-29 20:42:13 +00:00
minor refactoring to networking.c adding a separated function to get a string representing the current state of all the connected clients.
This commit is contained in:
parent
3852e2a831
commit
f4e2abfcd4
@ -939,20 +939,28 @@ sds getClientInfoString(redisClient *client) {
|
|||||||
client->lastcmd ? client->lastcmd->name : "NULL");
|
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) {
|
void clientCommand(redisClient *c) {
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
listIter li;
|
listIter li;
|
||||||
redisClient *client;
|
redisClient *client;
|
||||||
|
|
||||||
if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
|
if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
|
||||||
sds o = sdsempty();
|
sds o = getAllClientsInfoString();
|
||||||
|
|
||||||
listRewind(server.clients,&li);
|
|
||||||
while ((ln = listNext(&li)) != NULL) {
|
|
||||||
client = listNodeValue(ln);
|
|
||||||
o = sdscatsds(o,getClientInfoString(client));
|
|
||||||
o = sdscatlen(o,"\n",1);
|
|
||||||
}
|
|
||||||
addReplyBulkCBuffer(c,o,sdslen(o));
|
addReplyBulkCBuffer(c,o,sdslen(o));
|
||||||
sdsfree(o);
|
sdsfree(o);
|
||||||
} else if (!strcasecmp(c->argv[1]->ptr,"kill") && c->argc == 3) {
|
} else if (!strcasecmp(c->argv[1]->ptr,"kill") && c->argc == 3) {
|
||||||
|
@ -703,6 +703,7 @@ void *dupClientReplyValue(void *o);
|
|||||||
void getClientsMaxBuffers(unsigned long *longest_output_list,
|
void getClientsMaxBuffers(unsigned long *longest_output_list,
|
||||||
unsigned long *biggest_input_buffer);
|
unsigned long *biggest_input_buffer);
|
||||||
sds getClientInfoString(redisClient *client);
|
sds getClientInfoString(redisClient *client);
|
||||||
|
sds getAllClientsInfoString(void);
|
||||||
void rewriteClientCommandVector(redisClient *c, int argc, ...);
|
void rewriteClientCommandVector(redisClient *c, int argc, ...);
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user