Skip to content

Commit

Permalink
Merge branch 'main' into support_multipart
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Dec 27, 2023
2 parents 3bcb4a8 + 5272b07 commit 3dd3100
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/ylt/coro_rpc/impl/coro_rpc_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class coro_rpc_server_base {

coro_rpc_server_base(const server_config &config = server_config{})
: pool_(config.thread_num),
acceptor_(pool_.get_io_context()),
acceptor_(pool_.get_executor()->get_asio_executor()),
port_(config.port),
conn_timeout_duration_(config.conn_timeout_duration),
flag_{stat::init} {}
Expand Down
22 changes: 13 additions & 9 deletions include/ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,24 @@ struct coro_rpc_protocol {
static async_simple::coro::Lazy<std::error_code> read_payload(
Socket& socket, req_header& req_head, std::string& buffer,
std::string& attchment) {
uint64_t total = req_head.length + req_head.attach_length;
struct_pack::detail::resize(buffer, req_head.length);
if (req_head.attach_length > 0) {
struct_pack::detail::resize(attchment, req_head.attach_length);
std::array<asio::mutable_buffer, 2> iov = {
asio::mutable_buffer{buffer.data(), buffer.size()},
asio::mutable_buffer{attchment.data(), attchment.size()}};
auto [ec, _] = co_await coro_io::async_read(socket, iov);
co_return ec;
}
else {
auto [ec, _] = co_await coro_io::async_read(socket, asio::buffer(buffer));

if (req_head.length > 0) {
std::array<asio::mutable_buffer, 2> buffers{asio::buffer(buffer),
asio::buffer(attchment)};
auto [ec, _] = co_await coro_io::async_read(socket, buffers);
co_return ec;
}

auto [ec, _] =
co_await coro_io::async_read(socket, asio::buffer(attchment));
co_return ec;
}

auto [ec, _] = co_await coro_io::async_read(socket, asio::buffer(buffer));
co_return ec;
}

static std::string prepare_response(std::string& rpc_result,
Expand Down

0 comments on commit 3dd3100

Please sign in to comment.