Commit 46a40237 authored by Vincent Pelletier's avatar Vincent Pelletier

Avoid handling events for a file descriptor more than once per _poll call.

A single fd might be reported more than once per epoll call. This causes
the associated connection to be registered multiple times, which in turn
causes problems when the first connection registration gets emptied:
handling events of the second registration will raise an error when trying
to fetch a packet from an empty list.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1531 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 66cd62e9
...@@ -164,7 +164,11 @@ class EpollEventManager(object): ...@@ -164,7 +164,11 @@ class EpollEventManager(object):
def _poll(self, timeout = 1): def _poll(self, timeout = 1):
rlist, wlist = self.epoll.poll(timeout) rlist, wlist = self.epoll.poll(timeout)
r_done_set = set()
for fd in rlist: for fd in rlist:
if fd in r_done_set:
continue
r_done_set.add(fd)
try: try:
conn = self.connection_dict[fd] conn = self.connection_dict[fd]
except KeyError: except KeyError:
...@@ -178,7 +182,11 @@ class EpollEventManager(object): ...@@ -178,7 +182,11 @@ class EpollEventManager(object):
if conn.hasPendingMessages(): if conn.hasPendingMessages():
self._addPendingConnection(conn) self._addPendingConnection(conn)
w_done_set = set()
for fd in wlist: for fd in wlist:
if fd in w_done_set:
continue
w_done_set.add(fd)
# This can fail, if a connection is closed in readable(). # This can fail, if a connection is closed in readable().
try: try:
conn = self.connection_dict[fd] conn = self.connection_dict[fd]
......
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