diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-03-30 00:36:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 00:36:00 +0200 |
commit | 8ec555299873712d03c76f705e5bfe7ade01da4d (patch) | |
tree | b6cbc6a4f42171a8dba5714b95c67086f6a95fb3 /src | |
parent | Call ProcessProtocolOut at opportune times (diff) | |
download | cuberite-8ec555299873712d03c76f705e5bfe7ade01da4d.tar cuberite-8ec555299873712d03c76f705e5bfe7ade01da4d.tar.gz cuberite-8ec555299873712d03c76f705e5bfe7ade01da4d.tar.bz2 cuberite-8ec555299873712d03c76f705e5bfe7ade01da4d.tar.lz cuberite-8ec555299873712d03c76f705e5bfe7ade01da4d.tar.xz cuberite-8ec555299873712d03c76f705e5bfe7ade01da4d.tar.zst cuberite-8ec555299873712d03c76f705e5bfe7ade01da4d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ClientHandle.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 04436070c..5762de897 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -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,12 +3325,14 @@ void cClientHandle::ProcessProtocolIn(void) decltype(m_IncomingData) IncomingData; { cCSLock Lock(m_CSIncomingData); - std::swap(IncomingData, m_IncomingData); - } - if (IncomingData.empty()) - { - return; + // Bail out when nothing was received: + if (m_IncomingData.empty()) + { + return; + } + + std::swap(IncomingData, m_IncomingData); } try |