From d308d727f784d0178935c36608983a4f35820102 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 12 Nov 2014 10:22:45 +0100 Subject: [PATCH] Replace CIRCNetwork::FindClient() with FindClients() FindClient() is not enough, because there are no restrictions to used identifiers. They don't necessarily need to be unique, and the same identified client might re-connect meanwhile a ghost connection is still hanging there. --- include/znc/IRCNetwork.h | 2 +- src/IRCNetwork.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index ccb35def..ab6ef527 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -76,7 +76,7 @@ public: const CString& GetName() const; bool IsNetworkAttached() const { return !m_vClients.empty(); } const std::vector& GetClients() const { return m_vClients; } - CClient* FindClient(const CString& sIdentifier) const; + std::vector FindClients(const CString& sIdentifier) const; void SetUser(CUser *pUser); bool SetName(const CString& sName); diff --git a/src/IRCNetwork.cpp b/src/IRCNetwork.cpp index e809d243..78a0f1c8 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -669,14 +669,15 @@ const CString& CIRCNetwork::GetName() const { return m_sName; } -CClient* CIRCNetwork::FindClient(const CString& sIdentifier) const { +std::vector CIRCNetwork::FindClients(const CString& sIdentifier) const { + std::vector vClients; for (CClient* pClient : m_vClients) { if (pClient->GetIdentifier().Equals(sIdentifier)) { - return pClient; + vClients.push_back(pClient); } } - return NULL; + return vClients; } void CIRCNetwork::SetUser(CUser *pUser) {