You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix pub/sub: restrict commands in RESP2 subscription mode and fix reentrant lock crash
Fixes#1615. Two related bugs:
1. RESP2 subscription mode allowed arbitrary commands (GET, SET, PUBLISH, etc.)
instead of restricting to only (P|S)SUBSCRIBE/(P|S)UNSUBSCRIBE/PING/QUIT per
the Redis protocol. Added IsAllowedInSubscriptionMode() check in ProcessMessages
that rejects disallowed commands with a Redis-compatible error message.
2. PUBLISH from a subscriber session caused SynchronizationLockException because
the Publish() callback re-entered the spinlock already held by TryConsumeMessages.
Fixed by tracking the command-processing thread ID and detecting reentrant calls
in Publish()/PatternPublish() to skip lock acquire/release when on the same thread.
RESP3 sessions are not restricted since push message types are distinguishable
from regular responses.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: libs/server/Resp/CmdStrings.cs
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -328,6 +328,7 @@ static partial class CmdStrings
328
328
publicconststringGenericUnknownClientType="ERR Unknown client type '{0}'";
329
329
publicconststringGenericErrDuplicateFilter="ERR Filter '{0}' defined multiple times";
330
330
publicconststringGenericPubSubCommandDisabled="ERR {0} is disabled, enable it with --pubsub option.";
331
+
publicconststringGenericPubSubCommandNotAllowed="ERR Can't execute '{0}': only (P|S)SUBSCRIBE / (P|S)UNSUBSCRIBE / PING / QUIT are allowed in this context";
0 commit comments