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

Function closeClientOnOutputBufferLimitReached

src/networking.cpp:3912–3934  ·  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

3910 *
3911 * Returns 1 if client was (flagged) closed. */
3912int closeClientOnOutputBufferLimitReached(client *c, int async) {
3913 if (!c->conn) return 0; /* It is unsafe to free fake clients. */
3914 serverAssert(c->reply_bytes < SIZE_MAX-(1024*64));
3915 if (c->reply_bytes == 0 || c->flags & CLIENT_CLOSE_ASAP) return 0;
3916 if (checkClientOutputBufferLimits(c) && c->replstate != SLAVE_STATE_FASTSYNC_TX) {
3917 sds client = catClientInfoString(sdsempty(),c);
3918
3919 if (async) {
3920 freeClientAsync(c);
3921 serverLog(LL_WARNING,
3922 "Client %s scheduled to be closed ASAP for overcoming of output buffer limits.",
3923 client);
3924 } else {
3925 freeClient(c);
3926 serverLog(LL_WARNING,
3927 "Client %s closed for overcoming of output buffer limits.",
3928 client);
3929 }
3930 sdsfree(client);
3931 return 1;
3932 }
3933 return 0;
3934}
3935
3936/* Helper function used by performEvictions() in order to flush slaves
3937 * output buffers without returning control to the event loop.

Callers 5

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

Calls 7

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

Tested by

no test coverage detected