Improve style of PR #5084.

This commit is contained in:
antirez 2018-07-03 13:23:29 +02:00
parent 526b30a7ce
commit 549b8b9973

View File

@ -860,13 +860,19 @@ int clientsCronResizeQueryBuffer(client *c) {
* cycle. */ * cycle. */
c->querybuf_peak = 0; c->querybuf_peak = 0;
/* Clients representing masters also use a "pending query buffer" that
* is the yet not applied part of the stream we are reading. Such buffer
* also needs resizing from time to time, otherwise after a very large
* transfer (a huge value or a big MIGRATE operation) it will keep using
* a lot of memory. */
if (c->flags & CLIENT_MASTER) { if (c->flags & CLIENT_MASTER) {
/* There are two conditions to resize the pending query buffer: /* There are two conditions to resize the pending query buffer:
* 1) Pending Query buffer is > LIMIT_PENDING_QUERYBUF. * 1) Pending Query buffer is > LIMIT_PENDING_QUERYBUF.
* 2) used length is smaller than pending_querybuf_size/2 */ * 2) Used length is smaller than pending_querybuf_size/2 */
size_t pending_querybuf_size = sdsAllocSize(c->pending_querybuf); size_t pending_querybuf_size = sdsAllocSize(c->pending_querybuf);
if(pending_querybuf_size > LIMIT_PENDING_QUERYBUF && if(pending_querybuf_size > LIMIT_PENDING_QUERYBUF &&
sdslen(c->pending_querybuf) < (pending_querybuf_size>>1)){ sdslen(c->pending_querybuf) < (pending_querybuf_size/2))
{
c->pending_querybuf = sdsRemoveFreeSpace(c->pending_querybuf); c->pending_querybuf = sdsRemoveFreeSpace(c->pending_querybuf);
} }
} }