Commit d5d3ff20 authored by Kenneth Giusti's avatar Kenneth Giusti

small optimization to improve link event handling

parent 77fbd97a
......@@ -475,11 +475,12 @@ class Connection(Endpoint):
pn_event = self._pn_collector.peek()
while pn_event:
LOG.debug("pn_event: %s received", pn_event.type)
if self._handle_proton_event(pn_event):
# links will generate the most events, poll them first
if _Link._handle_proton_event(pn_event, self):
pass
elif _SessionProxy._handle_proton_event(pn_event, self):
elif self._handle_proton_event(pn_event):
pass
elif _Link._handle_proton_event(pn_event, self):
elif _SessionProxy._handle_proton_event(pn_event, self):
pass
self._pn_collector.pop()
pn_event = self._pn_collector.peek()
......
......@@ -248,22 +248,27 @@ class _Link(Endpoint):
@staticmethod
def _handle_proton_event(pn_event, connection):
ep_event = _Link._endpoint_event_map.get(pn_event.type)
if pn_event.type == proton.Event.DELIVERY:
pn_delivery = pn_event.context
pn_link = pn_delivery.link
if pn_link.context:
pn_link.context._process_delivery(pn_delivery)
elif pn_event.type == proton.Event.LINK_FLOW:
pn_link = pn_event.context
if pn_link.context:
pn_link.context._process_credit()
elif ep_event is not None:
pn_link = pn_event.context
if pn_link.context:
etype = pn_event.type
if etype == proton.Event.DELIVERY:
pn_link = pn_event.link
pn_link.context and \
pn_link.context._process_delivery(pn_event.delivery)
return True
if etype == proton.Event.LINK_FLOW:
pn_link = pn_event.link
pn_link.context and pn_link.context._process_credit()
return True
ep_event = _Link._endpoint_event_map.get(etype)
if ep_event is not None:
pn_link = pn_event.link
pn_link.context and \
pn_link.context._process_endpoint_event(ep_event)
elif pn_event.type == proton.Event.LINK_INIT:
pn_link = pn_event.context
return True
if etype == proton.Event.LINK_INIT:
pn_link = pn_event.link
# create a new link if requested by remote:
c = hasattr(pn_link, 'context') and pn_link.context
if not c:
......@@ -278,11 +283,14 @@ class _Link(Endpoint):
LOG.debug("Remotely initiated Receiver needs init")
link = session.request_receiver(pn_link)
connection._receiver_links[pn_link.name] = link
elif pn_event.type == proton.Event.LINK_FINAL:
return True
if etype == proton.Event.LINK_FINAL:
LOG.debug("link finalized: %s", pn_event.context)
else:
return False # unknown
return True # handled
return True
return False # event not handled
elif hasattr(proton.Event, "LINK_REMOTE_STATE"):
# 0.7 proton event model
@staticmethod
......
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