From: Robert Daniel Kortschak Date: Thu, 29 Aug 2013 07:14:57 +0000 (+1000) Subject: net: make channel-based semaphore depend on receive, not send X-Git-Tag: go1.2rc2~396 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b3fd434ae07db5cf6385fb6b97a467e6f312c253;p=gostls13.git net: make channel-based semaphore depend on receive, not send R=r, dvyukov CC=golang-dev https://golang.org/cl/13348045 --- diff --git a/src/pkg/net/net.go b/src/pkg/net/net.go index c918e96b43..4f177c64ed 100644 --- a/src/pkg/net/net.go +++ b/src/pkg/net/net.go @@ -442,10 +442,16 @@ func (d *deadline) setTime(t time.Time) { var threadLimit = make(chan struct{}, 500) +func init() { + for i := 0; i < cap(threadLimit); i++ { + threadLimit <- struct{}{} + } +} + func acquireThread() { - threadLimit <- struct{}{} + <-threadLimit } func releaseThread() { - <-threadLimit + threadLimit <- struct{}{} }