Do an early check for empty network buffers (#5172)
Avoid overhead when nothing to do.
This commit is contained in:
parent
abcc14076c
commit
8ec5552998
@ -232,6 +232,13 @@ void cClientHandle::ProcessProtocolOut()
|
||||
decltype(m_OutgoingData) OutgoingData;
|
||||
{
|
||||
cCSLock Lock(m_CSOutgoingData);
|
||||
|
||||
// Bail out when there's nothing to send to avoid TCPLink::Send overhead:
|
||||
if (m_OutgoingData.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::swap(OutgoingData, m_OutgoingData);
|
||||
}
|
||||
|
||||
@ -3318,14 +3325,16 @@ void cClientHandle::ProcessProtocolIn(void)
|
||||
decltype(m_IncomingData) IncomingData;
|
||||
{
|
||||
cCSLock Lock(m_CSIncomingData);
|
||||
std::swap(IncomingData, m_IncomingData);
|
||||
}
|
||||
|
||||
if (IncomingData.empty())
|
||||
// Bail out when nothing was received:
|
||||
if (m_IncomingData.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::swap(IncomingData, m_IncomingData);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_Protocol.HandleIncomingData(*this, std::move(IncomingData));
|
||||
|
Loading…
Reference in New Issue
Block a user