mirror of
https://github.com/znc/znc.git
synced 2026-05-09 23:04:47 +02:00
Remove the dedicated new-client-timeout timer
We used to start a dedicated timer for a new client socket that would make sure the client is disconnected if it didn't successfully log in after 60 seconds. This is now replaced by using Csocket's built-in timeout support. When a new client connects we SetTimeout(60, 0); which means that Timeout() will be called in 60 seconds, no matter what. The second argument is a bitmask which says on which events the timeout should be reset (TMO_READ, TMO_WRITE, TMO_ACCEPT, TMO_ALL). Once the client logs in successfully, CClient::AcceptLogin() now sets back the proper timeout (SetTimeout(240, TMO_READ);) which was set in Connected() before. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1622 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+4
-24
@@ -55,9 +55,6 @@ CClient::~CClient() {
|
||||
m_pUser->AddBytesRead(GetBytesRead());
|
||||
m_pUser->AddBytesWritten(GetBytesWritten());
|
||||
}
|
||||
if (m_pTimeout) {
|
||||
CZNC::Get().GetManager().DelCronByAddr(m_pTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::ReadLine(const CString& sData) {
|
||||
@@ -658,11 +655,6 @@ void CAuthBase::RefuseLogin(const CString& sReason) {
|
||||
}
|
||||
|
||||
void CClient::RefuseLogin(const CString& sReason) {
|
||||
if (m_pTimeout) {
|
||||
m_pTimeout->Stop();
|
||||
m_pTimeout = NULL;
|
||||
}
|
||||
|
||||
PutStatus("Bad username and/or password.");
|
||||
PutClient(":irc.znc.in 464 " + GetNick() + " :" + sReason);
|
||||
Close(Csock::CLT_AFTERWRITE);
|
||||
@@ -678,10 +670,9 @@ void CClient::AcceptLogin(CUser& User) {
|
||||
m_sPass = "";
|
||||
m_pUser = &User;
|
||||
|
||||
if (m_pTimeout) {
|
||||
m_pTimeout->Stop();
|
||||
m_pTimeout = NULL;
|
||||
}
|
||||
// Set our proper timeout and set back our proper timeout mode
|
||||
// (constructor set a different timeout and mode)
|
||||
SetTimeout(240, TMO_READ);
|
||||
|
||||
SetSockName("USR::" + m_pUser->GetUserName());
|
||||
|
||||
@@ -693,23 +684,12 @@ void CClient::AcceptLogin(CUser& User) {
|
||||
MODULECALL(OnClientLogin(), m_pUser, this, );
|
||||
}
|
||||
|
||||
void CClient::StartLoginTimeout() {
|
||||
m_pTimeout = new CClientTimeout(this);
|
||||
CZNC::Get().GetManager().AddCron(m_pTimeout);
|
||||
}
|
||||
|
||||
void CClient::LoginTimeout() {
|
||||
void CClient::Timeout() {
|
||||
PutClient("ERROR :Closing link [Timeout]");
|
||||
Close(Csock::CLT_AFTERWRITE);
|
||||
if (m_pTimeout) {
|
||||
m_pTimeout->Stop();
|
||||
m_pTimeout = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::Connected() {
|
||||
DEBUG(GetSockName() << " == Connected();");
|
||||
SetTimeout(240, TMO_READ); // Now that we are connected, let nature take its course
|
||||
}
|
||||
|
||||
void CClient::ConnectionRefused() {
|
||||
|
||||
Reference in New Issue
Block a user