optimize the check of kill pubsub clients after modifying ACL rules (#12457)

if there are no subscribers, we can ignore the operation
This commit is contained in:
zhaozhao.zz 2023-08-05 15:00:54 +08:00 committed by GitHub
parent 8226f39fb2
commit 1b6bdff48d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;