mirror of
https://github.com/golang/go.git
synced 2024-09-29 14:26:50 +00:00
net: remove unnecessary Close contention.
Contention profile in BenchmarkTCPOneShot (Core 2 Quad): Before Total: 80.285 seconds 44.743 55.7% 55.7% 44.743 55.7% runtime.chanrecv1 31.995 39.9% 95.6% 31.995 39.9% sync.(*Mutex).Lock 3.547 4.4% 100.0% 3.547 4.4% runtime.chansend1 After Total: 48.341 seconds 45.810 94.8% 94.8% 45.810 94.8% runtime.chanrecv1 2.530 5.2% 100.0% 2.530 5.2% runtime.chansend1 0.001 0.0% 100.0% 0.001 0.0% sync.(*Mutex).Lock R=golang-dev, dave, mikioh.mikioh CC=golang-dev https://golang.org/cl/6845119
This commit is contained in:
parent
e3e885bb48
commit
b18a7c7cae
@ -375,8 +375,8 @@ func (fd *netFD) decref() {
|
||||
|
||||
func (fd *netFD) Close() error {
|
||||
fd.pollServer.Lock() // needed for both fd.incref(true) and pollserver.Evict
|
||||
defer fd.pollServer.Unlock()
|
||||
if err := fd.incref(true); err != nil {
|
||||
fd.pollServer.Unlock()
|
||||
return err
|
||||
}
|
||||
// Unblock any I/O. Once it all unblocks and returns,
|
||||
@ -385,6 +385,7 @@ func (fd *netFD) Close() error {
|
||||
// fairly quickly, since all the I/O is non-blocking, and any
|
||||
// attempts to block in the pollserver will return errClosing.
|
||||
fd.pollServer.Evict(fd)
|
||||
fd.pollServer.Unlock()
|
||||
fd.decref()
|
||||
return nil
|
||||
}
|
||||
|
@ -61,7 +61,6 @@ func socket(net string, f, t, p int, ipv6only bool, ulsa, ursa syscall.Sockaddr,
|
||||
}
|
||||
if err = fd.connect(ursa); err != nil {
|
||||
closesocket(s)
|
||||
fd.Close()
|
||||
return nil, err
|
||||
}
|
||||
fd.isConnected = true
|
||||
|
Loading…
Reference in New Issue
Block a user