make sure NBClientCommon, dispatcher and

NodeBuilder are callected when we close the
connection
This commit is contained in:
Dimitur Kirov 2006-05-03 16:12:10 +00:00
parent 4013818599
commit f9e874a1a3
4 changed files with 14 additions and 12 deletions

View file

@ -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):

View file

@ -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 *

View file

@ -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:

View file

@ -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: