From: Russ Cox Date: Thu, 12 Sep 2013 00:29:22 +0000 (-0400) Subject: undo CL 13348045 / 43675523c526 X-Git-Tag: go1.2rc2~244 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bab302dea2f31e1ab04d17bc42050d0610c15793;p=gostls13.git undo CL 13348045 / 43675523c526 There is no reason to do this, and it's more work. ««« original CL description net: make channel-based semaphore depend on receive, not send R=r, dvyukov CC=golang-dev https://golang.org/cl/13348045 »»» R=golang-dev, r CC=golang-dev https://golang.org/cl/13632047 --- diff --git a/src/pkg/net/net.go b/src/pkg/net/net.go index 44288643d6..2e6db55514 100644 --- a/src/pkg/net/net.go +++ b/src/pkg/net/net.go @@ -408,16 +408,14 @@ func genericReadFrom(w io.Writer, r io.Reader) (n int64, err error) { var threadLimit = make(chan struct{}, 500) -func init() { - for i := 0; i < cap(threadLimit); i++ { - threadLimit <- struct{}{} - } -} +// Using send for acquire is fine here because we are not using this +// to protect any memory. All we care about is the number of goroutines +// making calls at a time. func acquireThread() { - <-threadLimit + threadLimit <- struct{}{} } func releaseThread() { - threadLimit <- struct{}{} + <-threadLimit }