summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-02 17:38:04 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-02 17:38:04 +0000
commitb145f922e0571dee3690b6886e59bc6ce7f1fb15 (patch)
tree5c3ce105e763c33e4f82b667462f3fedd8c07d93
parentcb16da88946f7f75a438b471734fa22c33f94461 (diff)
When socket fails to construct, we now check the GetState() of the socket object to detect this condition.
If we dont, we can end up leaking fd's and RAM on failure. We dont use exceptions here as these operations can occur very often. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3021 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_ident.cpp12
-rw-r--r--src/modules/m_spanningtree.cpp20
2 files changed, 28 insertions, 4 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 93fe115a2..2f8ac8283 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -165,8 +165,16 @@ class ModuleIdent : public Module
// Server::AddSocket() call.
Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :*** Looking up your ident...");
RFC1413* ident = new RFC1413(user, IdentTimeout, Srv);
- user->Extend("ident_data", (char*)ident);
- Srv->AddSocket(ident);
+ if (ident->GetState() != I_ERROR)
+ {
+ user->Extend("ident_data", (char*)ident);
+ Srv->AddSocket(ident);
+ }
+ else
+ {
+ Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :*** Could not find your ident, using "+std::string(user->ident)+" instead.");
+ delete ident;
+ }
}
virtual bool OnCheckReady(userrec* user)
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 842c0e770..16be107e1 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -2722,7 +2722,15 @@ class ModuleSpanningTree : public Module
// an autoconnected server is not connected. Check if its time to connect it
WriteOpers("*** AUTOCONNECT: Auto-connecting server \002%s\002 (%lu seconds until next attempt)",x->Name.c_str(),x->AutoConnect);
TreeSocket* newsocket = new TreeSocket(x->IPAddr,x->Port,false,10,x->Name);
- Srv->AddSocket(newsocket);
+ if (newsocket->GetState() != I_ERROR)
+ {
+ Srv->AddSocket(newsocket);
+ }
+ else
+ {
+ WriteOpers("*** AUTOCONNECT: Error autoconnecting \002%s\002.",x->Name.c_str());
+ delete newsocket;
+ }
}
}
}
@@ -2774,7 +2782,15 @@ 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 ? "<hidden>" : x->IPAddr.c_str()),x->Port);
TreeSocket* newsocket = new TreeSocket(x->IPAddr,x->Port,false,10,x->Name);
- Srv->AddSocket(newsocket);
+ if (newsocket->GetState() != I_ERROR)
+ {
+ Srv->AddSocket(newsocket);
+ }
+ else
+ {
+ WriteServ(user->fd,"NOTICE %s :*** CONNECT: Error connecting \002%s\002.",user->nick,x->Name.c_str());
+ delete newsocket;
+ }
return 1;
}
else