Commit b69cd29d authored by Vincent Pelletier's avatar Vincent Pelletier

Split handling of IN, OUT and (ERR | HUP) epoll events.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1912 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 815ff693
......@@ -93,13 +93,17 @@ class Epoll(object):
else:
readable_fd_list = []
writable_fd_list = []
error_fd_list = []
for i in xrange(n):
ev = self.events[i]
if ev.events & (EPOLLIN | EPOLLERR | EPOLLHUP):
readable_fd_list.append(int(ev.data.fd))
elif ev.events & EPOLLOUT:
writable_fd_list.append(int(ev.data.fd))
return readable_fd_list, writable_fd_list
fd = int(ev.data.fd)
if ev.events & EPOLLIN:
readable_fd_list.append(fd)
if ev.events & EPOLLOUT:
writable_fd_list.append(fd)
if ev.events & (EPOLLERR | EPOLLHUP):
error_fd_list.append(fd)
return readable_fd_list, writable_fd_list, error_fd_list
def register(self, fd):
ev = EpollEvent()
......
......@@ -100,7 +100,7 @@ class EpollEventManager(object):
def _poll(self, timeout = 1):
assert timeout >= 0
rlist, wlist = self.epoll.poll(timeout)
rlist, wlist, elist = self.epoll.poll(timeout)
r_done_set = set()
for fd in rlist:
if fd in r_done_set:
......@@ -132,6 +132,24 @@ class EpollEventManager(object):
finally:
conn.unlock()
e_done_set = set()
for fd in elist:
if fd in e_done_set:
continue
e_done_set.add(fd)
# This can fail, if a connection is closed in previous calls to
# readable() or writable().
try:
conn = self.connection_dict[fd]
except KeyError:
pass
else:
conn.lock()
try:
conn.readable()
finally:
conn.unlock()
t = time()
for conn in self.connection_dict.values():
conn.lock()
......
......@@ -106,6 +106,7 @@ class EventTests(NeoTestBase):
em.epoll = Mock({"poll":(
(r_connector.getDescriptor(),),
(w_connector.getDescriptor(),),
(),
)})
em.poll(timeout=10)
# check it called poll on epoll
......
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