From 3fe44d32b1670d20da624da32cd02a2628962214 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 7 Mar 2022 15:13:20 +0100 Subject: [PATCH] reset connection on identification required for issue 66. The other stuff in issue 66 ('error_closed' message), has to be implemented if and when frappy will support serial server connections Change-Id: I63bcd59741c3c330a72b829ce8491766ffe6c3a8 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27908 Tested-by: Jenkins Automated Tests Reviewed-by: Enrico Faulhaber Reviewed-by: Markus Zolliker --- secop/protocol/dispatcher.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/secop/protocol/dispatcher.py b/secop/protocol/dispatcher.py index 311f1d8..58a0e4b 100644 --- a/secop/protocol/dispatcher.py +++ b/secop/protocol/dispatcher.py @@ -125,15 +125,22 @@ class Dispatcher: """registers new connection""" self._connections.append(conn) - def remove_connection(self, conn): - """removes now longer functional connection""" - if conn in self._connections: - self._connections.remove(conn) + def reset_connection(self, conn): + """remove all subscriptions for a connection + + to be called on the identification message + """ for _evt, conns in list(self._subscriptions.items()): conns.discard(conn) self.set_all_log_levels(conn, 'off') self._active_connections.discard(conn) + def remove_connection(self, conn): + """removes now longer functional connection""" + if conn in self._connections: + self._connections.remove(conn) + self.reset_connection(conn) + def register_module(self, moduleobj, modulename, export=True): self.log.debug('registering module %r as %s (export=%r)' % (moduleobj, modulename, export)) @@ -299,6 +306,10 @@ class Dispatcher: self.log.error('should have been handled in the interface!') def handle__ident(self, conn, specifier, data): + # Remark: the following line is needed due to issue 66. + self.reset_connection(conn) + # The other stuff in issue 66 ('error_closed' message), has to be implemented + # if and when frappy will support serial server connections return (IDENTREPLY, None, None) def handle_describe(self, conn, specifier, data):