Skip to content

Commit

Permalink
Add defensive check to safeguard from future #3342s
Browse files Browse the repository at this point in the history
I hate adding "this should never happen" checks, but causing a tight
loop that OOMs Nomad is just too easy in this code otherwise.
  • Loading branch information
schmichael committed Dec 1, 2017
1 parent ac3fffc commit 13a69bd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions command/agent/fs_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 13a69bd

Please sign in to comment.