diff --git a/include/libnetwrk/net/core/shared/shared_connection.hpp b/include/libnetwrk/net/core/shared/shared_connection.hpp index 7ccad41..e3121dd 100644 --- a/include/libnetwrk/net/core/shared/shared_connection.hpp +++ b/include/libnetwrk/net/core/shared/shared_connection.hpp @@ -116,23 +116,20 @@ namespace libnetwrk { recv_message.head.deserialize(head_buffer); - recv_message.head.recv_timestamp = - std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - - if (recv_message.head.data_size == 0) { - ec = {}; - co_return; - } - - recv_message.data.underlying().resize(recv_message.head.data_size); + if (recv_message.head.data_size != 0) { + recv_message.data.underlying().resize(recv_message.head.data_size); - auto [b_ec, b_size] = co_await m_socket.async_read(recv_message.data); + auto [b_ec, b_size] = co_await m_socket.async_read(recv_message.data); - if (b_ec) { - ec = b_ec; - co_return; + if (b_ec) { + ec = b_ec; + co_return; + } } + recv_message.head.recv_timestamp = + std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ec = {}; }