logReadCloser: ensure loop terminates if channels are closed

Adding the !EOF check to the loop condition ensures not reading from closed channels.
This commit is contained in:
Roberto Bruggemann
2018-01-19 14:23:13 +00:00
parent d1d370ce01
commit 9198f6b38b

View File

@@ -84,7 +84,7 @@ func (l *logReadCloser) Read(p []byte) (int, error) {
// check if there's more data to read, without blocking
empty := false
for !empty && l.buffer.Len() < len(p) {
for !empty && l.buffer.Len() < len(p) && !l.isEOF() {
select {
case data := <-l.dataChannel:
l.buffer.Write(data)