Be patient whilst connecting

On startup we make several connections simultaneously.  Socket
maintenance code checks if we're not connected, and if not
switches to a connected interface if auto_connect.
Unfortunately this meant that we frequently didn't reconnect to
the prior good server on startup, because some other connection
would happen first and this code would decide to switch to it.

Instead, only switch if a connection attempt is not in progress.
If that times out at the O/S level the switch will happen.
This commit is contained in:
Neil Booth 2015-09-06 20:03:43 +09:00
parent f5a43b8738
commit da5c18b2f9
1 changed files with 2 additions and 1 deletions

View File

@ -642,7 +642,8 @@ class Network(util.DaemonThread):
# main interface
if not self.is_connected():
if self.auto_connect:
self.switch_to_random_interface()
if not self.is_connecting():
self.switch_to_random_interface()
else:
if self.default_server in self.disconnected_servers:
if now - self.server_retry_time > SERVER_RETRY_INTERVAL: