From 88a4177e285d65affeb2c2b97e308449a2c0cd4c Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 24 May 2005 04:05:14 +0000 Subject: Nonblocking connect() for outbound server links (why was this blocking anyway) Changed /map to show authenticating servers with a * similar to hybrid git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1485 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/servers.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/servers.cpp') diff --git a/src/servers.cpp b/src/servers.cpp index 38f9cfb5f..7ae90e41b 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -161,6 +161,8 @@ bool serverrec::BeginLink(char* targethost, int newport, char* password, char* s connector.SetState(STATE_NOAUTH_OUTBOUND); connector.SetHostAndPort(targethost, newport); this->connectors.push_back(connector); + // this packet isn't actually sent until the socket connects -- the STATE_NOAUTH_OUTBOUND state + // queues outbound data until the socket is polled as writeable (e.g. the connection is established) return this->SendPacket(connect, servername); } else @@ -250,7 +252,15 @@ void serverrec::FlushWriteBuffers() { for (int i = 0; i < this->connectors.size(); i++) { - if (this->connectors[i].GetState() != STATE_DISCONNECTED) + // don't try and ping a NOAUTH_OUTBOUND state, its not authed yet! + if (this->connectors[i].GetState() != STATE_NOAUTH_OUTBOUND) + { + // however if we reach this timer its connected timed out :) + WriteOpers("*** Connection to %s timed out",this->connectors[i].GetServerName().c_str()); + DoSplit(this->connectors[i].GetServerName().c_str()); + return; + } + else if (this->connectors[i].GetState() != STATE_DISCONNECTED) { if (!this->connectors[i].CheckPing()) { -- cgit v1.2.3