mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Fix clients timeout handling.
During the refactoring of blocking operations, commit 82b672f6335ac2db32a724ba5dc10398c949a4a8, a bug was introduced where a milliseconds time is compared to a seconds time, so all the clients always appear to timeout if timeout is set to non-zero value. Thanks to Jonathan Leibiusky for finding the bug and helping verifying the cause and fix.
This commit is contained in:
parent
c5618e7fdd
commit
58713c6b13
@ -872,7 +872,7 @@ long long getOperationsPerSecond(void) {
|
||||
|
||||
/* Check for timeouts. Returns non-zero if the client was terminated */
|
||||
int clientsCronHandleTimeout(redisClient *c) {
|
||||
mstime_t now = mstime();
|
||||
time_t now = server.unixtime;
|
||||
|
||||
if (server.maxidletime &&
|
||||
!(c->flags & REDIS_SLAVE) && /* no timeout for slaves */
|
||||
@ -886,7 +886,12 @@ int clientsCronHandleTimeout(redisClient *c) {
|
||||
freeClient(c);
|
||||
return 1;
|
||||
} else if (c->flags & REDIS_BLOCKED) {
|
||||
if (c->bpop.timeout != 0 && c->bpop.timeout < now) {
|
||||
/* Blocked OPS timeout is handled with milliseconds resolution.
|
||||
* However note that the actual resolution is limited by
|
||||
* server.hz. */
|
||||
mstime_t now_ms = mstime();
|
||||
|
||||
if (c->bpop.timeout != 0 && c->bpop.timeout < now_ms) {
|
||||
replyToBlockedClientTimedOut(c);
|
||||
unblockClient(c);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user