Fix merge issues and move timeout to C++
Former-commit-id: 1005a725d498e3c9f8c708d3c8b013a402149bd8
This commit is contained in:
parent
68fd7c5c3d
commit
8675bd3bde
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "cluster.h"
|
#include "cluster.h"
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
/* ========================== Clients timeouts ============================= */
|
/* ========================== Clients timeouts ============================= */
|
||||||
|
|
||||||
@ -163,10 +164,10 @@ void clientsHandleTimeout(void) {
|
|||||||
/* This function is called in beforeSleep() in order to unblock clients
|
/* This function is called in beforeSleep() in order to unblock clients
|
||||||
* that are waiting in blocking operations with a timeout set. */
|
* that are waiting in blocking operations with a timeout set. */
|
||||||
void handleBlockedClientsTimeout(void) {
|
void handleBlockedClientsTimeout(void) {
|
||||||
if (raxSize(server.clients_timeout_table) == 0) return;
|
if (raxSize(g_pserver->clients_timeout_table) == 0) return;
|
||||||
uint64_t now = mstime();
|
uint64_t now = mstime();
|
||||||
raxIterator ri;
|
raxIterator ri;
|
||||||
raxStart(&ri,server.clients_timeout_table);
|
raxStart(&ri,g_pserver->clients_timeout_table);
|
||||||
raxSeek(&ri,"^",NULL,0);
|
raxSeek(&ri,"^",NULL,0);
|
||||||
|
|
||||||
while(raxNext(&ri)) {
|
while(raxNext(&ri)) {
|
||||||
@ -175,10 +176,11 @@ void handleBlockedClientsTimeout(void) {
|
|||||||
if (timeout >= now) break; /* All the timeouts are in the future. */
|
if (timeout >= now) break; /* All the timeouts are in the future. */
|
||||||
client *c = lookupClientByID(id);
|
client *c = lookupClientByID(id);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
std::unique_lock<fastlock> lock(c->lock);
|
||||||
c->flags &= ~CLIENT_IN_TO_TABLE;
|
c->flags &= ~CLIENT_IN_TO_TABLE;
|
||||||
checkBlockedClientTimeout(c,now);
|
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);
|
raxSeek(&ri,"^",NULL,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user