From 1b6bdff48dcc333affab02b945821eb865529de2 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Sat, 5 Aug 2023 15:00:54 +0800 Subject: [PATCH] optimize the check of kill pubsub clients after modifying ACL rules (#12457) if there are no subscribers, we can ignore the operation --- src/acl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/acl.c b/src/acl.c index 07840406a..0bffbe970 100644 --- a/src/acl.c +++ b/src/acl.c @@ -1859,6 +1859,12 @@ int ACLCheckAllPerm(client *c, int *idxptr) { /* Check if the user's existing pub/sub clients violate the ACL pub/sub * permissions specified via the upcoming argument, and kill them if so. */ void ACLKillPubsubClientsIfNeeded(user *new, user *original) { + /* Do nothing if there are no subscribers. */ + if (!dictSize(server.pubsub_patterns) && + !dictSize(server.pubsub_channels) && + !dictSize(server.pubsubshard_channels)) + return; + listIter li, lpi; listNode *ln, *lpn; robj *o;