diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-01-14 15:37:21 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-01-14 15:37:21 +0000 |
commit | 2a81a5a0026396e7c476f648a25016443e002d85 (patch) | |
tree | 6c36ec4339c78a0ab02b41434cba76fe6766e696 | |
parent | a4693934583e30e245c60d51c01ad87d7dc08581 (diff) |
Added RemoveSocket as a test fix for merwins bug
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2787 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | src/modules.cpp | 17 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 39 |
3 files changed, 42 insertions, 18 deletions
diff --git a/include/modules.h b/include/modules.h index 5f9dfa29a..a7fc2e732 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1559,6 +1559,10 @@ class Server : public classbase */ virtual void AddSocket(InspSocket* sock); + /** Forcibly removes a class derived from InspSocket from the servers socket engine. + */ + virtual void RemoveSocket(InspSocket* sock); + /** Deletes a class derived from InspSocket from the server's socket engine. */ virtual void DelSocket(InspSocket* sock); diff --git a/src/modules.cpp b/src/modules.cpp index 4b8c0dffe..030007d1e 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -317,6 +317,23 @@ void Server::AddSocket(InspSocket* sock) module_sockets.push_back(sock); } +void Server::RemoveSocket(InspSocket* sock) +{ + for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++) + { + InspSocket* s = (InspSocket*)*a; + if (s == sock) + { + log(DEBUG,"Forcibly removed socket"); + ServerInstance->SE->DelFd(s->GetFd()); + s->Close(); + module_sockets.erase(a); + delete s; + return; + } + } +} + void Server::RehashServer() { WriteOpers("*** Rehashing config file"); diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 0ecc595fc..35f63790b 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -203,7 +203,7 @@ class TreeServer { VersionString = ""; UserCount = OperCount = 0; - this->SetNextPingTime(time(NULL) + 300); + this->SetNextPingTime(time(NULL) + 120); this->SetPingFlag(); /* find the 'route' for this server (e.g. the one directly connected @@ -1977,7 +1977,7 @@ class TreeSocket : public InspSocket * When there is activity on the socket, reset the ping counter so * that we're not wasting bandwidth pinging an active server. */ - route_back_again->SetNextPingTime(time(NULL) + 300); + route_back_again->SetNextPingTime(time(NULL) + 120); route_back_again->SetPingFlag(); } @@ -2594,6 +2594,7 @@ class ModuleSpanningTree : public Module WriteOpers("*** SQUIT: Server \002%s\002 removed from network by %s",parameters[0],user->nick); sock->Squit(s,"Server quit by "+std::string(user->nick)+"!"+std::string(user->ident)+"@"+std::string(user->host)); sock->Close(); + Srv->RemoveSocket(sock); } else { @@ -2637,22 +2638,24 @@ class ModuleSpanningTree : public Module TreeSocket* sock = serv->GetSocket(); if (sock) { - if (curtime >= serv->NextPingTime()) - { - if (serv->AnsweredLastPing()) - { - sock->WriteLine(":"+Srv->GetServerName()+" PING "+serv->GetName()); - serv->SetNextPingTime(curtime + 300); - } - else - { - // they didnt answer, boot them - WriteOpers("*** Server \002%s\002 pinged out",serv->GetName().c_str()); - sock->Squit(serv,"Ping timeout"); - sock->Close(); - return; - } - } + if (curtime >= serv->NextPingTime()) + { + if (serv->AnsweredLastPing()) + { + sock->WriteLine(":"+Srv->GetServerName()+" PING "+serv->GetName()); + serv->SetNextPingTime(curtime + 120); + } + else + { + // they didnt answer, boot them + WriteOpers("*** Server \002%s\002 pinged out",serv->GetName().c_str()); + sock->Squit(serv,"Ping timeout"); + sock->Close(); + Srv->RemoveSocket(sock); + return; + } + } + } } } |