Skip to content

Commit

Permalink
[coro_rpc]Fix for clang (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Dec 26, 2023
1 parent 0580035 commit d8ce57f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
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
2 changes: 1 addition & 1 deletion src/coro_http/examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void test_coro_http_server() {
int main() {
test_coro_http_server();
test_sync_client();
use_out_buf();
// use_out_buf();

coro_http::coro_http_client client{};
async_simple::coro::syncAwait(test_async_client(client));
Expand Down

0 comments on commit d8ce57f

Please sign in to comment.