}
}
+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
{
AutoConnectServers(curtime);
DoPingChecks(curtime);
+ DoConnectTimeout(curtime);
}
void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
*/
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);
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();
}
{
if (Hook)
BufferedSocketUnhookRequest(this, (Module*)Utils->Creator, Hook).Send();
+ Utils->timeoutlist.erase(this);
}
/** When an outbound connection finishes connecting, we receive
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())
/** 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;