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 <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
zolliker 2022-03-07 15:13:20 +01:00
parent f58ab263e7
commit 3fe44d32b1

View File

@ -125,15 +125,22 @@ class Dispatcher:
"""registers new connection""" """registers new connection"""
self._connections.append(conn) self._connections.append(conn)
def remove_connection(self, conn): def reset_connection(self, conn):
"""removes now longer functional connection""" """remove all subscriptions for a connection
if conn in self._connections:
self._connections.remove(conn) to be called on the identification message
"""
for _evt, conns in list(self._subscriptions.items()): for _evt, conns in list(self._subscriptions.items()):
conns.discard(conn) conns.discard(conn)
self.set_all_log_levels(conn, 'off') self.set_all_log_levels(conn, 'off')
self._active_connections.discard(conn) 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): def register_module(self, moduleobj, modulename, export=True):
self.log.debug('registering module %r as %s (export=%r)' % self.log.debug('registering module %r as %s (export=%r)' %
(moduleobj, modulename, export)) (moduleobj, modulename, export))
@ -299,6 +306,10 @@ class Dispatcher:
self.log.error('should have been handled in the interface!') self.log.error('should have been handled in the interface!')
def handle__ident(self, conn, specifier, data): 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) return (IDENTREPLY, None, None)
def handle_describe(self, conn, specifier, data): def handle_describe(self, conn, specifier, data):