diff options
author | antirez <antirez@gmail.com> | 2018-07-03 13:23:29 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-07-03 13:23:29 +0200 |
commit | 549b8b99733e49d2464666a22da8b56b1d9a3b52 (patch) | |
tree | 714ad62dd8bd0c6a4af1a67cf606c554d1310f50 | |
parent | 526b30a7ce654e8418708f98100f0321396315df (diff) | |
download | redis-549b8b99733e49d2464666a22da8b56b1d9a3b52.tar.gz |
Improve style of PR #5084.
-rw-r--r-- | src/server.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/server.c b/src/server.c index 7e3533e3a..b7d1e5e82 100644 --- a/src/server.c +++ b/src/server.c @@ -860,13 +860,19 @@ int clientsCronResizeQueryBuffer(client *c) { * cycle. */ 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) { /* There are two conditions to resize the pending query buffer: * 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); 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); } } |