Backport of stability fix for 'connection refused' on autoconnect/connect

git-svn-id: http://svn.inspircd.org/repository/branches/1_0_stable@3794 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-04-01 23:11:22 +00:00
parent 0e0353a5ed
commit acc947b584
2 changed files with 5 additions and 5 deletions

View File

@ -3221,13 +3221,13 @@ 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.c_str());
if (newsocket->GetState() != I_ERROR)
if (newsocket->GetFd() > -1)
{
Srv->AddSocket(newsocket);
}
else
{
WriteOpers("*** AUTOCONNECT: Error autoconnecting \002%s\002.",x->Name.c_str());
WriteOpers("*** AUTOCONNECT: Error autoconnecting \002%s\002: %s.",x->Name.c_str(),strerror(errno));
delete newsocket;
}
}
@ -3283,13 +3283,13 @@ 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.c_str());
if (newsocket->GetState() != I_ERROR)
if (newsocket->GetFd() > -1)
{
Srv->AddSocket(newsocket);
}
else
{
WriteServ(user->fd,"NOTICE %s :*** CONNECT: Error connecting \002%s\002.",user->nick,x->Name.c_str());
WriteServ(user->fd,"NOTICE %s :*** CONNECT: Error connecting \002%s\002: %s.",user->nick,x->Name.c_str(),strerror(errno));
delete newsocket;
}
return 1;

View File

@ -188,8 +188,8 @@ bool InspSocket::DoConnect()
{
log(DEBUG,"Error connect() %d: %s",this->fd,strerror(errno));
this->OnError(I_ERR_CONNECT);
this->state = I_ERROR;
this->Close();
this->state = I_ERROR;
this->fd = -1;
this->ClosePending = true;
return false;