]> Cypherpunks repositories - gostls13.git/commitdiff
net: If we stop polling, remove any pending events for the socket
authorIan Lance Taylor <iant@golang.org>
Wed, 25 May 2011 19:21:10 +0000 (12:21 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 25 May 2011 19:21:10 +0000 (12:21 -0700)
Fixes #1872.

R=rsc
CC=golang-dev, lars.pensjo
https://golang.org/cl/4559046

src/pkg/net/fd_linux.go

index dcf65c014d58009feed566d1e9a3c1597165ca54..70fc344b2a0b61ffd147a2330a22abf06e6bd641 100644 (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) {