diff options
author | Austin Clements <austin@google.com> | 2016-02-15 17:37:04 -0500 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2016-03-16 20:13:02 +0000 |
commit | e4a95b63433cc95c81782713b917b2941e48cb39 (patch) | |
tree | c75e4309ada98df7b4a5bd9e2d177983cc417c1f /src/runtime/chan.go | |
parent | d7cedc4b74f902a3a1b429fb27f85380f6955a6f (diff) | |
download | go-e4a95b63433cc95c81782713b917b2941e48cb39.tar.gz go-e4a95b63433cc95c81782713b917b2941e48cb39.zip |
runtime: record channel in sudog
Given a G, there's currently no way to find the channel it's blocking
on. We'll need this information to fix a (probably theoretical) bug in
select and to implement concurrent stack shrinking, so record the
channel in the sudog.
For #12967.
Change-Id: If8fb63a140f1d07175818824d08c0ebeec2bdf66
Reviewed-on: https://go-review.googlesource.com/20035
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/chan.go')
-rw-r--r-- | src/runtime/chan.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/chan.go b/src/runtime/chan.go index 85cbe5a5a7..cc64d30a68 100644 --- a/src/runtime/chan.go +++ b/src/runtime/chan.go @@ -209,6 +209,7 @@ func chansend(t *chantype, c *hchan, ep unsafe.Pointer, block bool, callerpc uin mysg.waitlink = nil mysg.g = gp mysg.selectdone = nil + mysg.c = c gp.waiting = mysg gp.param = nil c.sendq.enqueue(mysg) @@ -229,6 +230,7 @@ func chansend(t *chantype, c *hchan, ep unsafe.Pointer, block bool, callerpc uin if mysg.releasetime > 0 { blockevent(mysg.releasetime-t0, 2) } + mysg.c = nil releaseSudog(mysg) return true } @@ -469,6 +471,7 @@ func chanrecv(t *chantype, c *hchan, ep unsafe.Pointer, block bool) (selected, r gp.waiting = mysg mysg.g = gp mysg.selectdone = nil + mysg.c = c gp.param = nil c.recvq.enqueue(mysg) goparkunlock(&c.lock, "chan receive", traceEvGoBlockRecv, 3) @@ -483,6 +486,7 @@ func chanrecv(t *chantype, c *hchan, ep unsafe.Pointer, block bool) (selected, r } closed := gp.param == nil gp.param = nil + mysg.c = nil releaseSudog(mysg) return true, !closed } |