From: Michael Marley Date: Sat, 20 Dec 2014 20:22:19 +0000 (-0500) Subject: Fix potential state desync in disconnectFromIrc() X-Git-Tag: 0.12-beta1~25^2 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=51b46e3bdedd82eed34844c372efe432ec51d95d;hp=9c5fd60f6264898a7c0287e3f7d47e181ef39f84 Fix potential state desync in disconnectFromIrc() Previously, disconnectFromIrc() would assume that if the socket was in any state other than ConnectedState that it was disconnected and send the socketDisconnected() signal. However, if the socket was in a different state, such as ConnectingState, this caused the corenetwork state and the socket state to become desynchronized. This patch causes disconnectFromIrc() to close the socket and start the socketCloseTimer in the event that the socket is in a state other than UnconnectedState or ConnectedState. --- diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 4223c5f8..8655b110 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -232,17 +232,18 @@ void CoreNetwork::disconnectFromIrc(bool requested, const QString &reason, bool _quitReason = reason; displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Disconnecting. (%1)").arg((!requested && !withReconnect) ? tr("Core Shutdown") : _quitReason)); - switch (socket.state()) { - case QAbstractSocket::ConnectedState: - userInputHandler()->issueQuit(_quitReason); + if (socket.state() == QAbstractSocket::UnconnectedState) { + socketDisconnected(); + } else { + if (socket.state() == QAbstractSocket::ConnectedState) { + userInputHandler()->issueQuit(_quitReason); + } else { + socket.close(); + } if (requested || withReconnect) { // the irc server has 10 seconds to close the socket _socketCloseTimer.start(10000); - break; } - default: - socket.close(); - socketDisconnected(); } }