From 5b0b077e2a9a051b93b7837da79351ede361bcd6 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 2 Aug 2006 10:36:38 +0000 Subject: Check for duplicate servers in OnLookupComplete git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4636 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/modules/m_spanningtree.cpp') diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 73d054b24..d4bc5360e 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -3091,17 +3091,21 @@ class ServernameResolver : public Resolver * Passing a hostname directly to InspSocket causes it to * just bail and set its FD to -1. */ - TreeSocket* newsocket = new TreeSocket(result,MyLink.Port,false,10,MyLink.Name.c_str()); - if (newsocket->GetFd() > -1) + TreeServer* CheckDupe = FindServer(MyLink.Name.c_str()); + if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */ { - /* We're all OK */ - Srv->AddSocket(newsocket); - } - else - { - /* Something barfed, show the opers */ - WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno)); - delete newsocket; + TreeSocket* newsocket = new TreeSocket(result,MyLink.Port,false,10,MyLink.Name.c_str()); + if (newsocket->GetFd() > -1) + { + /* We're all OK */ + Srv->AddSocket(newsocket); + } + else + { + /* Something barfed, show the opers */ + WriteOpers("*** CONNECT: Error connecting \002%s\002: %s.",MyLink.Name.c_str(),strerror(errno)); + delete newsocket; + } } } @@ -3718,6 +3722,7 @@ class ModuleSpanningTree : public Module insp_inaddr binip; + /* Do we already have an IP? If so, no need to resolve it. */ if (insp_aton(x->IPAddr.c_str(), &binip) > 0) { TreeSocket* newsocket = new TreeSocket(x->IPAddr,x->Port,false,10,x->Name.c_str()); @@ -3791,6 +3796,7 @@ class ModuleSpanningTree : public Module WriteServ(user->fd,"NOTICE %s :*** CONNECT: Connecting to server: \002%s\002 (%s:%d)",user->nick,x->Name.c_str(),(x->HiddenFromStats ? "" : x->IPAddr.c_str()),x->Port); insp_inaddr binip; + /* Do we already have an IP? If so, no need to resolve it. */ if (insp_aton(x->IPAddr.c_str(), &binip) > 0) { TreeSocket* newsocket = new TreeSocket(x->IPAddr,x->Port,false,10,x->Name.c_str()); -- cgit v1.2.3