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_);