mirror of
https://github.com/znc/znc.git
synced 2026-05-01 11:02:27 +02:00
Debug: Only print queued lines if they are really just queued
Previously, every line that was forwarded to the IRCd was printed twice in debug mode. Once when it got added to the send queue and a second time when it was actually sent. However, most of the time this queue is empty and thus the two events happened at approximately the same time. Thus, this patch now changes the debug output. Lines are only printed extra if they really have to wait in the queue for a while before they can be sent out. This has the positive effect of making the debug output more readable, because it is shorter and less repetitive and it makes it more obvious when znc actively throttles the traffic that is sent out. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
@@ -1016,19 +1016,26 @@ bool CIRCSock::OnChanMsg(CNick& Nick, const CString& sChan, CString& sMessage) {
|
||||
}
|
||||
|
||||
void CIRCSock::PutIRC(const CString& sLine) {
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine << "] (queued)");
|
||||
// Only print if the line won't get sent immediately (same condition as in TrySend()!)
|
||||
if (m_bFloodProtection && m_iSendsAllowed <= 0) {
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine << "] (queued)");
|
||||
}
|
||||
m_vsSendQueue.push_back(sLine);
|
||||
TrySend();
|
||||
}
|
||||
|
||||
void CIRCSock::PutIRCQuick(const CString& sLine) {
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine << "] (queued to front)");
|
||||
// Only print if the line won't get sent immediately (same condition as in TrySend()!)
|
||||
if (m_bFloodProtection && m_iSendsAllowed <= 0) {
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine << "] (queued to front)");
|
||||
}
|
||||
m_vsSendQueue.push_front(sLine);
|
||||
TrySend();
|
||||
}
|
||||
|
||||
void CIRCSock::TrySend() {
|
||||
while (!m_vsSendQueue.empty() && (m_iSendsAllowed > 0 || !m_bFloodProtection)) {
|
||||
// This condition must be the same as in PutIRC() and PutIRCQuick()!
|
||||
while (!m_vsSendQueue.empty() && (!m_bFloodProtection || m_iSendsAllowed > 0)) {
|
||||
m_iSendsAllowed--;
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") ZNC -> IRC [" << m_vsSendQueue.front() << "]");
|
||||
Write(m_vsSendQueue.front() + "\r\n");
|
||||
|
||||
Reference in New Issue
Block a user