don't try to reconnect if socket was never

connected
This commit is contained in:
Dimitur Kirov 2006-04-08 00:30:33 +00:00
parent 077e3e1084
commit 71314f2b08
3 changed files with 8 additions and 7 deletions

View File

@ -300,7 +300,7 @@ class Connection(ConnectionHandlers):
self._hosts = [i for i in result_array]
self.connect_to_next_host()
def connect_to_next_host(self):
def connect_to_next_host(self, retry = False):
if len(self._hosts):
if self.last_connection:
self.last_connection.socket.disconnect()
@ -325,7 +325,7 @@ class Connection(ConnectionHandlers):
secure = self._secure)
return
else:
if self.retrycount > 10:
if not retry or self.retrycount > 10:
self.retrycount = 0
self.time_to_reconnect = None
self.on_connect_failure()

View File

@ -118,11 +118,11 @@ class NBCommonClient(CommonClient):
self.on_stream_start = on_stream_start
self.onreceive(self._on_receive_document_attrs)
def _on_connected_failure(self):
def _on_connected_failure(self, retry = None):
if self.socket:
self.socket.disconnect()
if self.on_connect_failure:
self.on_connect_failure()
self.on_connect_failure(retry)
def _on_connected(self):
self.connected = 'tcp'

View File

@ -224,9 +224,10 @@ class NonBlockingTcp(PlugIn, IdleObject):
if errnum != socket.SSL_ERROR_EOF:
# 8 EOF occurred in violation of protocol
self.DEBUG('Socket error while receiving data', 'error')
# TODO: change with on_connect_failure, needs some
# changes in connection.py in order to work properly
self.pollend()
self.disconnect()
if self.on_connect_failure:
self.on_connect_failure(True)
self.on_connect_failure = None
if self.state >= 0:
self.disconnect()
return