From 85371bff8cc5e70531c87b5708d3334412831a78 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Fri, 15 May 2015 12:01:42 +0200 Subject: Use existing addr object where available --- voctocore/lib/avpreviewoutput.py | 2 +- voctocore/lib/avrawoutput.py | 2 +- voctocore/lib/tcpmulticonnection.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'voctocore/lib') diff --git a/voctocore/lib/avpreviewoutput.py b/voctocore/lib/avpreviewoutput.py index 3a40a00..b1bc27f 100644 --- a/voctocore/lib/avpreviewoutput.py +++ b/voctocore/lib/avpreviewoutput.py @@ -61,6 +61,6 @@ class AVPreviewOutput(TCPMultiConnection): def on_disconnect(multifdsink, fileno): if fileno == conn.fileno(): self.log.debug('fd %u removed from multifdsink', fileno) - self.close_connection(conn) + self.close_connection(conn, addr) fdsink.connect('client-fd-removed', on_disconnect) diff --git a/voctocore/lib/avrawoutput.py b/voctocore/lib/avrawoutput.py index 3c7d739..912c292 100644 --- a/voctocore/lib/avrawoutput.py +++ b/voctocore/lib/avrawoutput.py @@ -50,6 +50,6 @@ class AVRawOutput(TCPMultiConnection): def on_disconnect(multifdsink, fileno): if fileno == conn.fileno(): self.log.debug('fd %u removed from multifdsink', fileno) - self.close_connection(conn) + self.close_connection(conn, addr) fdsink.connect('client-fd-removed', on_disconnect) diff --git a/voctocore/lib/tcpmulticonnection.py b/voctocore/lib/tcpmulticonnection.py index 201ecde..5ad4ca2 100644 --- a/voctocore/lib/tcpmulticonnection.py +++ b/voctocore/lib/tcpmulticonnection.py @@ -36,7 +36,10 @@ class TCPMultiConnection(object): return True - def close_connection(self, conn): + def close_connection(self, conn, addr=None): + if addr is None: + addr = conn.getpeername() + self.currentConnections.remove(conn) - self.log.info('Disconnected Receiver %s', conn.getpeername()) + self.log.info('Disconnected Receiver %s', addr) self.log.info('Now %u Receiver connected', len(self.currentConnections)) -- cgit v1.2.3