MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / handleBlockedClientsTimeout

Function handleBlockedClientsTimeout

src/timeout.cpp:137–156  ·  view source on GitHub ↗

This function is called in beforeSleep() in order to unblock clients * that are waiting in blocking operations with a timeout set. */

Source from the content-addressed store, hash-verified

135/* This function is called in beforeSleep() in order to unblock clients
136 * that are waiting in blocking operations with a timeout set. */
137void handleBlockedClientsTimeout(void) {
138 if (raxSize(g_pserver->clients_timeout_table) == 0) return;
139 uint64_t now = mstime();
140 raxIterator ri;
141 raxStart(&ri,g_pserver->clients_timeout_table);
142 raxSeek(&ri,"^",NULL,0);
143
144 while(raxNext(&ri)) {
145 uint64_t timeout;
146 client *c;
147 decodeTimeoutKey(ri.key,&timeout,&c);
148 if (timeout >= now) break; /* All the timeouts are in the future. */
149 std::unique_lock<fastlock> lock(c->lock);
150 c->flags &= ~CLIENT_IN_TO_TABLE;
151 checkBlockedClientTimeout(c,now);
152 raxRemove(g_pserver->clients_timeout_table,ri.key,ri.key_len,NULL);
153 raxSeek(&ri,"^",NULL,0);
154 }
155 raxStop(&ri);
156}
157
158/* Get a timeout value from an object and store it into 'timeout'.
159 * The final timeout is always stored as milliseconds as a time where the

Callers 1

beforeSleepFunction · 0.85

Calls 9

raxSizeFunction · 0.85
raxStartFunction · 0.85
raxSeekFunction · 0.85
raxNextFunction · 0.85
decodeTimeoutKeyFunction · 0.85
raxRemoveFunction · 0.85
raxStopFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected