logReadCloser: ensure reader errors yield EOF

This change makes the underlying reader set their corresponding `eof` slot to true on termination.
This make the overall logReadCloser converge to EOF in case of errors of the underlying readers, therefore prevent spinning on read.

`bufio.Reader.ReadBytes` may not return io.EOF when `Close()` closes the underlying reader.
For instance, closing logReadCloser from the Scope App makes `bufio.Reader.ReadBytes` produce the following error: `http2: response body closed`.
This commit is contained in:
Roberto Bruggemann
2018-01-19 10:42:57 +00:00
parent f3c1183cd9
commit d1d370ce01

View File

@@ -130,7 +130,6 @@ func (l *logReadCloser) readInput(idx int) {
if len(line) > 0 {
l.dataChannel <- l.annotateLine(idx, line)
}
l.eofChannel <- idx
break
}
if err != nil {
@@ -139,6 +138,8 @@ func (l *logReadCloser) readInput(idx int) {
}
l.dataChannel <- l.annotateLine(idx, line)
}
l.eofChannel <- idx
}
func (l *logReadCloser) annotateLine(idx int, line []byte) []byte {