From cc3a433a7abc89d2f766d4c87eaae9448e3dc091 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Wed, 11 Mar 2015 12:51:20 -0700 Subject: [PATCH] fix goroutine leak --- pkg/apiserver/resthandler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/resthandler.go b/pkg/apiserver/resthandler.go index 0d924b4ecfb..ef627178b35 100644 --- a/pkg/apiserver/resthandler.go +++ b/pkg/apiserver/resthandler.go @@ -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