From e7657c44a3720231d89998f74f6369243431f878 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 27 Feb 2014 21:10:40 +0100 Subject: [PATCH 1/1] Fix reconnection logic in the client Seems like b654b2f broke reconnecting the client to the core; it would only try once and then stop trying. Thanks to mamarley for noticing that bug and bisecting the culprit. The main issue causing this was that CoreConnection called resetConnection(false) before (re)connecting, thus clearing the reconnect flag. This call is a remnant from before we refactored out all the socket handling and should not be needed anymore, now that we have clean disconnected() semantics. Before b654b2f this was not a problem, because we would always receive a socket error on failed reconnect that would reinstate the flag. Because b654b2f worked around another issue by always sending a disconnected() when the socket goes back into UnconnectedState, and this would happen before the socket error signal was sent, the error handling would never be called and the reconnect flag thus not reinstated, causing this bug. So the second fix is to spin the event loop such that the error signal can overtake that disconnected() signal and be handled properly (so we also get the socket error message in the status bar). --- src/client/clientauthhandler.cpp | 4 +++- src/client/coreconnection.cpp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/clientauthhandler.cpp b/src/client/clientauthhandler.cpp index 0d24a761..9440419c 100644 --- a/src/client/clientauthhandler.cpp +++ b/src/client/clientauthhandler.cpp @@ -114,7 +114,9 @@ void ClientAuthHandler::onSocketStateChanged(QAbstractSocket::SocketState socket text = tr("Disconnected"); // Ensure the disconnected() signal is sent even if we haven't reached the Connected state yet. // The baseclass implementation will make sure to only send the signal once. - onSocketDisconnected(); + // However, we do want to prefer a potential socket error signal that may be on route already, so + // give this a chance to overtake us by spinning the loop... + QTimer::singleShot(0, this, SLOT(onSocketDisconnected())); } break; default: diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index db18ef43..36503854 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -378,8 +378,6 @@ void CoreConnection::connectToCurrentAccount() return; } - resetConnection(false); - if (currentAccount().isInternal()) { if (Quassel::runMode() != Quassel::Monolithic) { qWarning() << "Cannot connect to internal core in client-only mode!"; -- 2.20.1