Does not allow commands other than Pub/Sub commands when there is at least one pattern

This commit is contained in:
antirez
2010-04-14 12:12:25 +02:00
parent 9a22de8270
commit e6cca5dba6
2 changed files with 31 additions and 1 deletions

View File

@ -2304,7 +2304,8 @@ static int processCommand(redisClient *c) {
}
/* Only allow SUBSCRIBE and UNSUBSCRIBE in the context of Pub/Sub */
if (dictSize(c->pubsub_channels) > 0 &&
if ((dictSize(c->pubsub_channels) > 0 || listLength(c->pubsub_patterns) > 0)
&&
cmd->proc != subscribeCommand && cmd->proc != unsubscribeCommand &&
cmd->proc != psubscribeCommand && cmd->proc != punsubscribeCommand) {
addReplySds(c,sdsnew("-ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / QUIT allowed in this context\r\n"));