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
| 3910 | * |
| 3911 | * Returns 1 if client was (flagged) closed. */ |
| 3912 | int 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. |
no test coverage detected