]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Fix various rline bugs, implement /stats R, and fix the issue where you get no error...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index c14687804ee8332be0d877f8e45b3169aadab72c..86d511a2a970993a1aefd6752aa16f0551526642 100644 (file)
@@ -333,6 +333,30 @@ void ModuleSpanningTree::AutoConnectServers(time_t curtime)
        }
 }
 
+void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
+{
+       std::vector<Link*> failovers;
+       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();
+                       Link* MyLink = Utils->FindLink(p.first);
+                       if (MyLink)
+                               failovers.push_back(MyLink);
+               }
+       }
+       /* Trigger failover for each timed out socket */
+       for (std::vector<Link*>::const_iterator n = failovers.begin(); n != failovers.end(); ++n)
+       {
+               Utils->DoFailOver(*n);
+       }
+}
+
 int ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
 {
        // we've already checked if pcnt > 0, so this is safe
@@ -573,6 +597,7 @@ void ModuleSpanningTree::OnBackgroundTimer(time_t curtime)
 {
        AutoConnectServers(curtime);
        DoPingChecks(curtime);
+       DoConnectTimeout(curtime);
 }
 
 void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)