diff --git a/src/networking.c b/src/networking.c index 46d49bf6c5639febe72696852f06afe5cff56b0b..949537155921e3d433cd21871913158e8be9ce5b 100644 --- a/src/networking.c +++ b/src/networking.c @@ -541,7 +541,6 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) { aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE); /* Close connection after entire reply has been sent. */ - if (c->flags & REDIS_QUIT) freeClient(c); if (c->flags & REDIS_CLOSE_AFTER_REPLY) freeClient(c); } } @@ -802,9 +801,10 @@ void processInputBuffer(redisClient *c) { * will try to reiterate. The following line will make it return asap. */ if (c->flags & REDIS_BLOCKED || c->flags & REDIS_IO_WAIT) return; - /* Never continue to process the input buffer after QUIT. After the output - * buffer is flushed (with the OK), the connection will be dropped. */ - if (c->flags & REDIS_QUIT) return; + /* REDIS_CLOSE_AFTER_REPLY closes the connection once the reply is + * written to the client. Make sure to not let the reply grow after + * this flag has been set (i.e. don't process more commands). */ + if (c->flags & REDIS_CLOSE_AFTER_REPLY) return; /* Determine request type when unknown. */ if (!c->reqtype) { diff --git a/src/redis.c b/src/redis.c index 62a54b84304567dd4c7791d777f014e1c7d59e30..5c5198239a19ecaec6207e68210cc40ff5431611 100644 --- a/src/redis.c +++ b/src/redis.c @@ -893,10 +893,10 @@ int processCommand(redisClient *c) { * go through checking for replication and QUIT will cause trouble * when FORCE_REPLICATION is enabled and would be implemented in * a regular command proc. */ - redisAssert(!(c->flags & REDIS_QUIT)); + redisAssert(!(c->flags & REDIS_CLOSE_AFTER_REPLY)); if (!strcasecmp(c->argv[0]->ptr,"quit")) { - c->flags |= REDIS_QUIT; addReply(c,shared.ok); + c->flags |= REDIS_CLOSE_AFTER_REPLY; return REDIS_ERR; } diff --git a/src/redis.h b/src/redis.h index 1e841b73f0ebed53f936b61c288833f19d36eae4..44857569c37ed62d43c2c6abcd472c269c00820c 100644 --- a/src/redis.h +++ b/src/redis.h @@ -144,9 +144,7 @@ #define REDIS_BLOCKED 16 /* The client is waiting in a blocking operation */ #define REDIS_IO_WAIT 32 /* The client is waiting for Virtual Memory I/O */ #define REDIS_DIRTY_CAS 64 /* Watched keys modified. EXEC will fail. */ -#define REDIS_QUIT 128 /* Client will be disconnected after reply is sent */ -#define REDIS_CLOSE_AFTER_REPLY 256 /* Close connection immediately once the - * reply has been sent. */ +#define REDIS_CLOSE_AFTER_REPLY 128 /* Close after writing entire reply. */ /* Client request types */ #define REDIS_REQ_INLINE 1