mirror of
https://github.com/fluencelabs/redis
synced 2025-06-28 00:11:33 +00:00
PubSub clients refactoring and new PUBSUB flag.
The code tested many times if a client had active Pub/Sub subscriptions by checking the length of a list and dictionary where the patterns and channels are stored. This was substituted with a client flag called REDIS_PUBSUB that is simpler to test for. Moreover in order to manage this flag some code was refactored. This commit is believed to have no effects in the behavior of the server.
This commit is contained in:
@ -907,8 +907,7 @@ int clientsCronHandleTimeout(redisClient *c) {
|
||||
!(c->flags & REDIS_SLAVE) && /* no timeout for slaves */
|
||||
!(c->flags & REDIS_MASTER) && /* no timeout for masters */
|
||||
!(c->flags & REDIS_BLOCKED) && /* no timeout for BLPOP */
|
||||
dictSize(c->pubsub_channels) == 0 && /* no timeout for pubsub */
|
||||
listLength(c->pubsub_patterns) == 0 &&
|
||||
!(c->flags & REDIS_PUBSUB) && /* no timeout for Pub/Sub clients */
|
||||
(now - c->lastinteraction > server.maxidletime))
|
||||
{
|
||||
redisLog(REDIS_VERBOSE,"Closing idle client");
|
||||
@ -2211,8 +2210,8 @@ int processCommand(redisClient *c) {
|
||||
}
|
||||
|
||||
/* Only allow SUBSCRIBE and UNSUBSCRIBE in the context of Pub/Sub */
|
||||
if ((dictSize(c->pubsub_channels) > 0 || listLength(c->pubsub_patterns) > 0)
|
||||
&&
|
||||
if (c->flags & REDIS_PUBSUB &&
|
||||
c->cmd->proc != pingCommand &&
|
||||
c->cmd->proc != subscribeCommand &&
|
||||
c->cmd->proc != unsubscribeCommand &&
|
||||
c->cmd->proc != psubscribeCommand &&
|
||||
|
Reference in New Issue
Block a user