Add defensive check to safeguard from future #3342s

I hate adding "this should never happen" checks, but causing a tight
loop that OOMs Nomad is just too easy in this code otherwise.
This commit is contained in:
Michael Schurter
2017-11-30 20:37:13 -08:00
parent ac3fffc118
commit 13a69bda82

View File

@@ -923,6 +923,20 @@ func (s *HTTPServer) logs(follow, plain bool, offset int64,
return nil
}
// defensively check to make sure StreamFramer hasn't stopped
// running to avoid tight loops with goroutine leaks as in
// #3342
select {
case <-framer.ExitCh():
err := parseFramerErr(framer.Err())
if err == syscall.EPIPE {
// EPIPE just means the connection was closed
return nil
}
return err
default:
}
// Since we successfully streamed, update the overall offset/idx.
offset = int64(0)
nextIdx = idx + 1