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

Delta Between Two Patch Sets: src/pkg/net/udpsock.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/tcpsock.go ('k') | src/pkg/net/unixsock.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 // UDP sockets 5 // UDP 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 // UDPConn is the implementation of the Conn and PacketConn 68 // UDPConn is the implementation of the Conn and PacketConn
69 // interfaces for UDP network connections. 69 // interfaces for UDP network connections.
70 type UDPConn struct { 70 type UDPConn struct {
71 fd *netFD; 71 fd *netFD;
72 } 72 }
73 73
74 func newUDPConn(fd *netFD) *UDPConn { 74 func newUDPConn(fd *netFD) *UDPConn {
75 c := &UDPConn{fd}; 75 c := &UDPConn{fd};
76 fd.getref();
77 defer fd.delref();
78 setsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1); 76 setsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1);
79 return c; 77 return c;
80 } 78 }
81 79
82 func (c *UDPConn) ok() bool { return c != nil && c.fd != nil } 80 func (c *UDPConn) 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 a single UDP packet on the connection. 84 // Read reads data from a single UDP packet on the connection.
87 // If the slice b is smaller than the arriving packet, 85 // If the slice b is smaller than the arriving packet,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 279 }
282 if laddr == nil { 280 if laddr == nil {
283 return nil, &OpError{"listen", "udp", nil, errMissingAddress} 281 return nil, &OpError{"listen", "udp", nil, errMissingAddress}
284 } 282 }
285 fd, e := internetSocket(net, laddr.toAddr(), nil, syscall.SOCK_DGRAM, "d ial", sockaddrToUDP); 283 fd, e := internetSocket(net, laddr.toAddr(), nil, syscall.SOCK_DGRAM, "d ial", sockaddrToUDP);
286 if e != nil { 284 if e != nil {
287 return nil, e 285 return nil, e
288 } 286 }
289 return newUDPConn(fd), nil; 287 return newUDPConn(fd), nil;
290 } 288 }
LEFTRIGHT

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