We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ca291b8 commit 5bbd39fCopy full SHA for 5bbd39f
x/mongo/driver/topology/pool.go
@@ -888,9 +888,15 @@ func peekConnectionAlive(conn *connection) (int, error) {
888
return 0, err
889
}
890
891
+ // Figre out how many bytes are already buffered.
892
+ buffered := conn.br.Buffered()
893
+
894
// Peek(1) will fill the bufio.Reader’s buffer if needed,
895
// but will NOT advance it.
- bytes, err := conn.br.Peek(1)
896
+ //
897
+ // Peek buffered+1 bytes, which will read exactly one new byte from the
898
+ // socket.
899
+ bytes, err := conn.br.Peek(buffered + 1)
900
return len(bytes), err
901
902
0 commit comments