Commit aeb31eab authored by Julien Muchembled's avatar Julien Muchembled

Fix lib.protocol not registering properly when a packet should be ignored when closed

This fixes several random failures in unit tests.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2669 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f6cac0e3
...@@ -1339,12 +1339,13 @@ class NotifyReady(Packet): ...@@ -1339,12 +1339,13 @@ class NotifyReady(Packet):
pass pass
StaticRegistry = {} StaticRegistry = {}
def register(code, request, answer=None, ignore_when_closed=None): def register(code, request, ignore_when_closed=None):
""" Register a packet in the packet registry """ """ Register a packet in the packet registry """
# register the request # register the request
assert code not in StaticRegistry, "Duplicate request packet code" assert code not in StaticRegistry, "Duplicate request packet code"
request._code = code request._code = code
StaticRegistry[code] = request StaticRegistry[code] = request
answer = request._answer
if ignore_when_closed is None: if ignore_when_closed is None:
# By default, on a closed connection: # By default, on a closed connection:
# - request: ignore # - request: ignore
...@@ -1352,7 +1353,7 @@ def register(code, request, answer=None, ignore_when_closed=None): ...@@ -1352,7 +1353,7 @@ def register(code, request, answer=None, ignore_when_closed=None):
# - nofitication: keep # - nofitication: keep
ignore_when_closed = answer is not None ignore_when_closed = answer is not None
request._ignore_when_closed = ignore_when_closed request._ignore_when_closed = ignore_when_closed
if request._answer in (Error, None): if answer in (Error, None):
return request return request
# build a class for the answer # build a class for the answer
answer = ClassType('Answer%s' % (request.__name__, ), (Packet, ), {}) answer = ClassType('Answer%s' % (request.__name__, ), (Packet, ), {})
......
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