Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(446)

Side by Side Diff: src/pkg/net/tcpsock_posix.go

Issue 6002053: code review 6002053: net: fix race between Close and Read (Closed)
Patch Set: diff -r b25d41fa3e5f https://go.googlecode.com/hg/ Created 11 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/net/iprawsock_posix.go ('k') | src/pkg/net/udpsock_posix.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux netbsd openbsd windows 5 // +build darwin freebsd linux netbsd openbsd windows
6 6
7 // TCP sockets 7 // TCP sockets
8 8
9 package net 9 package net
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return 0, syscall.EINVAL 101 return 0, syscall.EINVAL
102 } 102 }
103 return c.fd.Write(b) 103 return c.fd.Write(b)
104 } 104 }
105 105
106 // Close closes the TCP connection. 106 // Close closes the TCP connection.
107 func (c *TCPConn) Close() error { 107 func (c *TCPConn) Close() error {
108 if !c.ok() { 108 if !c.ok() {
109 return syscall.EINVAL 109 return syscall.EINVAL
110 } 110 }
111 » err := c.fd.Close() 111 » return c.fd.Close()
112 » c.fd = nil
113 » return err
114 } 112 }
115 113
116 // CloseRead shuts down the reading side of the TCP connection. 114 // CloseRead shuts down the reading side of the TCP connection.
117 // Most callers should just use Close. 115 // Most callers should just use Close.
118 func (c *TCPConn) CloseRead() error { 116 func (c *TCPConn) CloseRead() error {
119 if !c.ok() { 117 if !c.ok() {
120 return syscall.EINVAL 118 return syscall.EINVAL
121 } 119 }
122 return c.fd.CloseRead() 120 return c.fd.CloseRead()
123 } 121 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if l == nil || l.fd == nil { 352 if l == nil || l.fd == nil {
355 return syscall.EINVAL 353 return syscall.EINVAL
356 } 354 }
357 return setDeadline(l.fd, t) 355 return setDeadline(l.fd, t)
358 } 356 }
359 357
360 // File returns a copy of the underlying os.File, set to blocking mode. 358 // File returns a copy of the underlying os.File, set to blocking mode.
361 // It is the caller's responsibility to close f when finished. 359 // It is the caller's responsibility to close f when finished.
362 // Closing c does not affect f, and closing f does not affect c. 360 // Closing c does not affect f, and closing f does not affect c.
363 func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() } 361 func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() }
OLDNEW
« no previous file with comments | « src/pkg/net/iprawsock_posix.go ('k') | src/pkg/net/udpsock_posix.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b