From 839208f118793c665f48a057d1f35d74979b7916 Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Mon, 1 Jun 2020 09:56:52 -0700 Subject: Enable TCP Receive buffer moderation in gonet and benchmark. Fixes #1666 PiperOrigin-RevId: 314148384 --- pkg/tcpip/adapters/gonet/gonet.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'pkg') diff --git a/pkg/tcpip/adapters/gonet/gonet.go b/pkg/tcpip/adapters/gonet/gonet.go index 6e0db2741..d82ed5205 100644 --- a/pkg/tcpip/adapters/gonet/gonet.go +++ b/pkg/tcpip/adapters/gonet/gonet.go @@ -335,6 +335,11 @@ func (c *TCPConn) Read(b []byte) (int, error) { deadline := c.readCancel() numRead := 0 + defer func() { + if numRead != 0 { + c.ep.ModerateRecvBuf(numRead) + } + }() for numRead != len(b) { if len(c.read) == 0 { var err error -- cgit v1.2.3