MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clientsCronHandleTimeout

Function clientsCronHandleTimeout

app/redis-6.2.6/src/timeout.c:55–78  ·  view source on GitHub ↗

Check for timeouts. Returns non-zero if the client was terminated. * The function gets the current time in milliseconds as argument since * it gets called multiple times in a loop, so calling gettimeofday() for * each iteration would be costly without any actual gain. */

Source from the content-addressed store, hash-verified

53 * it gets called multiple times in a loop, so calling gettimeofday() for
54 * each iteration would be costly without any actual gain. */
55int clientsCronHandleTimeout(client *c, mstime_t now_ms) {
56 time_t now = now_ms/1000;
57
58 if (server.maxidletime &&
59 /* This handles the idle clients connection timeout if set. */
60 !(c->flags & CLIENT_SLAVE) && /* No timeout for slaves and monitors */
61 !(c->flags & CLIENT_MASTER) && /* No timeout for masters */
62 !(c->flags & CLIENT_BLOCKED) && /* No timeout for BLPOP */
63 !(c->flags & CLIENT_PUBSUB) && /* No timeout for Pub/Sub clients */
64 (now - c->lastinteraction > server.maxidletime))
65 {
66 serverLog(LL_VERBOSE,"Closing idle client");
67 freeClient(c);
68 return 1;
69 } else if (c->flags & CLIENT_BLOCKED) {
70 /* Cluster: handle unblock & redirect of clients blocked
71 * into keys no longer served by this server. */
72 if (server.cluster_enabled) {
73 if (clusterRedirectBlockedClientIfNeeded(c))
74 unblockClient(c);
75 }
76 }
77 return 0;
78}
79
80/* For blocked clients timeouts we populate a radix tree of 128 bit keys
81 * composed as such:

Callers 1

clientsCronFunction · 0.85

Calls 3

unblockClientFunction · 0.85
freeClientFunction · 0.70

Tested by

no test coverage detected