mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user