Skip to content

Commit 96857bf

Browse files
authored
show capa in CLIENT LIST (#1698)
Signed-off-by: zhaozhao.zz <[email protected]>
1 parent 0e66aaa commit 96857bf

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/networking.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3346,7 +3346,7 @@ int isClientConnIpV6(client *c) {
33463346
* readable format, into the sds string 's'. */
33473347
sds catClientInfoString(sds s, client *client, int hide_user_data) {
33483348
if (!server.crashed) waitForClientIO(client);
3349-
char flags[17], events[3], conninfo[CONN_INFO_LEN], *p;
3349+
char flags[17], events[3], capa[9], conninfo[CONN_INFO_LEN], *p;
33503350

33513351
p = flags;
33523352
if (client->flag.replica) {
@@ -3382,6 +3382,10 @@ sds catClientInfoString(sds s, client *client, int hide_user_data) {
33823382
}
33833383
*p = '\0';
33843384

3385+
p = capa;
3386+
if (client->capa & CLIENT_CAPA_REDIRECT) *p++ = 'r';
3387+
*p = '\0';
3388+
33853389
/* Compute the total memory consumed by this client. */
33863390
size_t obufmem, total_mem = getClientMemoryUsage(client, &obufmem);
33873391

@@ -3402,6 +3406,7 @@ sds catClientInfoString(sds s, client *client, int hide_user_data) {
34023406
" age=%I", (long long)(commandTimeSnapshot() / 1000 - client->ctime),
34033407
" idle=%I", (long long)(server.unixtime - client->last_interaction),
34043408
" flags=%s", flags,
3409+
" capa=%s", capa,
34053410
" db=%i", client->db->id,
34063411
" sub=%i", client->pubsub_data ? (int)dictSize(client->pubsub_data->pubsub_channels) : 0,
34073412
" psub=%i", client->pubsub_data ? (int)dictSize(client->pubsub_data->pubsub_patterns) : 0,

tests/integration/replica-redirect.tcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ start_server {tags {needs:repl external:skip}} {
4646
assert_error "REDIRECT $primary_host:$primary_port" {r get foo}
4747
}
4848

49+
test {CLIENT INFO} {
50+
r client info
51+
} {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N capa=r db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=* lib-name=* lib-ver=* tot-net-in=* tot-net-out=* tot-cmds=*}
52+
4953
test {non-data access commands are not redirected} {
5054
r ping
5155
} {PONG}

tests/unit/introspection.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ start_server {tags {"introspection"}} {
77

88
test {CLIENT LIST} {
99
r client list
10-
} {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|list user=* redir=-1 resp=* lib-name=* lib-ver=* tot-net-in=* tot-net-out=* tot-cmds=*}
10+
} {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N capa= db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|list user=* redir=-1 resp=* lib-name=* lib-ver=* tot-net-in=* tot-net-out=* tot-cmds=*}
1111

1212
test {CLIENT LIST with IDs} {
1313
set myid [r client id]
@@ -17,7 +17,7 @@ start_server {tags {"introspection"}} {
1717

1818
test {CLIENT INFO} {
1919
r client info
20-
} {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=* lib-name=* lib-ver=* tot-net-in=* tot-net-out=* tot-cmds=*}
20+
} {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N capa= db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=* lib-name=* lib-ver=* tot-net-in=* tot-net-out=* tot-cmds=*}
2121

2222
test {CLIENT LIST with ADDR filter} {
2323
set client_info [r client info]

0 commit comments

Comments
 (0)