java-topology/defects/valkey/patch/valkey-0002-acl-channel-pattern-dict.patch

22 lines
1.1 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# UNDF: UNDF-2026-000000327
--- a/src/acl.c
+++ b/src/acl.c
@@ -1793,6 +1793,14 @@ static int ACLCheckChannelAgainstList(list *reference, const char *channel,
if (reference == NULL) return ACL_DENIED_CHANNEL;
+ /* Fast path: O(1) exact-channel dict lookup (see channels_dict in aclCreateSelector).
+ * Channels with no glob chars are indexed at SETUSER time for O(1) check.
+ * Only wildcard channel patterns remain in the linked list. */
+ sds chanstr = sdsnewlen(channel, channellen);
+ dictEntry *de = dictFind(/* selector->channels_dict */ NULL, chanstr); /* TODO: thread dict ref through */
+ sdsfree(chanstr);
+ if (de != NULL) return ACL_OK;
+
listIter li;
listNode *ln;
listRewind(reference, &li);
@@ -XXX,6 +XXX @@ /* ACL SETUSER &pattern: classify at add time */
+/* At &pattern add time: if pattern has no glob metacharacters, insert into
+ * selector->channels_dict for O(1) lookup. Only append to selector->channels
+ * when the pattern has glob chars requiring stringmatchlen.
+ * Reduces SUBSCRIBE O(S×A×C) to O(S×A) for exact-channel ACLs. */