mirror of
https://github.com/znc/znc.git
synced 2026-07-03 08:21:57 +02:00
listsockets: Ignore dereferenced sockets
When someone connects to ZNC, this connection is first handled by an instance of CIncomingConnection. Once we determined if this is a HTTP or an IRC connection, the connection is handed of to the appropriate class. The CIncomingConnection instance that was used first will still linger around for the next event loop iteration and then be destroyed. Since this socket isn't a "real" connection anymore (another instance of Csock took over for this one), listsockets should ignore all sockets in state CLT_DEREFERENCE. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2213 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -72,21 +72,34 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::priority_queue<CSocketSorter> GetSockets() {
|
||||
CSockManager& m = CZNC::Get().GetManager();
|
||||
std::priority_queue<CSocketSorter> ret;
|
||||
|
||||
for (unsigned int a = 0; a < m.size(); a++) {
|
||||
Csock* pSock = m[a];
|
||||
// These sockets went through SwapSockByAddr. That means
|
||||
// another socket took over the connection from this
|
||||
// socket. So ignore this to avoid listing the
|
||||
// connection twice.
|
||||
if (pSock->GetCloseType() == Csock::CLT_DEREFERENCE)
|
||||
continue;
|
||||
ret.push(pSock);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual bool WebRequiresAdmin() { return true; }
|
||||
virtual CString GetWebMenuTitle() { return "List sockets"; }
|
||||
|
||||
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
|
||||
if (sPageName.empty() || sPageName == "index") {
|
||||
CSockManager& m = CZNC::Get().GetManager();
|
||||
if (!m.size()) {
|
||||
if (CZNC::Get().GetManager().empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::priority_queue<CSocketSorter> socks;
|
||||
|
||||
for (unsigned int a = 0; a < m.size(); a++) {
|
||||
socks.push(m[a]);
|
||||
}
|
||||
std::priority_queue<CSocketSorter> socks = GetSockets();
|
||||
|
||||
while (!socks.empty()) {
|
||||
Csock* pSocket = socks.top().GetSock();
|
||||
@@ -187,17 +200,12 @@ public:
|
||||
}
|
||||
|
||||
void ShowSocks(bool bShowHosts) {
|
||||
CSockManager& m = CZNC::Get().GetManager();
|
||||
if (!m.size()) {
|
||||
if (CZNC::Get().GetManager().empty()) {
|
||||
PutStatus("You have no open sockets.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::priority_queue<CSocketSorter> socks;
|
||||
|
||||
for (unsigned int a = 0; a < m.size(); a++) {
|
||||
socks.push(m[a]);
|
||||
}
|
||||
std::priority_queue<CSocketSorter> socks = GetSockets();
|
||||
|
||||
CTable Table;
|
||||
Table.AddColumn("Name");
|
||||
|
||||
Reference in New Issue
Block a user