summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-03-26 14:37:00 +0100
committerantirez <antirez@gmail.com>2020-03-27 16:35:03 +0100
commit8d11e0df7aeecd4f1bcdf1fbaa5ef19f44a4a18f (patch)
tree48092645656220dce54f095491d060a435821758
parent324a8c91d05023420c7f15d9ad84ba41ad9eefe3 (diff)
downloadredis-8d11e0df7aeecd4f1bcdf1fbaa5ef19f44a4a18f.tar.gz
Precise timeouts: fix bugs in initial implementation.
-rw-r--r--src/blocked.c2
-rw-r--r--src/server.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/blocked.c b/src/blocked.c
index c470cba00..84a5287d4 100644
--- a/src/blocked.c
+++ b/src/blocked.c
@@ -111,6 +111,7 @@ void blockClient(client *c, int btype) {
c->btype = btype;
server.blocked_clients++;
server.blocked_clients_by_type[btype]++;
+ addClientToShortTimeoutTable(c);
}
/* This function is called in the beforeSleep() function of the event loop
@@ -619,7 +620,6 @@ void blockForKeys(client *c, int btype, robj **keys, int numkeys, mstime_t timeo
listAddNodeTail(l,c);
}
blockClient(c,btype);
- addClientToShortTimeoutTable(c);
}
/* Unblock a client that's waiting in a blocking operation such as BLPOP.
diff --git a/src/server.c b/src/server.c
index bd63c4b4e..25af4e161 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1588,6 +1588,7 @@ void clientsHandleShortTimeout(void) {
uint64_t now = mstime();
raxIterator ri;
raxStart(&ri,server.clients_timeout_table);
+ raxSeek(&ri,"^",NULL,0);
while(raxNext(&ri)) {
uint64_t id, timeout;
@@ -1745,6 +1746,9 @@ void getExpansiveClientsInfo(size_t *in_usage, size_t *out_usage) {
*/
#define CLIENTS_CRON_MIN_ITERATIONS 5
void clientsCron(void) {
+ /* Unblock short timeout clients ASAP. */
+ clientsHandleShortTimeout();
+
/* Try to process at least numclients/server.hz of clients
* per call. Since normally (if there are no big latency events) this
* function is called server.hz times per second, in the average case we