From 8675bd3bdee87c9614b1eda9b9564d456626586b Mon Sep 17 00:00:00 2001 From: John Sully Date: Tue, 14 Apr 2020 22:37:26 -0400 Subject: [PATCH] Fix merge issues and move timeout to C++ Former-commit-id: 1005a725d498e3c9f8c708d3c8b013a402149bd8 --- src/{timeout.c => timeout.cpp} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename src/{timeout.c => timeout.cpp} (97%) diff --git a/src/timeout.c b/src/timeout.cpp similarity index 97% rename from src/timeout.c rename to src/timeout.cpp index 6328bcd5d..4d114a25e 100644 --- a/src/timeout.c +++ b/src/timeout.cpp @@ -28,6 +28,7 @@ #include "server.h" #include "cluster.h" +#include /* ========================== Clients timeouts ============================= */ @@ -163,10 +164,10 @@ void clientsHandleTimeout(void) { /* This function is called in beforeSleep() in order to unblock clients * that are waiting in blocking operations with a timeout set. */ void handleBlockedClientsTimeout(void) { - if (raxSize(server.clients_timeout_table) == 0) return; + if (raxSize(g_pserver->clients_timeout_table) == 0) return; uint64_t now = mstime(); raxIterator ri; - raxStart(&ri,server.clients_timeout_table); + raxStart(&ri,g_pserver->clients_timeout_table); raxSeek(&ri,"^",NULL,0); while(raxNext(&ri)) { @@ -175,10 +176,11 @@ void handleBlockedClientsTimeout(void) { if (timeout >= now) break; /* All the timeouts are in the future. */ client *c = lookupClientByID(id); if (c) { + std::unique_lock lock(c->lock); c->flags &= ~CLIENT_IN_TO_TABLE; checkBlockedClientTimeout(c,now); } - raxRemove(server.clients_timeout_table,ri.key,ri.key_len,NULL); + raxRemove(g_pserver->clients_timeout_table,ri.key,ri.key_len,NULL); raxSeek(&ri,"^",NULL,0); } }