mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05: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
2c74a9f948
commit
45e7a1ce00
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user