From 71314f2b084f7c9b29acac990c9da7e6dd840388 Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Sat, 8 Apr 2006 00:30:33 +0000 Subject: [PATCH] don't try to reconnect if socket was never connected --- src/common/connection.py | 4 ++-- src/common/xmpp/client_nb.py | 4 ++-- src/common/xmpp/transports_nb.py | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 47955e8e8..cabc59010 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -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() diff --git a/src/common/xmpp/client_nb.py b/src/common/xmpp/client_nb.py index 031cc7927..145b17113 100644 --- a/src/common/xmpp/client_nb.py +++ b/src/common/xmpp/client_nb.py @@ -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' diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index 9228d5176..ba0803de0 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -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