From cebfd844167cdb334c475bb579c32905e68159bc Mon Sep 17 00:00:00 2001 From: Anton Ryzhov Date: Tue, 21 Jan 2014 16:19:27 +0400 Subject: Examples fixes --- examples/echo_client.py | 2 +- examples/ping.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/echo_client.py b/examples/echo_client.py index 18125a0d..f2d38847 100755 --- a/examples/echo_client.py +++ b/examples/echo_client.py @@ -151,7 +151,7 @@ if __name__ == '__main__': # # if xmpp.connect(('talk.google.com', 5222)): # ... - xmpp.process(block=False) + xmpp.process(block=True) print("Done") else: print("Unable to connect.") diff --git a/examples/ping.py b/examples/ping.py index 8fbb5655..1a1c2e94 100755 --- a/examples/ping.py +++ b/examples/ping.py @@ -37,7 +37,7 @@ class PingTest(sleekxmpp.ClientXMPP): def __init__(self, jid, password, pingjid): sleekxmpp.ClientXMPP.__init__(self, jid, password) if pingjid is None: - pingjid = self.jid + pingjid = self.boundjid.bare self.pingjid = pingjid # The session_start event will be triggered when -- cgit v1.2.3 From 7c03cc622c8f00768097d8170887aefdad1d57c6 Mon Sep 17 00:00:00 2001 From: Anton Ryzhov Date: Tue, 21 Jan 2014 19:28:17 +0400 Subject: Thread counting fix --- sleekxmpp/xmlstream/xmlstream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 4d17d08c..3bc1f652 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -1343,12 +1343,12 @@ class XMLStream(object): return True def _start_thread(self, name, target, track=True): - self.__active_threads.add(name) self.__thread[name] = threading.Thread(name=name, target=target) self.__thread[name].daemon = self._use_daemons self.__thread[name].start() if track: + self.__active_threads.add(name) with self.__thread_cond: self.__thread_count += 1 -- cgit v1.2.3 From b95532b68b33787deef606e3ffc13e7416858b28 Mon Sep 17 00:00:00 2001 From: waechtjn Date: Sun, 26 Jan 2014 16:48:31 +0100 Subject: Update xep_0065/proxy.py Removed reference to undefined variable "conn" --- sleekxmpp/plugins/xep_0065/proxy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sleekxmpp/plugins/xep_0065/proxy.py b/sleekxmpp/plugins/xep_0065/proxy.py index 265d3030..eba7d1e9 100644 --- a/sleekxmpp/plugins/xep_0065/proxy.py +++ b/sleekxmpp/plugins/xep_0065/proxy.py @@ -88,8 +88,9 @@ class XEP_0065(base_plugin): # Request that the proxy activate the session with the target. self.activate(proxy, sid, to, timeout=timeout) - self.xmpp.event('stream:%s:%s' % (sid, conn.peer_jid), conn) - return self.get_socket(sid) + socket = self.get_socket(sid) + self.xmpp.event('stream:%s:%s' % (sid, to), socket) + return socket def request_stream(self, to, sid=None, ifrom=None, block=True, timeout=None, callback=None): if sid is None: -- cgit v1.2.3 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