mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
Fixes async_exec function.
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
matrix:
|
||||
build-type: ['sanity']
|
||||
runs-on: [ubuntu-22.04]
|
||||
compiler: [g++-11]
|
||||
compiler: [g++-11, clang++11, clang++-13]
|
||||
cxx-std: ['c++20']
|
||||
optim-level: ['-O0']
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
|
||||
@@ -16,9 +16,9 @@ nobase_include_HEADERS =\
|
||||
$(top_srcdir)/include/aedis/resp3/compose.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/detail/read_ops.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/detail/parser.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/detail/exec.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/type.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/read.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/exec.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/write.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/request.hpp\
|
||||
$(top_srcdir)/include/aedis/resp3/impl/request.ipp\
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#include <aedis/error.hpp>
|
||||
#include <aedis/detail/net.hpp>
|
||||
#include <aedis/resp3/type.hpp>
|
||||
#include <aedis/resp3/detail/exec.hpp>
|
||||
#include <aedis/resp3/detail/parser.hpp>
|
||||
#include <aedis/resp3/read.hpp>
|
||||
#include <aedis/resp3/write.hpp>
|
||||
#include <aedis/resp3/request.hpp>
|
||||
#include <aedis/resp3/exec.hpp>
|
||||
|
||||
#define HANDLER_LOCATION \
|
||||
BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, __func__))
|
||||
@@ -413,10 +413,8 @@ struct run_op {
|
||||
|
||||
conn->ping_timer_.expires_after(conn->cfg_.ping_interval);
|
||||
|
||||
// TODO: This is going to consume on the first response i.e.
|
||||
// AUTH, we also have to consume the HELLO.
|
||||
yield
|
||||
resp3::async_exec(
|
||||
async_exec(
|
||||
*conn->socket_,
|
||||
conn->ping_timer_,
|
||||
conn->req_,
|
||||
|
||||
@@ -36,6 +36,8 @@ struct exec_op {
|
||||
request const* req = nullptr;
|
||||
Adapter adapter;
|
||||
DynamicBuffer dbuf{};
|
||||
std::size_t n_cmds = 0;
|
||||
std::size_t size = 0;
|
||||
boost::asio::coroutine coro{};
|
||||
|
||||
template <class Self>
|
||||
@@ -43,29 +45,38 @@ struct exec_op {
|
||||
, boost::system::error_code ec = {}
|
||||
, std::size_t n = 0)
|
||||
{
|
||||
reenter (coro)
|
||||
reenter (coro) for (;;)
|
||||
{
|
||||
yield
|
||||
boost::asio::async_write(
|
||||
*socket,
|
||||
boost::asio::buffer(req->payload()),
|
||||
std::move(self));
|
||||
if (req) {
|
||||
yield
|
||||
boost::asio::async_write(
|
||||
*socket,
|
||||
boost::asio::buffer(req->payload()),
|
||||
std::move(self));
|
||||
|
||||
if (ec || n_cmds == 0) {
|
||||
self.complete(ec, n);
|
||||
return;
|
||||
}
|
||||
|
||||
req = nullptr;
|
||||
}
|
||||
|
||||
yield resp3::async_read(*socket, dbuf, adapter, std::move(self));
|
||||
if (ec) {
|
||||
self.complete(ec, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
yield resp3::async_read(*socket, dbuf, adapter, std::move(self));
|
||||
self.complete(ec, n);
|
||||
size += n;
|
||||
if (--n_cmds == 0) {
|
||||
self.complete(ec, size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/asio/unyield.hpp>
|
||||
|
||||
} // detail
|
||||
|
||||
template <
|
||||
class AsyncStream,
|
||||
class Adapter,
|
||||
@@ -83,13 +94,9 @@ auto async_exec(
|
||||
< CompletionToken
|
||||
, void(boost::system::error_code, std::size_t)
|
||||
>(detail::exec_op<AsyncStream, Adapter, DynamicBuffer>
|
||||
{&socket, &req, adapter, dbuf}, token, socket);
|
||||
{&socket, &req, adapter, dbuf, req.size()}, token, socket);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
#include <boost/asio/yield.hpp>
|
||||
|
||||
template <
|
||||
class AsyncStream,
|
||||
class Timer,
|
||||
@@ -115,7 +122,7 @@ struct exec_with_timeout_op {
|
||||
{
|
||||
yield
|
||||
boost::asio::experimental::make_parallel_group(
|
||||
[this](auto token) { return resp3::async_exec(*socket, *req, adapter, dbuf, token);},
|
||||
[this](auto token) { return detail::async_exec(*socket, *req, adapter, dbuf, token);},
|
||||
[this](auto token) { return timer->async_wait(token);}
|
||||
).async_wait(
|
||||
boost::asio::experimental::wait_for_one(),
|
||||
@@ -148,8 +155,6 @@ struct exec_with_timeout_op {
|
||||
|
||||
#include <boost/asio/unyield.hpp>
|
||||
|
||||
} // detail
|
||||
|
||||
template <
|
||||
class AsyncStream,
|
||||
class Timer,
|
||||
@@ -172,6 +177,7 @@ auto async_exec(
|
||||
{&socket, &timer, &req, adapter, dbuf}, token, socket, timer);
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // resp3
|
||||
} // aedis
|
||||
|
||||
Reference in New Issue
Block a user