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); } }