mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user