Commit 0f566515 authored by Vincent Pelletier's avatar Vincent Pelletier

Always call _poll after handling a packet.

This should increase process responsiveness when a single _poll call
fetched many packets: as long as packet queue is not empty, no epoll.poll
call was made. This means that outgoing packets were kept in our buffer
until packet queue becomes empty.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2420 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 07b48079
...@@ -179,7 +179,10 @@ class HandlerSwitcher(object): ...@@ -179,7 +179,10 @@ class HandlerSwitcher(object):
else: else:
neo.logging.error('Unexpected answer %r in %r', packet, connection) neo.logging.error('Unexpected answer %r in %r', packet, connection)
notification = Packets.Notify('Unexpected answer: %r' % packet) notification = Packets.Notify('Unexpected answer: %r' % packet)
try:
connection.notify(notification) connection.notify(notification)
except ConnectorConnectionClosedException:
pass
connection.abort() connection.abort()
handler.peerBroken(connection) handler.peerBroken(connection)
# apply a pending handler if no more answers are pending # apply a pending handler if no more answers are pending
......
...@@ -81,7 +81,9 @@ class EpollEventManager(object): ...@@ -81,7 +81,9 @@ class EpollEventManager(object):
return result return result
def _addPendingConnection(self, conn): def _addPendingConnection(self, conn):
self._pending_processing.append(conn) pending_processing = self._pending_processing
if conn not in pending_processing:
pending_processing.append(conn)
def poll(self, timeout=1): def poll(self, timeout=1):
to_process = self._getPendingConnection() to_process = self._getPendingConnection()
...@@ -102,6 +104,10 @@ class EpollEventManager(object): ...@@ -102,6 +104,10 @@ class EpollEventManager(object):
self._addPendingConnection(to_process) self._addPendingConnection(to_process)
finally: finally:
to_process.unlock() to_process.unlock()
# Non-blocking call: as we handled a packet, we should just offer
# poll a chance to fetch & send already-available data, but it must
# not delay us.
self._poll(timeout=0)
def _poll(self, timeout=1): def _poll(self, timeout=1):
rlist, wlist, elist = self.epoll.poll(timeout) rlist, wlist, elist = self.epoll.poll(timeout)
......
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