]> Cypherpunks repositories - gostls13.git/commit
runtime: protect sudog.elem with hchan.lock
authorAustin Clements <austin@google.com>
Thu, 18 Feb 2016 14:34:43 +0000 (09:34 -0500)
committerAustin Clements <austin@google.com>
Wed, 16 Mar 2016 20:13:15 +0000 (20:13 +0000)
commitdb72b41bcd67ecb80890d586effbabd8d110952c
treed351d5b1adbbf61ef0161d472f27b027713f1716
parent3c2a21ff13c53b93db50cfb37b186d6200e2ceec
runtime: protect sudog.elem with hchan.lock

Currently sudog.elem is never accessed concurrently, so in several
cases we drop the channel lock just before reading/writing the
sent/received value from/to sudog.elem. However, concurrent stack
shrinking is going to have to adjust sudog.elem to point to the new
stack, which means it needs a way to synchronize with accesses to
sudog.elem. Hence, add sudog.elem to the fields protected by
hchan.lock and scoot the unlocks down past the uses of sudog.elem.

While we're here, better document the channel synchronization rules.

For #12967.

Change-Id: I3ad0ca71f0a74b0716c261aef21b2f7f13f74917
Reviewed-on: https://go-review.googlesource.com/20040
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/runtime/chan.go
src/runtime/runtime2.go