summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/plugins/xep_0065/proxy.py13
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py2
2 files changed, 11 insertions, 4 deletions
diff --git a/sleekxmpp/plugins/xep_0065/proxy.py b/sleekxmpp/plugins/xep_0065/proxy.py
index 265d3030..fdd9f97e 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:
@@ -198,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."""
@@ -250,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
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