diff --git a/include/ylt/coro_rpc/impl/coro_connection.hpp b/include/ylt/coro_rpc/impl/coro_connection.hpp index f01e739fb..a18be38c7 100644 --- a/include/ylt/coro_rpc/impl/coro_connection.hpp +++ b/include/ylt/coro_rpc/impl/coro_connection.hpp @@ -23,13 +23,10 @@ #include #include #include -#include #include #include #include #include -#include -#include #include #include "ylt/coro_io/coro_io.hpp" diff --git a/include/ylt/coro_rpc/impl/errno.h b/include/ylt/coro_rpc/impl/errno.h index ccfa0c60a..6c2f2d573 100644 --- a/include/ylt/coro_rpc/impl/errno.h +++ b/include/ylt/coro_rpc/impl/errno.h @@ -16,7 +16,7 @@ #include #pragma once namespace coro_rpc { -enum class errc : uint8_t { +enum class errc : uint16_t { ok, io_error, not_connected, @@ -29,8 +29,8 @@ enum class errc : uint8_t { protocol_error, message_too_large, server_has_ran, - user_defined_err_min = 100, - user_defined_err_max = 255 + user_defined_err_min = 256, + user_defined_err_max = 65535 }; inline bool operator!(errc ec) { return ec == errc::ok; } inline std::string_view make_error_message(errc ec) { diff --git a/include/ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp b/include/ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp index 70f93e433..0e448baee 100644 --- a/include/ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp +++ b/include/ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp @@ -66,11 +66,11 @@ struct coro_rpc_protocol { struct resp_header { uint8_t magic; //!< magic number uint8_t version; //!< rpc protocol version - uint8_t err_code; //!< rpc error type - uint8_t msg_type; //!< message type + uint16_t err_code; //!< rpc error type uint32_t seq_num; //!< sequence number uint32_t length; //!< length of RPC body uint32_t attach_length; //!< reserved field + uint8_t msg_type; //!< message type }; using supported_serialize_protocols = std::variant; @@ -151,7 +151,7 @@ struct coro_rpc_protocol { auto& resp_head = *(resp_header*)header_buf.data(); resp_head.magic = magic_number; resp_head.seq_num = req_header.seq_num; - resp_head.err_code = static_cast(rpc_err_code); + resp_head.err_code = static_cast(rpc_err_code); resp_head.attach_length = attachment_len; if (rpc_err_code != coro_rpc::errc{}) AS_UNLIKELY { @@ -179,7 +179,7 @@ struct coro_rpc_protocol { static_assert(REQ_HEAD_LEN == 20); static constexpr auto RESP_HEAD_LEN = sizeof(resp_header{}); - static_assert(RESP_HEAD_LEN == 16); + static_assert(RESP_HEAD_LEN == 20); }; } // namespace protocol template