From 83ff385000f29a0341badd0ad5709e338ee2357a Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 9 Sep 2008 15:54:34 +0000 Subject: [PATCH] Fix '/msg *status disconnect' to *really* disconnect from IRC Before this commit, if a connection attempt was still going on, that attempt wasn't aborted. This is now fixed. This was reported by Kuja, thanks! git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1194 726aef4b-f618-498e-8847-2d620e286838 --- ClientCommand.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ClientCommand.cpp b/ClientCommand.cpp index f4d1a5d2..6fe222d4 100644 --- a/ClientCommand.cpp +++ b/ClientCommand.cpp @@ -266,8 +266,20 @@ void CClient::UserCommand(const CString& sLine) { } } else if (sCommand.CaseCmp("DISCONNECT") == 0) { if (m_pUser) { - if (m_pIRCSock) + // m_pIRCSock is only set after the low level connection + // to the IRC server was established. Before this we can + // only find the IRC socket by its name. + if (m_pIRCSock) { m_pIRCSock->Quit(); + } else { + Csock* pIRCSock; + CString sSockName = "IRC::" + m_pUser->GetUserName(); + // This is *slow*, we try to avoid doing this + pIRCSock = CZNC::Get().GetManager().FindSockByName(sSockName); + if (pIRCSock) + pIRCSock->Close(); + } + m_pUser->SetIRCConnectEnabled(false); PutStatus("Disconnected from IRC. Use 'connect' to reconnect."); return;