mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
Improvements in the writer cancellation.
This commit is contained in:
@@ -370,6 +370,11 @@ private:
|
||||
{
|
||||
write_buffer_ += ri.get_request().payload();
|
||||
cmds_ += ri.get_request().size();
|
||||
|
||||
// TODO: We mark a request a written only after a successful
|
||||
// write on the socket and not before writting. Otherwise, if
|
||||
// the write fails they will be seen as written and may be
|
||||
// removed with cancel(run).
|
||||
ri.mark_written();
|
||||
}
|
||||
|
||||
|
||||
@@ -498,6 +498,7 @@ struct writer_op {
|
||||
yield
|
||||
boost::asio::async_write(conn->next_layer(), boost::asio::buffer(conn->write_buffer_), std::move(self));
|
||||
if (ec) {
|
||||
conn->cancel(operation::run);
|
||||
self.complete(ec);
|
||||
return;
|
||||
}
|
||||
@@ -509,21 +510,8 @@ struct writer_op {
|
||||
conn->cancel_push_requests();
|
||||
}
|
||||
|
||||
if (conn->is_open()) {
|
||||
yield
|
||||
conn->writer_timer_.async_wait(std::move(self));
|
||||
if (ec != boost::asio::error::operation_aborted) {
|
||||
conn->cancel(operation::run);
|
||||
self.complete(ec);
|
||||
return;
|
||||
}
|
||||
// The timer may be canceled either to stop the write op
|
||||
// or to proceed to the next write, the difference between
|
||||
// the two is that for the former the socket will be
|
||||
// closed first. We check for that below.
|
||||
}
|
||||
|
||||
if (!conn->is_open()) {
|
||||
yield conn->writer_timer_.async_wait(std::move(self));
|
||||
if (self.get_cancellation_state().cancelled() != boost::asio::cancellation_type_t::none) {
|
||||
// Notice this is not an error of the op, stoping was
|
||||
// requested from the outside, so we complete with
|
||||
// success.
|
||||
|
||||
Reference in New Issue
Block a user