fix:修正Server端,漏解析包bug。
This commit is contained in:
parent
004d894129
commit
0cafcaf643
@ -63,18 +63,16 @@ void CTcpClient::async_recv()
|
||||
}
|
||||
} else {
|
||||
buffer_.push(tmp_buf_.data(), length);
|
||||
|
||||
bool done = true;
|
||||
while (done) {
|
||||
while (true) {
|
||||
auto* frame = CTransProtocal::parse(buffer_);
|
||||
if (frame) {
|
||||
if (fun_) {
|
||||
fun_(frame);
|
||||
}
|
||||
delete frame;
|
||||
} else {
|
||||
done = false;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
async_recv();
|
||||
}
|
||||
|
@ -238,11 +238,15 @@ void CTcpServer::th_client(std::shared_ptr<asio::ip::tcp::socket> socket, const
|
||||
}
|
||||
|
||||
cache->buffer_.push(cache->tmp_buf_.data(), length);
|
||||
auto* frame = CTransProtocal::parse(cache->buffer_);
|
||||
if (frame) {
|
||||
frame->fid_ = client_key;
|
||||
std::lock_guard<std::mutex> lock(buf_mut_);
|
||||
cache_.push_back(frame);
|
||||
while (true) {
|
||||
auto* frame = CTransProtocal::parse(cache->buffer_);
|
||||
if (frame) {
|
||||
frame->fid_ = client_key;
|
||||
std::lock_guard<std::mutex> lock(buf_mut_);
|
||||
cache_.push_back(frame);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user