diff --git a/src/common/connection.py b/src/common/connection.py index 928eaa473..d9a7b9c1c 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -121,6 +121,7 @@ class Connection(ConnectionHandlers): # make sure previous connection is completely closed gajim.proxy65_manager.disconnect(self.connection) self.connection.disconnect() + self.last_connection = None self.connection = None def _disconnectedReconnCB(self): diff --git a/src/common/xmpp/__init__.py b/src/common/xmpp/__init__.py index aa06c9c4a..4645ceda2 100644 --- a/src/common/xmpp/__init__.py +++ b/src/common/xmpp/__init__.py @@ -26,7 +26,7 @@ and use only methods for access all values you should not have any problems. """ -import simplexml,protocol,debug,auth_nb,auth,transports,transports_nb,roster_nb,roster,dispatcher_nb,dispatcher,features_nb,features,browser,filetransfer,commands, idlequeue +import simplexml,protocol,debug,auth_nb,auth,transports,transports_nb,roster_nb,roster,dispatcher_nb,features_nb,features,browser,filetransfer,commands, idlequeue from client_nb import * from client import * from protocol import * diff --git a/src/common/xmpp/dispatcher_nb.py b/src/common/xmpp/dispatcher_nb.py index a003177f4..dbdaf4d63 100644 --- a/src/common/xmpp/dispatcher_nb.py +++ b/src/common/xmpp/dispatcher_nb.py @@ -92,6 +92,8 @@ class Dispatcher(PlugIn): self.Stream.DEBUG = None self.Stream.features = None self.Stream.destroy() + self._owner = None + self.Stream = None def StreamInit(self): ''' Send an initial stream header. ''' @@ -127,7 +129,7 @@ class Dispatcher(PlugIn): try: self.Stream.Parse(data) # end stream:stream tag received - if self.Stream._NodeBuilder__depth == 0: + if self.Stream and self.Stream._NodeBuilder__depth == 0: self._owner.Connection.disconnect() return 0 except ExpatError: diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index 43e3ad2c1..b21b436dd 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -138,15 +138,16 @@ class NonBlockingTcp(PlugIn, IdleObject): the owner's dispatcher. ''' self.disconnect() self._owner.Connection = None + self._owner = None def pollin(self): self._do_receive() def pollend(self): + conn_failure_cb = self.on_connect_failure self.disconnect() - if self.on_connect_failure: - self.on_connect_failure() - self.on_connect_failure = None + if conn_failure_cb: + conn_failure_cb() def disconnect(self): if self.state == -2: # already disconnected @@ -166,6 +167,7 @@ class NonBlockingTcp(PlugIn, IdleObject): self.fd = -1 if self.on_disconnect: self.on_disconnect() + self.on_connect_failure = None def end_disconnect(self): ''' force disconnect only if we are still trying to disconnect ''' @@ -215,19 +217,14 @@ class NonBlockingTcp(PlugIn, IdleObject): if errnum == socket.SSL_ERROR_WANT_READ: pass elif errnum in [errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN]: - self.disconnect() - if self.on_connect_failure: - self.on_connect_failure() + self.pollend() # don't proccess result, cas it will raise error return elif not received : if errnum != socket.SSL_ERROR_EOF: # 8 EOF occurred in violation of protocol self.DEBUG('Socket error while receiving data', 'error') - self.disconnect() - if self.on_connect_failure: - self.on_connect_failure(True) - self.on_connect_failure = None + self.pollend() if self.state >= 0: self.disconnect() return @@ -393,6 +390,8 @@ class NonBlockingTLS(PlugIn): # if dispatcher is not plugged we cannot (un)register handlers if self._owner.__dict__.has_key('Dispatcher'): self._owner.UnregisterHandler('features', self.FeaturesHandler,xmlns=NS_STREAMS) + self._owner.Dispatcher.PlugOut() + self._owner = None def tls_start(self): if self.on_tls_start: