mirror of https://github.com/jackc/pgx.git
Only count when bytes actually read
parent
6bc327b3ce
commit
9963c32d4f
internal/nbconn
|
@ -421,7 +421,6 @@ func (c *NetConn) fakeNonblockingRead(b []byte) (n int, err error) {
|
|||
// already in Go or the OS's receive buffer.
|
||||
if c.fakeNonBlockingShortReadCount < 5 && len(b) > 0 {
|
||||
b = b[:1]
|
||||
c.fakeNonBlockingShortReadCount++
|
||||
}
|
||||
|
||||
startTime := time.Now()
|
||||
|
@ -436,6 +435,10 @@ func (c *NetConn) fakeNonblockingRead(b []byte) (n int, err error) {
|
|||
if err == nil && c.fakeNonblockingReadWaitDuration > minNonblockingReadWaitDuration {
|
||||
endTime := time.Now()
|
||||
|
||||
if n > 0 && c.fakeNonBlockingShortReadCount < 5 {
|
||||
c.fakeNonBlockingShortReadCount++
|
||||
}
|
||||
|
||||
// The wait duration should be 2x the fastest read that has occurred. This should give reasonable assurance that
|
||||
// a Read deadline will not block a read before it has a chance to read data already in Go or the OS's receive
|
||||
// buffer.
|
||||
|
|
Loading…
Reference in New Issue