diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 16 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 3 |
5 files changed, 27 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index c14687804..264ee1078 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -333,6 +333,21 @@ void ModuleSpanningTree::AutoConnectServers(time_t curtime) } } +void ModuleSpanningTree::DoConnectTimeout(time_t curtime) +{ + for (std::map<TreeSocket*, std::pair<std::string, int> >::iterator i = Utils->timeoutlist.begin(); i != Utils->timeoutlist.end(); i++) + { + TreeSocket* s = i->first; + std::pair<std::string, int> p = i->second; + if (curtime > s->age + p.second) + { + ServerInstance->SNO->WriteToSnoMask('l',"CONNECT: Error connecting \002%s\002 (timeout of %d seconds)",p.first.c_str(),p.second); + ServerInstance->SE->DelFd(s); + s->Close(); + } + } +} + int ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user) { // we've already checked if pcnt > 0, so this is safe @@ -573,6 +588,7 @@ void ModuleSpanningTree::OnBackgroundTimer(time_t curtime) { AutoConnectServers(curtime); DoPingChecks(curtime); + DoConnectTimeout(curtime); } void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 861bf7e14..8cfcaaa02 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -124,6 +124,10 @@ class ModuleSpanningTree : public Module */ void AutoConnectServers(time_t curtime); + /** Check if any connecting servers should timeout + */ + void DoConnectTimeout(time_t curtime); + /** Handle remote VERSON */ int HandleVersion(const std::vector<std::string>& parameters, User* user); diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 589e05bcd..09c3158cc 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -43,6 +43,7 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string sh theirchallenge.clear(); ourchallenge.clear(); this->LinkState = CONNECTING; + Utils->timeoutlist[this] = std::pair<std::string, int>(ServerName,maxtime); if (Hook) BufferedSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send(); } @@ -81,6 +82,7 @@ TreeSocket::~TreeSocket() { if (Hook) BufferedSocketUnhookRequest(this, (Module*)Utils->Creator, Hook).Send(); + Utils->timeoutlist.erase(this); } /** When an outbound connection finishes connecting, we receive diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index c2664a65e..c1b45237d 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -175,6 +175,8 @@ bool TreeSocket::ProcessLine(std::string &line) this->LinkState = CONNECTED; Link* lnk = Utils->FindLink(InboundServerName); + Utils->timeoutlist.erase(this); + Node = new TreeServer(this->Utils, this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false); if (Node->DuplicateID()) diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 1022c1796..839c1899c 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -109,6 +109,9 @@ class SpanningTreeUtilities : public classbase /** Hash of servers currently bursting but not initialized as connected */ std::map<irc::string,TreeSocket*> burstingserverlist; + /** List of all outgoing sockets and their timeouts + */ + std::map<TreeSocket*, std::pair<std::string, int> > timeoutlist; /** Holds the data from the <link> tags in the conf */ std::vector<Link> LinkBlocks; |