diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index 289451ec..80b6c359 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -44,7 +44,14 @@ public: ~CIRCNetwork(); enum { - PING_TIMEOUT = 270 + /** How long must an IRC connection be idle before ZNC sends a ping */ + PING_FREQUENCY = 270, + /** Time between checks if PINGs need to be sent */ + PING_SLACK = 30, + /** Timeout after which IRC connections are closed. Must + * obviously be smaller than PING_FREQUENCY + PING_SLACK. + */ + NO_TRAFFIC_TIMEOUT = 540 }; void Clone(const CIRCNetwork& Network, bool bCloneName = true); diff --git a/src/Client.cpp b/src/Client.cpp index a6ea8b67..44cadf70 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -671,7 +671,7 @@ void CClient::AcceptLogin(CUser& User) { // Set our proper timeout and set back our proper timeout mode // (constructor set a different timeout and mode) - SetTimeout(540, TMO_READ); + SetTimeout(CIRCNetwork::NO_TRAFFIC_TIMEOUT, TMO_READ); SetSockName("USR::" + m_pUser->GetUserName()); SetEncoding(m_pUser->GetClientEncoding()); diff --git a/src/IRCNetwork.cpp b/src/IRCNetwork.cpp index 00c5787a..ec15fcd7 100644 --- a/src/IRCNetwork.cpp +++ b/src/IRCNetwork.cpp @@ -30,7 +30,7 @@ public: CIRCNetworkPingTimer(CIRCNetwork *pNetwork) : CCron() { m_pNetwork = pNetwork; SetName("CIRCNetworkPingTimer::" + m_pNetwork->GetUser()->GetUserName() + "::" + m_pNetwork->GetName()); - Start(30); + Start(CIRCNetwork::PING_SLACK); } virtual ~CIRCNetworkPingTimer() {} @@ -39,7 +39,7 @@ protected: virtual void RunJob() { CIRCSock* pIRCSock = m_pNetwork->GetIRCSock(); - if (pIRCSock && pIRCSock->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_TIMEOUT) { + if (pIRCSock && pIRCSock->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_FREQUENCY) { pIRCSock->PutIRC("PING :ZNC"); } @@ -47,7 +47,7 @@ protected: for (size_t b = 0; b < vClients.size(); b++) { CClient* pClient = vClients[b]; - if (pClient->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_TIMEOUT) { + if (pClient->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_FREQUENCY) { pClient->PutClient("PING :ZNC"); } } diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 1e0c7931..d7f0a42a 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -174,7 +174,7 @@ void CIRCSock::ReadLine(const CString& sData) { } m_pNetwork->SetIRCServer(sServer); - SetTimeout(540, TMO_READ); // Now that we are connected, let nature take its course + SetTimeout(CIRCNetwork::NO_TRAFFIC_TIMEOUT, TMO_READ); // Now that we are connected, let nature take its course PutIRC("WHO " + sNick); m_bAuthed = true; diff --git a/src/User.cpp b/src/User.cpp index ee672b09..930d211e 100644 --- a/src/User.cpp +++ b/src/User.cpp @@ -29,7 +29,7 @@ public: CUserTimer(CUser* pUser) : CCron() { m_pUser = pUser; SetName("CUserTimer::" + m_pUser->GetUserName()); - Start(30); + Start(CIRCNetwork::PING_SLACK); } virtual ~CUserTimer() {} @@ -40,7 +40,7 @@ protected: for (size_t c = 0; c < vUserClients.size(); ++c) { CClient* pUserClient = vUserClients[c]; - if (pUserClient->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_TIMEOUT) { + if (pUserClient->GetTimeSinceLastDataTransaction() >= CIRCNetwork::PING_FREQUENCY) { pUserClient->PutClient("PING :ZNC"); } }