From b7a20454ce09b3e8f81ca76d86b45993e3be0a86 Mon Sep 17 00:00:00 2001 From: peavey Date: Fri, 19 Sep 2008 02:00:04 +0000 Subject: Implement timeout on outgoing server connections as per our docs git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10558 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/modules/m_spanningtree/main.cpp') 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 >::iterator i = Utils->timeoutlist.begin(); i != Utils->timeoutlist.end(); i++) + { + TreeSocket* s = i->first; + std::pair 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& 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) -- cgit v1.3.1-10-gc9f91