mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-09 00:34:10 -04:00
Fix potential goroutine leak in operation_executor_test.go
If the test times out in isOperationRunConcurrently, the receiver channel stops listening. The goroutine spawned in startOperationAndBlock then blocks forever on ch <- nil. This commit updates startOperationAndBlock to use a select statement. It now waits for either the send to complete or the quit channel to be closed (signaling test completion). This ensures the goroutine exits cleanly even if the receiver is gone. Signed-off-by: kkh <kkhdevs@gmail.com>
This commit is contained in:
parent
18663b347e
commit
d733195cfe
1 changed files with 5 additions and 2 deletions
|
|
@ -185,6 +185,9 @@ func setup(t *testing.T) (context.Context, chan interface{}, chan interface{}, O
|
|||
// This function starts by writing to ch and blocks on the quit channel
|
||||
// until it is closed by the currently running test
|
||||
func startOperationAndBlock(ch chan<- interface{}, quit <-chan interface{}) {
|
||||
ch <- nil
|
||||
<-quit
|
||||
select {
|
||||
case ch <- nil:
|
||||
<-quit
|
||||
case <-quit:
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue