diff --git a/src/commands/client-kill.json b/src/commands/client-kill.json index 5156e9b9be..8cc3578e24 100644 --- a/src/commands/client-kill.json +++ b/src/commands/client-kill.json @@ -38,7 +38,7 @@ ], [ "8.1.0", - "`ID` option accepts multiple IDs. Added filters NAME, MINIDLE, FLAGS, PATTERN, CHANNEL and SHARDCHANNEL." + "`ID` option accepts multiple IDs. Added filters NAME, MINIDLE, FLAGS, SUBSCRIBED-PATTERN, SUBSCRIBED-CHANNEL and SUBSCRIBED-SHARD-CHANNEL" ] ], "command_flags": [ diff --git a/src/commands/client-list.json b/src/commands/client-list.json index b709de843a..39f4d59388 100644 --- a/src/commands/client-list.json +++ b/src/commands/client-list.json @@ -38,7 +38,7 @@ ], [ "8.1.0", - "Added filters USER, ADDR, LADDR, SKIPME, MAXAGE, NAME, MINIDLE, FLAGS, PATTERN, CHANNEL and SHARDCHANNEL " + "Added filters USER, ADDR, LADDR, SKIPME, MAXAGE, NAME, MINIDLE, FLAGS, SUBSCRIBED-PATTERN, SUBSCRIBED-CHANNEL and SUBSCRIBED-SHARD-CHANNEL." ] ], "command_flags": [ diff --git a/src/networking.c b/src/networking.c index 1fdf464d03..0477d9598c 100644 --- a/src/networking.c +++ b/src/networking.c @@ -72,12 +72,12 @@ typedef struct { long long min_idle; /* Client flags for filtering. If NULL, no filtering is applied. */ char *flags; - /* Client pattern for filtering. If NULL, no filtering is applied. */ - robj *pattern; - /* Client channel for filtering. If NULL, no filtering is applied. */ - robj *channel; - /* Client shard channel for filtering. If NULL, no filtering is applied. */ - robj *shard_channel; + /* Client subscribed pattern for filtering. If NULL, no filtering is applied. */ + robj *subscribed_pattern; + /* Client subscribed channel for filtering. If NULL, no filtering is applied. */ + robj *subscribed_channel; + /* Client subscribed shard channel for filtering. If NULL, no filtering is applied. */ + robj *subscribed_shard_channel; } clientFilter; static void setProtocolError(const char *errstr, client *c); @@ -3623,14 +3623,14 @@ static int parseClientFiltersOrReply(client *c, int index, clientFilter *filter) } else if (!strcasecmp(c->argv[index]->ptr, "name") && moreargs) { filter->name = c->argv[index + 1]->ptr; index += 2; - } else if (!strcasecmp(c->argv[index]->ptr, "pattern") && moreargs) { - filter->pattern = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr)); + } else if (!strcasecmp(c->argv[index]->ptr, "subscribed-pattern") && moreargs) { + filter->subscribed_pattern = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr)); index += 2; - } else if (!strcasecmp(c->argv[index]->ptr, "channel") && moreargs) { - filter->channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr)); + } else if (!strcasecmp(c->argv[index]->ptr, "subscribed-channel") && moreargs) { + filter->subscribed_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr)); index += 2; - } else if (!strcasecmp(c->argv[index]->ptr, "shardchannel") && moreargs) { - filter->shard_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr)); + } else if (!strcasecmp(c->argv[index]->ptr, "subscribed-shard-channel") && moreargs) { + filter->subscribed_shard_channel = createObject(OBJ_STRING, sdsnew(c->argv[index + 1]->ptr)); index += 2; } else { addReplyErrorObject(c, shared.syntaxerr); @@ -3656,9 +3656,9 @@ static int clientMatchesFilter(client *client, clientFilter client_filter) { return 0; } } - if (client_filter.pattern && !clientSubscribedToPattern(client, client_filter.pattern)) return 0; - if (client_filter.channel && !clientSubscribedToChannel(client, client_filter.channel)) return 0; - if (client_filter.shard_channel && !clientSubscribedToShardChannel(client, client_filter.shard_channel)) return 0; + if (client_filter.subscribed_pattern && !clientSubscribedToPattern(client, client_filter.subscribed_pattern)) return 0; + if (client_filter.subscribed_channel && !clientSubscribedToChannel(client, client_filter.subscribed_channel)) return 0; + if (client_filter.subscribed_shard_channel && !clientSubscribedToShardChannel(client, client_filter.subscribed_shard_channel)) return 0; /* If all conditions are satisfied, the client matches the filter. */ return 1; @@ -3806,12 +3806,12 @@ void clientHelpCommand(client *c) { " Kill connections that include the specified flags.", " * NAME ", " Kill connections with the specified name.", - " * PATTERN ", - " Kill connections subscribed to a matching pattern.", - " * CHANNEL ", - " Kill connections subscribed to a matching channel.", - " * SHARD-CHANNEL ", - " Kill connections subscribed to a matching shard channel.", + " * SUBSCRIBED-PATTERN ", + " Kill connections subscribed to a matching subscribed pattern.", + " * SUBSCRIBED-CHANNEL ", + " Kill connections subscribed to a matching subscribed channel.", + " * SUBSCRIBED-SHARD-CHANNEL ", + " Kill connections subscribed to a matching subscribe shard channel.", "LIST [options ...]", " Return information about client connections. Options:", " * TYPE (NORMAL|PRIMARY|REPLICA|PUBSUB)", @@ -3834,12 +3834,12 @@ void clientHelpCommand(client *c) { " Return clients with the specified name.", " * MIN-IDLE ", " Return clients with idle time greater than or equal to seconds.", - " * PATTERN ", - " Return clients subscribed to a matching pattern.", - " * CHANNEL ", - " Return clients subscribed to the specified channel.", - " * SHARD-CHANNEL ", - " Return clients subscribed to the specified shard channel.", + " * SUBSCRIBED-PATTERN ", + " Return clients subscribed to a matching subscribed-pattern.", + " * SUBSCRIBED-CHANNEL ", + " Return clients subscribed to the specified subscribed-channel.", + " * SUBSCRIBED-SHARD-CHANNEL ", + " Return clients subscribed to the specified subscribe shard channel.", "UNPAUSE", " Stop the current client pause, resuming traffic.", "PAUSE [WRITE|ALL]", @@ -4007,17 +4007,17 @@ void clientKillCommand(client *c) { static void freeClientFilter(clientFilter *filter) { zfree(filter->ids); - if (filter->pattern) { - decrRefCount(filter->pattern); - filter->pattern = NULL; + if (filter->subscribed_pattern) { + decrRefCount(filter->subscribed_pattern); + filter->subscribed_pattern = NULL; } - if (filter->shard_channel) { - decrRefCount(filter->shard_channel); - filter->shard_channel = NULL; + if (filter->subscribed_shard_channel) { + decrRefCount(filter->subscribed_shard_channel); + filter->subscribed_shard_channel = NULL; } - if (filter->channel) { - decrRefCount(filter->channel); - filter->channel = NULL; + if (filter->subscribed_channel) { + decrRefCount(filter->subscribed_channel); + filter->subscribed_channel = NULL; } } diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index e03770f600..40b5586514 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -169,7 +169,7 @@ start_server {tags {"introspection"}} { $c1 psubscribe h*llo # Fetch the client list filtered by channel - set cl [split [r client list pattern h*llo] "\r\n"] + set cl [split [r client list subscribed-pattern h*llo] "\r\n"] # Assert the client is subscribed to the channel foreach line $cl { @@ -188,7 +188,7 @@ start_server {tags {"introspection"}} { $c1 subscribe mychannel # Fetch the client list filtered by channel - set cl [split [r client list channel mychannel] "\r\n"] + set cl [split [r client list subscribed-channel mychannel] "\r\n"] # Assert the client is subscribed to the channel foreach line $cl { @@ -207,7 +207,7 @@ start_server {tags {"introspection"}} { $c1 ssubscribe myshardchannel # Fetch the client list filtered by channel - set cl [split [r client list shardchannel myshardchannel] "\r\n"] + set cl [split [r client list subscribed-shard-channel myshardchannel] "\r\n"] # Assert the client is subscribed to the channel foreach line $cl { @@ -327,7 +327,7 @@ start_server {tags {"introspection"}} { $c1 psubscribe h*llo # Kill the client using the exact name pattern - r client kill pattern h*llo + r client kill subscribed-pattern h*llo # Assert the client was killed set err [catch {$c1 ping} error_message] @@ -345,7 +345,7 @@ start_server {tags {"introspection"}} { $c1 subscribe mychannel # Kill the client using the channel filter - r client kill channel mychannel + r client kill subscribed-channel mychannel # Assert the client was killed set err [catch {$c1 ping} error_message] @@ -363,7 +363,7 @@ start_server {tags {"introspection"}} { $c1 ssubscribe myshardchannel # Kill the client using the shard channel filter - r client kill shardchannel myshardchannel + r client kill subscribed-shard-channel myshardchannel # Assert the client was killed set err [catch {$c1 ping} error_message]