1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:24:41 -07:00
Change-Id: Iee83b60a107cc4a24fda9bf6e0c0fadacb1bec03
This commit is contained in:
qiulaidongfeng 2024-08-29 11:01:26 +08:00
parent 6acb9f1a47
commit e0efaca829

View File

@ -378,8 +378,8 @@ func parentCancelCtx(parent Context) (*cancelCtx, bool) {
if !ok { if !ok {
return nil, false return nil, false
} }
pdone, _ := p.done.Load().(chan struct{}) pdone := p.done.Load()
if pdone != done { if pdone != nil && *pdone != done {
return nil, false return nil, false
} }
return p, true return p, true
@ -546,7 +546,7 @@ func (c *cancelCtx) cancel(removeFromParent bool, err, cause error) {
c.err = err c.err = err
c.cause = cause c.cause = cause
d := c.done.Load() d := c.done.Load()
if *d == nil { if d == nil {
c.done.Store(&closedchan) c.done.Store(&closedchan)
} else { } else {
close(*d) close(*d)