Commit 0b8f1ac8 authored by Ian Lance Taylor's avatar Ian Lance Taylor

net: If we stop polling, remove any pending events for the socket

Fixes #1872.

R=rsc
CC=golang-dev, lars.pensjo
https://golang.org/cl/4559046
parent a1c92c61
...@@ -117,6 +117,17 @@ func (p *pollster) DelFD(fd int, mode int) { ...@@ -117,6 +117,17 @@ func (p *pollster) DelFD(fd int, mode int) {
} else { } else {
p.StopWaiting(fd, writeFlags) p.StopWaiting(fd, writeFlags)
} }
// Discard any queued up events.
i := 0
for i < len(p.waitEvents) {
if fd == int(p.waitEvents[i].Fd) {
copy(p.waitEvents[i:], p.waitEvents[i+1:])
p.waitEvents = p.waitEvents[:len(p.waitEvents)-1]
} else {
i++
}
}
} }
func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.Error) { func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err os.Error) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment