core: connectToIrc: Pick first IRC server specified when not failed
authorgenius3000 <genius3000@g3k.solutions>
Fri, 14 Apr 2017 00:01:36 +0000 (18:01 -0600)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 24 Apr 2017 21:02:16 +0000 (23:02 +0200)
When connecting to the IRC network, only clear the
'_previousConnectionAttemptFailed' flag when trying the next server
in the list. Otherwise, reset server index to start from the top.

Currently, Quassel will continue to use the last used (working)
server (or a random server if set to). This doesn't match the
intention of having an ordered list of servers to use. The change
here just makes Quassel start with the first server in the list
unless it's a failed attempt, in which it continues down the list
(same as currently).

This fixes the issue of getting "stuck" on a specific server even if
you manually disconnect and connect.

Reference: http://bugs.quassel-irc.org/issues/693
And: http://bugs.quassel-irc.org/issues/1006
Fixes #693 and #1006
Resolves GH-287

src/core/corenetwork.cpp

index 4d1fc01..3ad9d7c 100644 (file)
@@ -214,12 +214,16 @@ void CoreNetwork::connectToIrc(bool reconnecting)
     }
     else if (_previousConnectionAttemptFailed) {
         // cycle to next server if previous connection attempt failed
+        _previousConnectionAttemptFailed = false;
         displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Connection failed. Cycling to next Server"));
         if (++_lastUsedServerIndex >= serverList().size()) {
             _lastUsedServerIndex = 0;
         }
     }
-    _previousConnectionAttemptFailed = false;
+    else {
+        // Start out with the top server in the list
+        _lastUsedServerIndex = 0;
+    }
 
     Server server = usedServer();
     displayStatusMsg(tr("Connecting to %1:%2...").arg(server.host).arg(server.port));