Skip to content

Commit 0520791

Browse files
committed
Renames request flag.
1 parent 14b376e commit 0520791

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

include/aedis/detail/connection_base.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class connection_base {
104104
return ret;
105105
}
106106

107-
// Remove requests that have the flag cancel_if_not_sent_when_connection_lost set
108107
auto cancel_on_conn_lost() -> std::size_t
109108
{
110109
// Must return false if the request should be removed.
@@ -113,7 +112,7 @@ class connection_base {
113112
BOOST_ASSERT(ptr != nullptr);
114113

115114
if (ptr->is_written()) {
116-
return ptr->get_request().get_config().retry_on_connection_lost;
115+
return !ptr->get_request().get_config().cancel_if_unresponded;
117116
} else {
118117
return !ptr->get_request().get_config().cancel_on_connection_lost;
119118
}
@@ -248,8 +247,8 @@ class connection_base {
248247
[[nodiscard]] auto get_request() const noexcept -> auto const&
249248
{ return *req_; }
250249

251-
[[nodiscard]] auto get_action() const noexcept
252-
{ return action_;}
250+
[[nodiscard]] auto stop_requested() const noexcept
251+
{ return action_ == action::stop;}
253252

254253
template <class CompletionToken>
255254
auto async_wait(CompletionToken token)

include/aedis/detail/connection_ops.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct exec_op {
131131
yield info->async_wait(std::move(self));
132132
BOOST_ASSERT(ec == boost::asio::error::operation_aborted);
133133

134-
if (info->get_action() == Conn::req_info::action::stop) {
134+
if (info->stop_requested()) {
135135
// Don't have to call remove_request as it has already
136136
// been by cancel(exec).
137137
return self.complete(ec, 0);
@@ -141,7 +141,7 @@ struct exec_op {
141141
if (info->is_written()) {
142142
using c_t = boost::asio::cancellation_type;
143143
auto const c = self.get_cancellation_state().cancelled();
144-
if ((c & (c_t::total | c_t::terminal)) != c_t::none) {
144+
if ((c & c_t::terminal) != c_t::none) {
145145
// Cancellation requires closing the connection
146146
// otherwise it stays in inconsistent state.
147147
conn->cancel(operation::run);

include/aedis/resp3/request.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class request {
192192
* requests that have been written to the socket but remained
193193
* unresponded when `aedis::connection::async_run` completed.
194194
*/
195-
bool retry_on_connection_lost = false;
195+
bool cancel_if_unresponded = true;
196196

197197
/** \brief If this request has a HELLO command and this flag is
198198
* true, the `aedis::connection` will move it to the front of
@@ -208,7 +208,7 @@ class request {
208208
* \param resource Memory resource.
209209
*/
210210
explicit
211-
request(config cfg = config{true, true, false, false, true},
211+
request(config cfg = config{true, true, false, true, true},
212212
std::pmr::memory_resource* resource = std::pmr::get_default_resource())
213213
: cfg_{cfg}, payload_(resource) {}
214214

tests/conn_exec.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE(request_retry_false)
139139
resp3::request req2;
140140
req2.get_config().coalesce = true;
141141
req2.get_config().cancel_on_connection_lost = false;
142-
req2.get_config().retry_on_connection_lost = false;
142+
req2.get_config().cancel_if_unresponded = true;
143143
req2.push("PING");
144144

145145
net::io_context ioc;
@@ -191,13 +191,13 @@ BOOST_AUTO_TEST_CASE(request_retry_true)
191191
resp3::request req2;
192192
req2.get_config().coalesce = true;
193193
req2.get_config().cancel_on_connection_lost = false;
194-
req2.get_config().retry_on_connection_lost = true;
194+
req2.get_config().cancel_if_unresponded = false;
195195
req2.push("PING");
196196

197197
resp3::request req3;
198198
req3.get_config().coalesce = true;
199199
req3.get_config().cancel_on_connection_lost = true;
200-
req3.get_config().retry_on_connection_lost = false;
200+
req3.get_config().cancel_if_unresponded = true;
201201
req3.push("QUIT");
202202

203203
net::io_context ioc;

tests/conn_exec_cancel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ auto cancel_of_req_written_on_run_canceled() -> net::awaitable<void>
136136

137137
resp3::request req1;
138138
req1.get_config().cancel_on_connection_lost = true;
139-
req1.get_config().retry_on_connection_lost = false;
139+
req1.get_config().cancel_if_unresponded = true;
140140
req1.push("BLPOP", "any", 0);
141141

142142
auto ex = co_await net::this_coro::executor;

tests/conn_reconnect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ auto async_test_reconnect_timeout() -> net::awaitable<void>
7373
resp3::request req1;
7474
req1.get_config().cancel_if_not_connected = false;
7575
req1.get_config().cancel_on_connection_lost = true;
76-
req1.get_config().retry_on_connection_lost = false;
76+
req1.get_config().cancel_if_unresponded = true;
7777
req1.push("HELLO", 3);
7878
req1.push("BLPOP", "any", 0);
7979

@@ -92,7 +92,7 @@ auto async_test_reconnect_timeout() -> net::awaitable<void>
9292
resp3::request req2;
9393
req2.get_config().cancel_if_not_connected = false;
9494
req2.get_config().cancel_on_connection_lost = true;
95-
req2.get_config().retry_on_connection_lost= false;
95+
req2.get_config().cancel_if_unresponded= true;
9696
req2.push("HELLO", 3);
9797
req2.push("QUIT");
9898

0 commit comments

Comments
 (0)