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

Delta Between Two Patch Sets: src/pkg/net/tcpsock_posix.go

Issue 6002053: code review 6002053: net: fix race between Close and Read (Closed)
Left Patch Set: diff -r 762426ee0cca https://code.google.com/p/go Created 11 years, 11 months ago
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/iprawsock_posix.go ('k') | src/pkg/net/udpsock_posix.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 » return err
113 } 112 }
114 113
115 // CloseRead shuts down the reading side of the TCP connection. 114 // CloseRead shuts down the reading side of the TCP connection.
116 // Most callers should just use Close. 115 // Most callers should just use Close.
117 func (c *TCPConn) CloseRead() error { 116 func (c *TCPConn) CloseRead() error {
118 if !c.ok() { 117 if !c.ok() {
119 return syscall.EINVAL 118 return syscall.EINVAL
120 } 119 }
121 return c.fd.CloseRead() 120 return c.fd.CloseRead()
122 } 121 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if l == nil || l.fd == nil { 352 if l == nil || l.fd == nil {
354 return syscall.EINVAL 353 return syscall.EINVAL
355 } 354 }
356 return setDeadline(l.fd, t) 355 return setDeadline(l.fd, t)
357 } 356 }
358 357
359 // 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.
360 // It is the caller's responsibility to close f when finished. 359 // It is the caller's responsibility to close f when finished.
361 // 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.
362 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() }
LEFTRIGHT

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