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>
Wed, 4 Apr 2018 21:14:04 +0000 (23:14 +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

(cherry picked from commit cb53823eeecff3f033adfe2cb1a48d8b8a89dbae)

src/core/corenetwork.cpp

index ac69044..0ebcd19 100644 (file)
@@ -191,12 +191,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));