From 4eaf69dfa73a0653fb61bb32f0a0b7513cb55323 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sat, 27 Jul 2024 06:58:40 +0800 Subject: [PATCH] internal/runtime: fix endSelect --- internal/runtime/z_chan.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/runtime/z_chan.go b/internal/runtime/z_chan.go index 950c6096..fca39e59 100644 --- a/internal/runtime/z_chan.go +++ b/internal/runtime/z_chan.go @@ -239,6 +239,12 @@ func (p *selectOp) init() { p.sem = false } +func (p *selectOp) end() { + p.mutex.Destroy() + p.cond.Destroy() + p.next = nil +} + func (p *selectOp) notify() { p.mutex.Lock() p.sem = true @@ -299,6 +305,7 @@ func Select(ops ...ChanOp) (isel int, recvOK bool) { for _, op := range ops { endSelect(op.C, selOp) } + selOp.end() return } @@ -317,7 +324,6 @@ func endSelect(c *Chan, selOp *selectOp) { } *pp = selOp.next c.mutex.Unlock() - selOp.next = nil } // -----------------------------------------------------------------------------