]> Cypherpunks repositories - gostls13.git/commitdiff
undo CL 13348045 / 43675523c526
authorRuss Cox <rsc@golang.org>
Thu, 12 Sep 2013 00:29:22 +0000 (20:29 -0400)
committerRob Pike <r@golang.org>
Thu, 12 Sep 2013 00:29:22 +0000 (20:29 -0400)
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

src/pkg/net/net.go

index 44288643d66593c300ddf88f77f745d53d24853e..2e6db5551430cb55e0d07da6706e6f8b1153013c 100644 (file)
@@ -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
 }