Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

api/http/langos: ensure only one second peek #1947

Merged
merged 1 commit into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/http/langos/langos.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func (l *Langos) Read(p []byte) (n int, err error) {
case <-pe.done:
default:
// start the next peek while waiting for the current to finish
l.peek(l.cursor + int64(l.peekSize))
if len(l.peeks) == 0 { // ensure only one second peek
l.peek(l.cursor + int64(l.peekSize))
}
}

select {
Expand Down
2 changes: 1 addition & 1 deletion api/http/langos/langos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestLangosNumberOfReadCalls(t *testing.T) {
name: "3 seq reads, EOF",
peekSize: 6,
numReads: 3,
expReads: 5,
expReads: 4,
expErr: io.EOF,
},
{
Expand Down