]> Cypherpunks repositories - gostls13.git/commitdiff
net: make channel-based semaphore depend on receive, not send
authorRobert Daniel Kortschak <dan.kortschak@adelaide.edu.au>
Thu, 29 Aug 2013 07:14:57 +0000 (17:14 +1000)
committerRob Pike <r@golang.org>
Thu, 29 Aug 2013 07:14:57 +0000 (17:14 +1000)
R=r, dvyukov
CC=golang-dev
https://golang.org/cl/13348045

src/pkg/net/net.go

index c918e96b430f2a792272bd9fc9751b3f79b1a277..4f177c64edfd251ad4996c5cd389d3028afac79d 100644 (file)
@@ -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{}{}
 }