From f76524fc9f6724c1013cd1d994dd7da813d8d61c Mon Sep 17 00:00:00 2001 From: waechtjn Date: Sun, 26 Jan 2014 16:53:53 +0100 Subject: Fixed XEP-0065 SOCKS5 socket closing SCOKS5 SID were removed multiple times from the _sessions dictionary --- sleekxmpp/plugins/xep_0065/proxy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sleekxmpp/plugins/xep_0065/proxy.py b/sleekxmpp/plugins/xep_0065/proxy.py index eba7d1e9..fdd9f97e 100644 --- a/sleekxmpp/plugins/xep_0065/proxy.py +++ b/sleekxmpp/plugins/xep_0065/proxy.py @@ -199,11 +199,16 @@ class XEP_0065(base_plugin): sock = self._sessions.get(sid) if sock: try: + # sock.close() will also delete sid from self._sessions (see _connect_proxy) sock.close() except socket.error: pass + # Though this should not be neccessary remove the closed session anyway with self._sessions_lock: - del self._sessions[sid] + if sid in self._sessions: + log.warn(('SOCKS5 session with sid = "%s" was not ' + + 'removed from _sessions by sock.close()') % sid) + del self._sessions[sid] def close(self): """Closes all proxy sockets.""" @@ -251,6 +256,7 @@ class XEP_0065(base_plugin): if sid in self._sessions: del self._sessions[sid] _close() + log.info('Socket closed.') sock.close = close sock.peer_jid = peer -- cgit v1.2.3