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

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

Issue 5593046: code review 5593046: net: replace error variable name e, errno with err (Closed)
Left Patch Set: diff -r f36b37b08176 https://go.googlecode.com/hg/ Created 13 years, 1 month ago
Right Patch Set: diff -r 05b67fff4f9c https://go.googlecode.com/hg/ Created 13 years, 1 month 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/fd_freebsd.go ('k') | src/pkg/net/fd_netbsd.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 // Waiting for FDs via epoll(7). 5 // Waiting for FDs via epoll(7).
6 6
7 package net 7 package net
8 8
9 import ( 9 import (
10 "os" 10 "os"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 for i < len(p.waitEvents) { 127 for i < len(p.waitEvents) {
128 if fd == int(p.waitEvents[i].Fd) { 128 if fd == int(p.waitEvents[i].Fd) {
129 copy(p.waitEvents[i:], p.waitEvents[i+1:]) 129 copy(p.waitEvents[i:], p.waitEvents[i+1:])
130 p.waitEvents = p.waitEvents[:len(p.waitEvents)-1] 130 p.waitEvents = p.waitEvents[:len(p.waitEvents)-1]
131 } else { 131 } else {
132 i++ 132 i++
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 func (p *pollster) WaitFD(s *pollServer, nsec int64) (int, int, error) { 137 func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err erro r) {
rsc 2012/01/29 17:44:45 Same.
mikio 2012/01/31 14:01:37 Done.
138 for len(p.waitEvents) == 0 { 138 for len(p.waitEvents) == 0 {
139 var msec int = -1 139 var msec int = -1
140 if nsec > 0 { 140 if nsec > 0 {
141 msec = int((nsec + 1e6 - 1) / 1e6) 141 msec = int((nsec + 1e6 - 1) / 1e6)
142 } 142 }
143 143
144 s.Unlock() 144 s.Unlock()
145 n, err := syscall.EpollWait(p.epfd, p.waitEventBuf[0:], msec) 145 n, err := syscall.EpollWait(p.epfd, p.waitEventBuf[0:], msec)
146 s.Lock() 146 s.Lock()
147 147
148 if err != nil { 148 if err != nil {
149 if err == syscall.EAGAIN || err == syscall.EINTR { 149 if err == syscall.EAGAIN || err == syscall.EINTR {
150 continue 150 continue
151 } 151 }
152 return -1, 0, os.NewSyscallError("epoll_wait", err) 152 return -1, 0, os.NewSyscallError("epoll_wait", err)
153 } 153 }
154 if n == 0 { 154 if n == 0 {
155 return -1, 0, nil 155 return -1, 0, nil
156 } 156 }
157 p.waitEvents = p.waitEventBuf[0:n] 157 p.waitEvents = p.waitEventBuf[0:n]
158 } 158 }
159 159
160 ev := &p.waitEvents[0] 160 ev := &p.waitEvents[0]
161 p.waitEvents = p.waitEvents[1:] 161 p.waitEvents = p.waitEvents[1:]
162 162
163 » fd := int(ev.Fd) 163 » fd = int(ev.Fd)
164 164
165 if ev.Events&writeFlags != 0 { 165 if ev.Events&writeFlags != 0 {
166 p.StopWaiting(fd, writeFlags) 166 p.StopWaiting(fd, writeFlags)
167 return fd, 'w', nil 167 return fd, 'w', nil
168 } 168 }
169 if ev.Events&readFlags != 0 { 169 if ev.Events&readFlags != 0 {
170 p.StopWaiting(fd, readFlags) 170 p.StopWaiting(fd, readFlags)
171 return fd, 'r', nil 171 return fd, 'r', nil
172 } 172 }
173 173
174 // Other events are error conditions - wake whoever is waiting. 174 // Other events are error conditions - wake whoever is waiting.
175 events, _ := p.events[fd] 175 events, _ := p.events[fd]
176 if events&writeFlags != 0 { 176 if events&writeFlags != 0 {
177 p.StopWaiting(fd, writeFlags) 177 p.StopWaiting(fd, writeFlags)
178 return fd, 'w', nil 178 return fd, 'w', nil
179 } 179 }
180 p.StopWaiting(fd, readFlags) 180 p.StopWaiting(fd, readFlags)
181 return fd, 'r', nil 181 return fd, 'r', nil
182 } 182 }
183 183
184 func (p *pollster) Close() error { 184 func (p *pollster) Close() error {
185 return os.NewSyscallError("close", syscall.Close(p.epfd)) 185 return os.NewSyscallError("close", syscall.Close(p.epfd))
186 } 186 }
LEFTRIGHT

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