summaryrefslogtreecommitdiff
path: root/src/pkg/bytes/buffer.go
diff options
context:
space:
mode:
authorAdam Langley <agl@golang.org>2009-12-18 12:25:53 -0800
committerAdam Langley <agl@golang.org>2009-12-18 12:25:53 -0800
commit2be9df1cca7061c90a405bb2da7310794ae5bfe9 (patch)
tree402229af2bae3c4bff0aa3489637389c3a4e590b /src/pkg/bytes/buffer.go
parent691eee4258d311e48f7e322243e927be764d061d (diff)
downloadgolang-2be9df1cca7061c90a405bb2da7310794ae5bfe9.tar.gz
runtime: fix race condition
(Thanks to ken and rsc for pointing this out) rsc: ken pointed out that there's a race in the new one-lock-per-channel code. the issue is that if one goroutine has gone to sleep doing select { case <-c1: case <-c2: } and then two more goroutines try to send on c1 and c2 simultaneously, the way that the code makes sure only one wins is the selgen field manipulation in dequeue: // if sgp is stale, ignore it if(sgp->selgen != sgp->g->selgen) { //prints("INVALID PSEUDOG POINTER\n"); freesg(c, sgp); goto loop; } // invalidate any others sgp->g->selgen++; but because the global lock is gone both goroutines will be fiddling with sgp->g->selgen at the same time. This results in a 7% slowdown in the single threaded case for a ping-pong microbenchmark. Since the cas predominantly succeeds, adding a simple check first didn't make any difference. R=rsc CC=golang-dev http://codereview.appspot.com/180068
Diffstat (limited to 'src/pkg/bytes/buffer.go')
0 files changed, 0 insertions, 0 deletions