From 8f46c75e73c99e4d75d3601fb41bb8f7609e5efd Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 25 Feb 2023 16:45:34 -0600 Subject: [PATCH] Fix: fake non-blocking read adaptive wait time If the time reached the minimum time before the 5 tries were up it would get stuck reading 1 byte at a time indefinitely. --- internal/nbconn/nbconn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/nbconn/nbconn.go b/internal/nbconn/nbconn.go index 61b610a4..7a38383f 100644 --- a/internal/nbconn/nbconn.go +++ b/internal/nbconn/nbconn.go @@ -419,7 +419,7 @@ func (c *NetConn) fakeNonblockingRead(b []byte) (n int, err error) { // The first 5 reads only read 1 byte at a time. This should give us 4 chances to read when we are sure the bytes are // already in Go or the OS's receive buffer. - if c.fakeNonBlockingShortReadCount < 5 && len(b) > 0 { + if c.fakeNonBlockingShortReadCount < 5 && len(b) > 0 && c.fakeNonblockingReadWaitDuration < minNonblockingReadWaitDuration { b = b[:1] }