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

Function closeClientOnOutputBufferLimitReached

app/redis-6.2.6/src/networking.c:3267–3289  ·  view source on GitHub ↗

Asynchronously close a client if soft or hard limit is reached on the * output buffer size. The caller can check if the client will be closed * checking if the client CLIENT_CLOSE_ASAP flag is set. * * Note: we need to close the client asynchronously because this function is * called from contexts where the client can't be freed safely, i.e. from the * lower level functions pushing data insi

Source from the content-addressed store, hash-verified

3265 *
3266 * Returns 1 if client was (flagged) closed. */
3267int closeClientOnOutputBufferLimitReached(client *c, int async) {
3268 if (!c->conn) return 0; /* It is unsafe to free fake clients. */
3269 serverAssert(c->reply_bytes < SIZE_MAX-(1024*64));
3270 if (c->reply_bytes == 0 || c->flags & CLIENT_CLOSE_ASAP) return 0;
3271 if (checkClientOutputBufferLimits(c)) {
3272 sds client = catClientInfoString(sdsempty(),c);
3273
3274 if (async) {
3275 freeClientAsync(c);
3276 serverLog(LL_WARNING,
3277 "Client %s scheduled to be closed ASAP for overcoming of output buffer limits.",
3278 client);
3279 } else {
3280 freeClient(c);
3281 serverLog(LL_WARNING,
3282 "Client %s closed for overcoming of output buffer limits.",
3283 client);
3284 }
3285 sdsfree(client);
3286 return 1;
3287 }
3288 return 0;
3289}
3290
3291/* Helper function used by performEvictions() in order to flush slaves
3292 * output buffers without returning control to the event loop.

Callers 4

clientsCronFunction · 0.85
_addReplyProtoToListFunction · 0.85
setDeferredReplyFunction · 0.85
AddReplyFromClientFunction · 0.85

Calls 6

catClientInfoStringFunction · 0.85
sdsemptyFunction · 0.85
freeClientAsyncFunction · 0.85
sdsfreeFunction · 0.85
freeClientFunction · 0.70

Tested by

no test coverage detected