From: Amnon Hanuhov Date: Thu, 3 Jun 2021 13:57:41 +0000 (+0300) Subject: crimson/net: Use out_q instead of pending_q X-Git-Tag: v17.1.0~1746^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a59c0a9296142cc7f30af23030c8bea85b5940f9;p=ceph.git crimson/net: Use out_q instead of pending_q pending_q contains the same messages as in out_q and it is only used for creating a bytestream out of these messages. We can just use out_q for that. Signed-off-by: Amnon Hanuhov --- diff --git a/src/crimson/net/Protocol.cc b/src/crimson/net/Protocol.cc index 50b5c45a335f..75a60b329857 100644 --- a/src/crimson/net/Protocol.cc +++ b/src/crimson/net/Protocol.cc @@ -90,6 +90,26 @@ void Protocol::close(bool dispatch_reset, }); } +ceph::bufferlist Protocol::sweep_messages_and_move_to_sent( + size_t num_msgs, + bool require_keepalive, + std::optional keepalive_ack, + bool require_ack) +{ + ceph::bufferlist bl = do_sweep_messages(conn.out_q, + num_msgs, + require_keepalive, + keepalive_ack, + require_ack); + if (!conn.policy.lossy) { + conn.sent.insert(conn.sent.end(), + conn.out_q.begin(), + conn.out_q.end()); + } + conn.out_q.clear(); + return bl; +} + seastar::future<> Protocol::send(MessageRef msg) { if (write_state != write_state_t::drop) { @@ -222,18 +242,11 @@ seastar::future<> Protocol::do_write_dispatch_sweep() if (unlikely(!still_queued)) { return try_exit_sweep(); } - conn.pending_q.clear(); - conn.pending_q.swap(conn.out_q); - if (!conn.policy.lossy) { - conn.sent.insert(conn.sent.end(), - conn.pending_q.begin(), - conn.pending_q.end()); - } auto acked = ack_left; assert(acked == 0 || conn.in_seq > 0); // sweep all pending writes with the concrete Protocol - return socket->write(do_sweep_messages( - conn.pending_q, num_msgs, need_keepalive, keepalive_ack, acked > 0) + return socket->write(sweep_messages_and_move_to_sent( + num_msgs, need_keepalive, keepalive_ack, acked > 0) ).then([this, prv_keepalive_ack=keepalive_ack, acked] { need_keepalive = false; if (keepalive_ack == prv_keepalive_ack) { diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index dc4e4f2af8f3..ce88629ba6c2 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -65,6 +65,13 @@ class Protocol { virtual void notify_write() {}; virtual void on_closed() {} + + private: + ceph::bufferlist sweep_messages_and_move_to_sent( + size_t num_msgs, + bool require_keepalive, + std::optional keepalive_ack, + bool require_ack); public: const proto_t proto_type; diff --git a/src/crimson/net/SocketConnection.h b/src/crimson/net/SocketConnection.h index 28a2491895e4..068d8886ac4f 100644 --- a/src/crimson/net/SocketConnection.h +++ b/src/crimson/net/SocketConnection.h @@ -45,7 +45,6 @@ class SocketConnection : public Connection { // messages to be resent after connection gets reset std::deque out_q; - std::deque pending_q; // messages sent, but not yet acked by peer std::deque sent;