mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
fix goroutine leak
This commit is contained in:
parent
c868b0bbf0
commit
cc3a433a7a
@ -392,8 +392,10 @@ type resultFunc func() (runtime.Object, error)
|
|||||||
// finishRequest makes a given resultFunc asynchronous and handles errors returned by the response.
|
// 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.
|
// 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) {
|
func finishRequest(timeout time.Duration, fn resultFunc) (result runtime.Object, err error) {
|
||||||
ch := make(chan runtime.Object)
|
// these channels need to be buffered to prevent the goroutine below from hanging indefinitely
|
||||||
errCh := make(chan error)
|
// 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() {
|
go func() {
|
||||||
if result, err := fn(); err != nil {
|
if result, err := fn(); err != nil {
|
||||||
errCh <- err
|
errCh <- err
|
||||||
|
Loading…
Reference in New Issue
Block a user