From b3de43ae3fda3fab7ef79d0bb3dba10e0b02cee0 Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Thu, 16 Mar 2006 17:29:30 +0000 Subject: [PATCH] disconnect after stream end tag, unregister two more handlers --- src/common/xmpp/client.py | 1 + src/common/xmpp/client_nb.py | 4 ++++ src/common/xmpp/dispatcher_nb.py | 4 ++++ src/common/xmpp/transports_nb.py | 3 ++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/xmpp/client.py b/src/common/xmpp/client.py index 08417c8af..cc8f77313 100644 --- a/src/common/xmpp/client.py +++ b/src/common/xmpp/client.py @@ -80,6 +80,7 @@ class PlugIn: for method in self._old_owners_methods: self._owner.__dict__[method.__name__]=method del self._owner.__dict__[self.__class__.__name__] if self.__class__.__dict__.has_key('plugout'): return self.plugout() + del self._owner def DEBUG(self,text,severity='info'): """ Feed a provided debug line to main instance's debug facility along with our ID string. """ diff --git a/src/common/xmpp/client_nb.py b/src/common/xmpp/client_nb.py index 5d6967ea4..031cc7927 100644 --- a/src/common/xmpp/client_nb.py +++ b/src/common/xmpp/client_nb.py @@ -78,6 +78,10 @@ class NBCommonClient(CommonClient): for i in self.disconnect_handlers: i() self.disconnect_handlers.reverse() + if self.__dict__.has_key('NonBlockingRoster'): + self.NonBlockingRoster.PlugOut() + if self.__dict__.has_key('NonBlockingBind'): + self.NonBlockingBind.PlugOut() if self.__dict__.has_key('NonBlockingNonSASL'): self.NonBlockingNonSASL.PlugOut() if self.__dict__.has_key('SASL'): diff --git a/src/common/xmpp/dispatcher_nb.py b/src/common/xmpp/dispatcher_nb.py index 1a6a063a6..f174fe5b0 100644 --- a/src/common/xmpp/dispatcher_nb.py +++ b/src/common/xmpp/dispatcher_nb.py @@ -126,6 +126,10 @@ class Dispatcher(PlugIn): raise _pendingException[0], _pendingException[1], _pendingException[2] try: self.Stream.Parse(data) + # end stream:stream tag received + if self.Stream._NodeBuilder__depth == 0: + self._owner.Connection.disconnect() + return 0 except ExpatError: sys.exc_clear() self._owner.Connection.pollend() diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index 0b886114d..bf0a4b0dd 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -236,7 +236,7 @@ class NonBlockingTcp(PlugIn, IdleObject): self.renew_send_timeout() if self.on_receive: if received.strip(): - self.DEBUG(received,'got') + self.DEBUG(received, 'got') if hasattr(self._owner, 'Dispatcher'): self._owner.Dispatcher.Event('', DATA_RECEIVED, received) self.on_receive(received) @@ -258,6 +258,7 @@ class NonBlockingTcp(PlugIn, IdleObject): self.sendbuff = self.sendbuff[send_count:] if not self.sendbuff and not self.sendqueue: if self.state < 0: + self.idlequeue.unplug_idle(self.fd) self._on_send() self.disconnect() return