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

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

Issue 6460108: net: epoll dispatcher 2
Left Patch Set: diff -r 2518eee18c4f https://go.googlecode.com/hg/ Created 11 years, 7 months ago
Right Patch Set: diff -r f2755950769b https://dvyukov%40google.com@code.google.com/p/go/ Created 11 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:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/sock_posix.go ('k') | src/pkg/net/sockopt_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
(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 // Socket options for Linux 5 // Socket options for Linux
6 6
7 package net 7 package net
8 8
9 import ( 9 import (
10 "os" 10 "os"
11 "syscall" 11 "syscall"
12 "time"
12 ) 13 )
14
15 func deadlineNano(t time.Time) int64 {
16 if t.IsZero() {
17 return 0
18 }
19 return t.UnixNano()
20 }
21
22 func setDeadlineImpl(fd *netFD, t time.Time, mode int) error {
23 d := t.UnixNano()
24 if t.IsZero() {
25 d = 0
26 }
27 if err := fd.incref(false); err != nil {
28 return err
29 }
30 defer fd.decref()
31 runtime_setDeadlineFD(fd.pollServer, d, mode)
32 return nil
33 }
34
35 func setReadDeadline(fd *netFD, t time.Time) error {
36 return setDeadlineImpl(fd, t, 'r')
37 }
38
39 func setWriteDeadline(fd *netFD, t time.Time) error {
40 return setDeadlineImpl(fd, t, 'w')
41 }
42
43 func setDeadline(fd *netFD, t time.Time) error {
44 return setDeadlineImpl(fd, t, 'r'+'w')
45 }
13 46
14 func setDefaultSockopts(s, f, t int, ipv6only bool) error { 47 func setDefaultSockopts(s, f, t int, ipv6only bool) error {
15 switch f { 48 switch f {
16 case syscall.AF_INET6: 49 case syscall.AF_INET6:
17 if ipv6only { 50 if ipv6only {
18 syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.I PV6_V6ONLY, 1) 51 syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.I PV6_V6ONLY, 1)
19 } else { 52 } else {
20 // Allow both IP versions even if the OS default 53 // Allow both IP versions even if the OS default
21 // is otherwise. Note that some operating systems 54 // is otherwise. Note that some operating systems
22 // never admit this option. 55 // never admit this option.
(...skipping 19 matching lines...) Expand all
42 75
43 func setDefaultMulticastSockopts(s int) error { 76 func setDefaultMulticastSockopts(s int) error {
44 // Allow multicast UDP and raw IP datagram sockets to listen 77 // Allow multicast UDP and raw IP datagram sockets to listen
45 // concurrently across multiple listeners. 78 // concurrently across multiple listeners.
46 err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR , 1) 79 err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR , 1)
47 if err != nil { 80 if err != nil {
48 return os.NewSyscallError("setsockopt", err) 81 return os.NewSyscallError("setsockopt", err)
49 } 82 }
50 return nil 83 return nil
51 } 84 }
LEFTRIGHT

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