Read only if there is something to read

Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
David Gageot 2015-12-28 11:32:31 +01:00
parent 232c0ea37e
commit 501c4f3460
1 changed files with 6 additions and 5 deletions

View File

@ -173,7 +173,7 @@ func stream(scanner *bufio.Scanner, streamOutCh chan<- string, stopCh <-chan boo
close(streamOutCh) close(streamOutCh)
return return
default: default:
scanner.Scan() if scanner.Scan() {
line := scanner.Text() line := scanner.Text()
if err := scanner.Err(); err != nil { if err := scanner.Err(); err != nil {
log.Warnf("Scanning stream: %s", err) log.Warnf("Scanning stream: %s", err)
@ -182,6 +182,7 @@ func stream(scanner *bufio.Scanner, streamOutCh chan<- string, stopCh <-chan boo
} }
} }
} }
}
func (lbp *Plugin) AttachStream(scanner *bufio.Scanner) (<-chan string, chan<- bool) { func (lbp *Plugin) AttachStream(scanner *bufio.Scanner) (<-chan string, chan<- bool) {
streamOutCh := make(chan string) streamOutCh := make(chan string)