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

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

Issue 7188044: code review 7188044: net: Use accept4() on Linux. (Closed)
Left Patch Set: Created 11 years, 2 months ago
Right Patch Set: diff -r 2da48f86d386 https://code.google.com/p/go Created 11 years, 2 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:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 5 // +build darwin freebsd linux netbsd openbsd
6 6
7 package net 7 package net
8 8
9 import ( 9 import (
10 "os" 10 "os"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if sotype == syscall.SOCK_DGRAM { 54 if sotype == syscall.SOCK_DGRAM {
55 toAddr = sockaddrToUnixgram 55 toAddr = sockaddrToUnixgram
56 } else if sotype == syscall.SOCK_SEQPACKET { 56 } else if sotype == syscall.SOCK_SEQPACKET {
57 toAddr = sockaddrToUnixpacket 57 toAddr = sockaddrToUnixpacket
58 } 58 }
59 } 59 }
60 laddr := toAddr(lsa) 60 laddr := toAddr(lsa)
61 rsa, _ := syscall.Getpeername(fd) 61 rsa, _ := syscall.Getpeername(fd)
62 raddr := toAddr(rsa) 62 raddr := toAddr(rsa)
63 63
64 » netfd, err := newFD(fd, family, sotype, laddr.Network()) 64 » err = syscall.SetNonblock(fd, true)
65 if err != nil { 65 if err != nil {
66 closesocket(fd) 66 closesocket(fd)
67 return nil, err 67 return nil, err
68 } 68 }
69 netfd := newFD(fd, family, sotype, laddr.Network())
69 netfd.setAddr(laddr, raddr) 70 netfd.setAddr(laddr, raddr)
70 return netfd, nil 71 return netfd, nil
71 } 72 }
72 73
73 // FileConn returns a copy of the network connection corresponding to 74 // FileConn returns a copy of the network connection corresponding to
74 // the open file f. It is the caller's responsibility to close f when 75 // the open file f. It is the caller's responsibility to close f when
75 // finished. Closing c does not affect f, and closing f does not 76 // finished. Closing c does not affect f, and closing f does not
76 // affect c. 77 // affect c.
77 func FileConn(f *os.File) (c Conn, err error) { 78 func FileConn(f *os.File) (c Conn, err error) {
78 fd, err := newFileFD(f) 79 fd, err := newFileFD(f)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 124 }
124 switch fd.laddr.(type) { 125 switch fd.laddr.(type) {
125 case *UDPAddr: 126 case *UDPAddr:
126 return newUDPConn(fd), nil 127 return newUDPConn(fd), nil
127 case *UnixAddr: 128 case *UnixAddr:
128 return newUnixConn(fd), nil 129 return newUnixConn(fd), nil
129 } 130 }
130 fd.Close() 131 fd.Close()
131 return nil, syscall.EINVAL 132 return nil, syscall.EINVAL
132 } 133 }
LEFTRIGHT

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