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

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

Issue 6460108: net: epoll dispatcher 2
Left Patch Set: diff -r ac1b735e8753 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/sockopt_linux.go ('k') | src/pkg/net/sockopt_unix.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 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 // +build darwin freebsd linux netbsd openbsd windows 5 // +build darwin freebsd linux netbsd openbsd windows
6 6
7 // Socket options 7 // Socket options
8 8
9 package net 9 package net
10 10
11 import ( 11 import (
12 "os" 12 "os"
13 "syscall" 13 "syscall"
14 "time"
15 ) 14 )
16 15
17 // Boolean to int. 16 // Boolean to int.
18 func boolint(b bool) int { 17 func boolint(b bool) int {
19 if b { 18 if b {
20 return 1 19 return 1
21 } 20 }
22 return 0 21 return 0
23 } 22 }
24 23
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 111 }
113 112
114 func setWriteBuffer(fd *netFD, bytes int) error { 113 func setWriteBuffer(fd *netFD, bytes int) error {
115 if err := fd.incref(false); err != nil { 114 if err := fd.incref(false); err != nil {
116 return err 115 return err
117 } 116 }
118 defer fd.decref() 117 defer fd.decref()
119 return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_SNDBUF, bytes)) 118 return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_SNDBUF, bytes))
120 } 119 }
121 120
122 func setReadDeadline(fd *netFD, t time.Time) error { 121 func setReuseAddr(fd *netFD, reuse bool) error {
123 » if t.IsZero() { 122 » if err := fd.incref(false); err != nil {
124 » » fd.rdeadline = 0 123 » » return err
125 » } else {
126 » » fd.rdeadline = t.UnixNano()
127 } 124 }
128 » return nil 125 » defer fd.decref()
126 » return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, boolint(reuse)))
129 } 127 }
130 128
131 func setWriteDeadline(fd *netFD, t time.Time) error { 129 func setDontRoute(fd *netFD, dontroute bool) error {
132 » if t.IsZero() { 130 » if err := fd.incref(false); err != nil {
133 » » fd.wdeadline = 0
134 » } else {
135 » » fd.wdeadline = t.UnixNano()
136 » }
137 » return nil
138 }
139
140 func setDeadline(fd *netFD, t time.Time) error {
141 » if err := setReadDeadline(fd, t); err != nil {
142 return err 131 return err
143 } 132 }
144 » return setWriteDeadline(fd, t) 133 » defer fd.decref()
134 » return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_DONTROUTE, boolint(dontroute)))
145 } 135 }
146 136
147 func setKeepAlive(fd *netFD, keepalive bool) error { 137 func setKeepAlive(fd *netFD, keepalive bool) error {
148 if err := fd.incref(false); err != nil { 138 if err := fd.incref(false); err != nil {
149 return err 139 return err
150 } 140 }
151 defer fd.decref() 141 defer fd.decref()
152 return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, boolint(keepalive))) 142 return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, boolint(keepalive)))
153 } 143 }
154 144
(...skipping 13 matching lines...) Expand all
168 } else { 158 } else {
169 l.Onoff = 0 159 l.Onoff = 0
170 l.Linger = 0 160 l.Linger = 0
171 } 161 }
172 if err := fd.incref(false); err != nil { 162 if err := fd.incref(false); err != nil {
173 return err 163 return err
174 } 164 }
175 defer fd.decref() 165 defer fd.decref()
176 return os.NewSyscallError("setsockopt", syscall.SetsockoptLinger(fd.sysf d, syscall.SOL_SOCKET, syscall.SO_LINGER, &l)) 166 return os.NewSyscallError("setsockopt", syscall.SetsockoptLinger(fd.sysf d, syscall.SOL_SOCKET, syscall.SO_LINGER, &l))
177 } 167 }
LEFTRIGHT

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