diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-24 01:49:07 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-24 01:49:07 +0000 |
commit | 5b08c0883c83c95ceca07e590620fe254b17f6ab (patch) | |
tree | 7ea4f795eb8a18530e231dc5ce2bac41027c3eb4 /src/connection.cpp | |
parent | 0a1ef900f98881a03dfa0945ff1eddfa8b1dfba5 (diff) |
Added ping checks for server links (experimental)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1481 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/connection.cpp')
-rw-r--r-- | src/connection.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/connection.cpp b/src/connection.cpp index c7221ce74..2f6cbd6d5 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -82,6 +82,8 @@ ircd_connector::ircd_connector() port = 0; sendq = ""; WriteError = ""; + nextping = TIME+30; + replied = false; } char* ircd_connector::GetServerIP() @@ -179,6 +181,35 @@ bool ircd_connector::HasBufferedOutput() return (sendq.length() > 0); } +bool ircd_connector::CheckPing() +{ + if (TIME > this->nextping) + { + if (this->replied) + { + this->AddWriteBuf("?\n"); + this->nextping = TIME+30; + this->replied = false; + return true; + } + else + { + this->SetWriteError("Ping timeout"); + this->CloseConnection(); + this->SetState(STATE_DISCONNECTED); + WriteOpers("*** Ping timeout on link to %s (more routes may remain)",this->GetServerName().c_str()); + return false; + } + } +} + +void ircd_connector::ResetPing() +{ + log(DEBUG,"Reset ping counter"); + this->replied = true; + this->nextping = TIME+30; +} + // send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it) bool ircd_connector::FlushWriteBuf() { |