XEP-0047: remove now-useless threading locks.
This commit is contained in:
parent
45f7cb8bda
commit
c1f23b566b
2 changed files with 17 additions and 35 deletions
|
@ -1,6 +1,5 @@
|
|||
import uuid
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from slixmpp import Message, Iq
|
||||
from slixmpp.exceptions import XMPPError
|
||||
|
@ -30,10 +29,6 @@ class XEP_0047(BasePlugin):
|
|||
def plugin_init(self):
|
||||
self._streams = {}
|
||||
self._pending_streams = {}
|
||||
self._pending_lock = threading.Lock()
|
||||
self._stream_lock = threading.Lock()
|
||||
|
||||
self._preauthed_sids_lock = threading.Lock()
|
||||
self._preauthed_sids = {}
|
||||
|
||||
register_stanza_plugin(Iq, Open)
|
||||
|
@ -85,7 +80,6 @@ class XEP_0047(BasePlugin):
|
|||
self._streams[(jid, sid, peer_jid)] = stream
|
||||
|
||||
def _del_stream(self, jid, sid, peer_jid, data):
|
||||
with self._stream_lock:
|
||||
if (jid, sid, peer_jid) in self._streams:
|
||||
del self._streams[(jid, sid, peer_jid)]
|
||||
|
||||
|
@ -105,14 +99,12 @@ class XEP_0047(BasePlugin):
|
|||
return False
|
||||
|
||||
def _authorized_sid(self, jid, sid, ifrom, iq):
|
||||
with self._preauthed_sids_lock:
|
||||
if (jid, sid, ifrom) in self._preauthed_sids:
|
||||
del self._preauthed_sids[(jid, sid, ifrom)]
|
||||
return True
|
||||
return False
|
||||
|
||||
def _preauthorize_sid(self, jid, sid, ifrom, data):
|
||||
with self._preauthed_sids_lock:
|
||||
self._preauthed_sids[(jid, sid, ifrom)] = True
|
||||
|
||||
def open_stream(self, jid, block_size=None, sid=None, window=1, use_messages=False,
|
||||
|
@ -134,9 +126,6 @@ class XEP_0047(BasePlugin):
|
|||
iq['from'], iq['to'], window,
|
||||
use_messages)
|
||||
|
||||
with self._stream_lock:
|
||||
self._pending_streams[iq['id']] = stream
|
||||
|
||||
self._pending_streams[iq['id']] = stream
|
||||
|
||||
cb = None
|
||||
|
@ -151,7 +140,6 @@ class XEP_0047(BasePlugin):
|
|||
|
||||
def _handle_opened_stream(self, iq):
|
||||
if iq['type'] == 'result':
|
||||
with self._stream_lock:
|
||||
stream = self._pending_streams.get(iq['id'], None)
|
||||
if stream is not None:
|
||||
log.debug('IBB stream (%s) accepted by %s', stream.sid, iq['from'])
|
||||
|
@ -162,7 +150,6 @@ class XEP_0047(BasePlugin):
|
|||
self.xmpp.event('ibb_stream_start', stream)
|
||||
self.xmpp.event('stream:%s:%s' % (stream.sid, stream.peer_jid), stream)
|
||||
|
||||
with self._stream_lock:
|
||||
if iq['id'] in self._pending_streams:
|
||||
del self._pending_streams[iq['id']]
|
||||
|
||||
|
|
|
@ -27,9 +27,6 @@ class IBBytestream(object):
|
|||
self.send_seq = -1
|
||||
self.recv_seq = -1
|
||||
|
||||
self._send_seq_lock = threading.Lock()
|
||||
self._recv_seq_lock = threading.Lock()
|
||||
|
||||
self.stream_started = threading.Event()
|
||||
self.stream_in_closed = threading.Event()
|
||||
self.stream_out_closed = threading.Event()
|
||||
|
@ -47,7 +44,6 @@ class IBBytestream(object):
|
|||
raise socket.error
|
||||
data = data[0:self.block_size]
|
||||
self.send_window.acquire()
|
||||
with self._send_seq_lock:
|
||||
self.send_seq = (self.send_seq + 1) % 65535
|
||||
seq = self.send_seq
|
||||
if self.use_messages:
|
||||
|
@ -87,7 +83,6 @@ class IBBytestream(object):
|
|||
self.close()
|
||||
|
||||
def _recv_data(self, stanza):
|
||||
with self._recv_seq_lock:
|
||||
new_seq = stanza['ibb_data']['seq']
|
||||
if new_seq != (self.recv_seq + 1) % 65535:
|
||||
self.close()
|
||||
|
|
Loading…
Reference in a new issue