Skip to content

Commit

Permalink
Merge pull request kubernetes#5316 from lavalamp/fix6
Browse files Browse the repository at this point in the history
fix goroutine leak
  • Loading branch information
vmarmol committed Mar 11, 2015
2 parents 18d1a1e + cc3a433 commit 0aee25e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/apiserver/resthandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ type resultFunc func() (runtime.Object, error)
// finishRequest makes a given resultFunc asynchronous and handles errors returned by the response.
// Any api.Status object returned is considered an "error", which interrupts the normal response flow.
func finishRequest(timeout time.Duration, fn resultFunc) (result runtime.Object, err error) {
ch := make(chan runtime.Object)
errCh := make(chan error)
// these channels need to be buffered to prevent the goroutine below from hanging indefinitely
// when the select statement reads something other than the one the goroutine sends on.
ch := make(chan runtime.Object, 1)
errCh := make(chan error, 1)
go func() {
if result, err := fn(); err != nil {
errCh <- err
Expand Down

0 comments on commit 0aee25e

Please sign in to comment.