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