Commit d6cc8867 authored by antirez's avatar antirez
Browse files

No timeouts nor other commands for clients in a Pub/Sub context

parent ff767a75
......@@ -1152,7 +1152,8 @@ static void closeTimedoutClients(void) {
if (server.maxidletime &&
!(c->flags & REDIS_SLAVE) && /* no timeout for slaves */
!(c->flags & REDIS_MASTER) && /* no timeout for masters */
(now - c->lastinteraction > server.maxidletime))
dictSize(c->pubsub_classes) == 0 && /* no timeout for pubsub */
(now - c->lastinteraction > server.maxidletime))
{
redisLog(REDIS_VERBOSE,"Closing idle client");
freeClient(c);
......@@ -2264,6 +2265,14 @@ static int processCommand(redisClient *c) {
return 1;
}
/* Only allow SUBSCRIBE and UNSUBSCRIBE in the context of Pub/Sub */
if (dictSize(c->pubsub_classes) > 0 &&
cmd->proc != subscribeCommand && cmd->proc != unsubscribeCommand) {
addReplySds(c,sdsnew("-ERR only SUBSCRIBE / UNSUBSCRIBE / QUIT allowed in this context\r\n"));
resetClient(c);
return 1;
}
/* Exec the command */
if (c->flags & REDIS_MULTI && cmd->proc != execCommand && cmd->proc != discardCommand) {
queueMultiCommand(c,cmd);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment