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

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

Issue 164057: code review 164057: 'close' race fixed/suggestions from rcs (Closed)
Left Patch Set: code review 164057: 'close' race fixed/suggestions from rcs Created 15 years, 4 months ago
Right Patch Set: code review 164057: 'close' race fixed/suggestions from rcs 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
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.locksysfd(); 76 » fd.incref();
rsc 2009/12/01 19:58:56 There's no need for the incref/decref here. This i
77 » defer fd.unlocksysfd(); 77 » defer fd.decref();
78 setsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1); 78 setsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1);
79 return c; 79 return c;
80 } 80 }
81 81
82 func (c *TCPConn) ok() bool { return c != nil && c.fd != nil } 82 func (c *TCPConn) ok() bool { return c != nil && c.fd != nil }
83 83
84 // Implementation of the Conn interface - see Conn for documentation. 84 // Implementation of the Conn interface - see Conn for documentation.
85 85
86 // Read reads data from the TCP connection. 86 // Read reads data from the TCP connection.
87 // 87 //
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // Already Accepted connections are not closed. 273 // Already Accepted connections are not closed.
274 func (l *TCPListener) Close() os.Error { 274 func (l *TCPListener) Close() os.Error {
275 if l == nil || l.fd == nil { 275 if l == nil || l.fd == nil {
276 return os.EINVAL 276 return os.EINVAL
277 } 277 }
278 return l.fd.Close(); 278 return l.fd.Close();
279 } 279 }
280 280
281 // Addr returns the listener's network address, a *TCPAddr. 281 // Addr returns the listener's network address, a *TCPAddr.
282 func (l *TCPListener) Addr() Addr { return l.fd.laddr } 282 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