From b7eb7cd97462adeb3e8865c438ccd959ccbf563a Mon Sep 17 00:00:00 2001 From: taynpg Date: Fri, 13 Dec 2024 12:39:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=AD=A3=E9=94=81?= =?UTF-8?q?=E9=87=8A=E6=94=BE=E4=BD=8D=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/server.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/server.cpp b/server/server.cpp index 343cd28..9d6d0b9 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -100,11 +100,12 @@ void CTcpServer::handle_frame() if (cache_.size() > 0) { buf = cache_.front(); cache_.pop(); - } else { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - continue; } } + if (!buf) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + continue; + } // 拿到该包后,要看转发给谁或者处理 if (buf->type_ == 199) { // 询问在线客户端 @@ -130,11 +131,13 @@ void CTcpServer::send_simple_buf() if (scache_.size() > 0) { buf = scache_.front(); scache_.pop(); - } else { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - continue; } } + if (!buf) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + continue; + } + std::shared_ptr socket = nullptr; { std::lock_guard clock(cli_mut_);