internal/runtime: fix endSelect

This commit is contained in:
visualfc
2024-07-27 06:58:40 +08:00
parent bc584aa56e
commit 4eaf69dfa7

View File

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