From 69cdc02ebb931963c5eff9478d669faffa779fc6 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Wed, 20 Feb 2019 13:13:29 -0800 Subject: [PATCH] Const for maxFlushPending Signed-off-by: Derek Collison --- server/client.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/server/client.go b/server/client.go index 57e62d0c..24d596fc 100644 --- a/server/client.go +++ b/server/client.go @@ -60,14 +60,13 @@ const ( msgScratchSize = 1024 msgHeadProto = "RMSG " msgHeadProtoLen = len(msgHeadProto) -) -// For controlling dynamic buffer sizes. -const ( - startBufSize = 512 // For INFO/CONNECT block - minBufSize = 64 // Smallest to shrink to for PING/PONG - maxBufSize = 65536 // 64k - shortsToShrink = 2 + // For controlling dynamic buffer sizes. + startBufSize = 512 // For INFO/CONNECT block + minBufSize = 64 // Smallest to shrink to for PING/PONG + maxBufSize = 65536 // 64k + shortsToShrink = 2 // Trigger to shrink dynamic buffers + maxFlushPending = 10 // Max fsps to have in order to wait for writeLoop ) // Represent client booleans with a bitmask @@ -636,7 +635,7 @@ func (c *client) writeLoop() { // buffered outbound structure for efficient writev to the underlying socket. for { c.mu.Lock() - owtf := c.out.fsp > 0 && c.out.pb < maxBufSize && c.out.fsp < 10 + owtf := c.out.fsp > 0 && c.out.pb < maxBufSize && c.out.fsp < maxFlushPending if waitOk && (c.out.pb == 0 || owtf) && !c.flags.isSet(clearConnection) { // Wait on pending data. c.out.sgw = true