1
0
mirror of https://github.com/golang/go synced 2024-09-25 15:20:13 -06:00

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
This commit is contained in:
Ian Lance Taylor 2011-05-25 12:21:10 -07:00
parent a1c92c612f
commit 0b8f1ac802

View File

@ -117,6 +117,17 @@ func (p *pollster) DelFD(fd int, mode int) {
} else {
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) {