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

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

Issue 163052: code review 163052: Fix netFD.Close races demonstrated in Issues 321 and 271. (Closed)
Left Patch Set: code review 163052: Fix netFD.Close races Created 15 years, 4 months ago
Right Patch Set: code review 163052: Fix netFD.Close races demonstrated in Issues 321 and 271. Created 15 years, 4 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/sock.go ('k') | src/pkg/net/udpsock.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 // TCP sockets 5 // TCP sockets
6 6
7 package net 7 package net
8 8
9 import ( 9 import (
10 "os"; 10 "os";
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 // TCPConn is an implementation of the Conn interface 68 // TCPConn is an implementation of the Conn interface
69 // for TCP network connections. 69 // for TCP network connections.
70 type TCPConn struct { 70 type TCPConn struct {
71 fd *netFD; 71 fd *netFD;
72 } 72 }
73 73
74 func newTCPConn(fd *netFD) *TCPConn { 74 func newTCPConn(fd *netFD) *TCPConn {
75 c := &TCPConn{fd}; 75 c := &TCPConn{fd};
76 fd.getref();
77 defer fd.delref();
78 setsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1); 76 setsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1);
79 return c; 77 return c;
80 } 78 }
81 79
82 func (c *TCPConn) ok() bool { return c != nil && c.fd != nil } 80 func (c *TCPConn) ok() bool { return c != nil && c.fd != nil }
83 81
84 // Implementation of the Conn interface - see Conn for documentation. 82 // Implementation of the Conn interface - see Conn for documentation.
85 83
86 // Read reads data from the TCP connection. 84 // Read reads data from the TCP connection.
87 // 85 //
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // Already Accepted connections are not closed. 271 // Already Accepted connections are not closed.
274 func (l *TCPListener) Close() os.Error { 272 func (l *TCPListener) Close() os.Error {
275 if l == nil || l.fd == nil { 273 if l == nil || l.fd == nil {
276 return os.EINVAL 274 return os.EINVAL
277 } 275 }
278 return l.fd.Close(); 276 return l.fd.Close();
279 } 277 }
280 278
281 // Addr returns the listener's network address, a *TCPAddr. 279 // Addr returns the listener's network address, a *TCPAddr.
282 func (l *TCPListener) Addr() Addr { return l.fd.laddr } 280 func (l *TCPListener) Addr() Addr { return l.fd.laddr }
LEFTRIGHT

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