diff --git a/src/pkg/net/net.go b/src/pkg/net/net.go index 44288643d66593c300ddf88f77f745d53d24853e..2e6db5551430cb55e0d07da6706e6f8b1153013c 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 }