fix goroutine leak

pull/6/head
Daniel Smith 2015-03-11 12:51:20 -07:00
parent c868b0bbf0
commit cc3a433a7a
1 changed files with 4 additions and 2 deletions

View File

@ -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