summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger <wenrui@gmail.com>2010-12-08 13:23:30 +0800
committerAvery Pennarun <apenwarr@gmail.com>2010-12-09 19:20:01 -0800
commit735460084991336dbd8e0c054bc939b209014d42 (patch)
tree562c21356b3ca0564bf3f6c8b6cc7ade56abc96b
parent918725c4857f8b6fc31813354ba29e152a83b751 (diff)
Fix a socket leak: delete object after close on both direction.
(Note by apenwarr: seems to still work for me. The reason the problem occurred is that reassigning 'handlers' doesn't change it in its parent; it creates a whole new list, and the caller still owns the old one with all the dead sockets in it. The problem seems to have been introduced in commit 84376284db6199d4928797e5e8be4182449120f2 when I factored the runonce() functionality out of the client and server but didn't notice this reassignment.)
-rw-r--r--ssnet.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/ssnet.py b/ssnet.py
index f307629..6f5b788 100644
--- a/ssnet.py
+++ b/ssnet.py
@@ -468,7 +468,10 @@ def runonce(handlers, mux):
r = []
w = []
x = []
- handlers = filter(lambda s: s.ok, handlers)
+ to_remove = filter(lambda s: not s.ok, handlers)
+ for h in to_remove:
+ handlers.remove(h)
+
for s in handlers:
s.pre_select(r,w,x)
debug2('Waiting: %d r=%r w=%r x=%r (fullness=%d/%d)\n'