summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-24 16:22:50 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-24 16:22:50 +0000
commitc0eda93f4e758d5f2e1875d828076cd8f2089335 (patch)
tree3d195c5f30febb681b331de378f63d1969d3af67
parent2d6813e2eab42e450fb2b2914920b124373050ad (diff)
Added more immediate disconnect when a server isnt routable any more
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1496 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/servers.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/servers.cpp b/src/servers.cpp
index d22ad760f..ff5f40a68 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -36,6 +36,7 @@ using namespace std;
extern time_t TIME;
extern int MaxConn;
+extern serverrec* me[32];
std::deque<std::string> xsums;
@@ -230,7 +231,7 @@ bool serverrec::AddIncoming(int newfd, char* targethost, int sourceport)
void serverrec::TerminateLink(char* targethost)
{
// this locates the targethost in the serverrec::connectors vector of the class,
- // and terminates it by sending it an SQUIT token and closing its descriptor.
+ // and terminates it by sending it an SQUIT token and closing its descriptor.
// TerminateLink with a null string causes a terminate of ALL links
}
@@ -247,6 +248,36 @@ ircd_connector* serverrec::FindHost(std::string findhost)
return NULL;
}
+
+// Checks to see if we can still reach a server at all (e.g. is it in ANY routing table?)
+bool IsRoutable(std::string servername)
+{
+ for (int x = 0; x < 32; x++) if (me[x])
+ {
+ ircd_connector* cn = me[x]->FindHost(servername.c_str());
+ if (cn)
+ {
+ if (cn->GetState() == STATE_DISCONNECTED)
+ {
+ for (int k = 0; k < me[x]->connectors.size(); k++)
+ {
+ for (int m = 0; m < me[x]->connectors[k].routes.size(); m++)
+ {
+ if (!strcasecmp(me[x]->connectors[k].routes[m].c_str(),servername.c_str()))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ else return true;
+ }
+ }
+ return false;
+}
+
+
void serverrec::FlushWriteBuffers()
{
for (int i = 0; i < this->connectors.size(); i++)
@@ -272,6 +303,11 @@ void serverrec::FlushWriteBuffers()
WriteOpers("*** Lost single connection to %s: Ping timeout",this->connectors[i].GetServerName().c_str());
this->connectors[i].CloseConnection();
this->connectors[i].SetState(STATE_DISCONNECTED);
+ if (!IsRoutable(this->connectors[i].GetServerName()))
+ {
+ WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
+ DoSplit(this->connectors[i].GetServerName().c_str());
+ }
}
}
if (this->connectors[i].HasBufferedOutput())
@@ -282,6 +318,11 @@ void serverrec::FlushWriteBuffers()
WriteOpers("*** Lost single connection to %s, link inactive and retrying: %s",this->connectors[i].GetServerName().c_str(),this->connectors[i].GetWriteError().c_str());
this->connectors[i].CloseConnection();
this->connectors[i].SetState(STATE_DISCONNECTED);
+ if (!IsRoutable(this->connectors[i].GetServerName()))
+ {
+ WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
+ DoSplit(this->connectors[i].GetServerName().c_str());
+ }
}
}
}
@@ -411,6 +452,11 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
log(DEBUG,"Disabling connector: %s",this->connectors[i].GetServerName().c_str());
this->connectors[i].CloseConnection();
this->connectors[i].SetState(STATE_DISCONNECTED);
+ if (!IsRoutable(this->connectors[i].GetServerName()))
+ {
+ WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
+ DoSplit(this->connectors[i].GetServerName().c_str());
+ }
}
}
int pushed = 0;
@@ -421,6 +467,11 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std
WriteOpers("*** Read buffer for %s exceeds maximum, closing connection!",this->connectors[i].GetServerName().c_str());
this->connectors[i].CloseConnection();
this->connectors[i].SetState(STATE_DISCONNECTED);
+ if (!IsRoutable(this->connectors[i].GetServerName()))
+ {
+ WriteOpers("*** Server %s is no longer routable, disconnecting.",this->connectors[i].GetServerName().c_str());
+ DoSplit(this->connectors[i].GetServerName().c_str());
+ }
}
if (this->connectors[i].BufferIsComplete())
{