make sure NBClientCommon, dispatcher and
NodeBuilder are callected when we close the connection
This commit is contained in:
parent
4013818599
commit
f9e874a1a3
4 changed files with 14 additions and 12 deletions
|
@ -121,6 +121,7 @@ class Connection(ConnectionHandlers):
|
||||||
# make sure previous connection is completely closed
|
# make sure previous connection is completely closed
|
||||||
gajim.proxy65_manager.disconnect(self.connection)
|
gajim.proxy65_manager.disconnect(self.connection)
|
||||||
self.connection.disconnect()
|
self.connection.disconnect()
|
||||||
|
self.last_connection = None
|
||||||
self.connection = None
|
self.connection = None
|
||||||
|
|
||||||
def _disconnectedReconnCB(self):
|
def _disconnectedReconnCB(self):
|
||||||
|
|
|
@ -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_nb import *
|
||||||
from client import *
|
from client import *
|
||||||
from protocol import *
|
from protocol import *
|
||||||
|
|
|
@ -92,6 +92,8 @@ class Dispatcher(PlugIn):
|
||||||
self.Stream.DEBUG = None
|
self.Stream.DEBUG = None
|
||||||
self.Stream.features = None
|
self.Stream.features = None
|
||||||
self.Stream.destroy()
|
self.Stream.destroy()
|
||||||
|
self._owner = None
|
||||||
|
self.Stream = None
|
||||||
|
|
||||||
def StreamInit(self):
|
def StreamInit(self):
|
||||||
''' Send an initial stream header. '''
|
''' Send an initial stream header. '''
|
||||||
|
@ -127,7 +129,7 @@ class Dispatcher(PlugIn):
|
||||||
try:
|
try:
|
||||||
self.Stream.Parse(data)
|
self.Stream.Parse(data)
|
||||||
# end stream:stream tag received
|
# end stream:stream tag received
|
||||||
if self.Stream._NodeBuilder__depth == 0:
|
if self.Stream and self.Stream._NodeBuilder__depth == 0:
|
||||||
self._owner.Connection.disconnect()
|
self._owner.Connection.disconnect()
|
||||||
return 0
|
return 0
|
||||||
except ExpatError:
|
except ExpatError:
|
||||||
|
|
|
@ -138,15 +138,16 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
the owner's dispatcher. '''
|
the owner's dispatcher. '''
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self._owner.Connection = None
|
self._owner.Connection = None
|
||||||
|
self._owner = None
|
||||||
|
|
||||||
def pollin(self):
|
def pollin(self):
|
||||||
self._do_receive()
|
self._do_receive()
|
||||||
|
|
||||||
def pollend(self):
|
def pollend(self):
|
||||||
|
conn_failure_cb = self.on_connect_failure
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
if self.on_connect_failure:
|
if conn_failure_cb:
|
||||||
self.on_connect_failure()
|
conn_failure_cb()
|
||||||
self.on_connect_failure = None
|
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
if self.state == -2: # already disconnected
|
if self.state == -2: # already disconnected
|
||||||
|
@ -166,6 +167,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
self.fd = -1
|
self.fd = -1
|
||||||
if self.on_disconnect:
|
if self.on_disconnect:
|
||||||
self.on_disconnect()
|
self.on_disconnect()
|
||||||
|
self.on_connect_failure = None
|
||||||
|
|
||||||
def end_disconnect(self):
|
def end_disconnect(self):
|
||||||
''' force disconnect only if we are still trying to disconnect '''
|
''' 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:
|
if errnum == socket.SSL_ERROR_WANT_READ:
|
||||||
pass
|
pass
|
||||||
elif errnum in [errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN]:
|
elif errnum in [errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN]:
|
||||||
self.disconnect()
|
self.pollend()
|
||||||
if self.on_connect_failure:
|
|
||||||
self.on_connect_failure()
|
|
||||||
# don't proccess result, cas it will raise error
|
# don't proccess result, cas it will raise error
|
||||||
return
|
return
|
||||||
elif not received :
|
elif not received :
|
||||||
if errnum != socket.SSL_ERROR_EOF:
|
if errnum != socket.SSL_ERROR_EOF:
|
||||||
# 8 EOF occurred in violation of protocol
|
# 8 EOF occurred in violation of protocol
|
||||||
self.DEBUG('Socket error while receiving data', 'error')
|
self.DEBUG('Socket error while receiving data', 'error')
|
||||||
self.disconnect()
|
self.pollend()
|
||||||
if self.on_connect_failure:
|
|
||||||
self.on_connect_failure(True)
|
|
||||||
self.on_connect_failure = None
|
|
||||||
if self.state >= 0:
|
if self.state >= 0:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
return
|
return
|
||||||
|
@ -393,6 +390,8 @@ class NonBlockingTLS(PlugIn):
|
||||||
# if dispatcher is not plugged we cannot (un)register handlers
|
# if dispatcher is not plugged we cannot (un)register handlers
|
||||||
if self._owner.__dict__.has_key('Dispatcher'):
|
if self._owner.__dict__.has_key('Dispatcher'):
|
||||||
self._owner.UnregisterHandler('features', self.FeaturesHandler,xmlns=NS_STREAMS)
|
self._owner.UnregisterHandler('features', self.FeaturesHandler,xmlns=NS_STREAMS)
|
||||||
|
self._owner.Dispatcher.PlugOut()
|
||||||
|
self._owner = None
|
||||||
|
|
||||||
def tls_start(self):
|
def tls_start(self):
|
||||||
if self.on_tls_start:
|
if self.on_tls_start:
|
||||||
|
|
Loading…
Add table
Reference in a new issue