]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/mon: keep a copy of sent MMonCommand messages 39798/head
authorKefu Chai <kchai@redhat.com>
Wed, 3 Mar 2021 03:39:36 +0000 (11:39 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Mar 2021 03:41:38 +0000 (11:41 +0800)
as per Yingxin Cheng,

> The send process can be asynchronous (there is a conn.out_q, or if the
> underlying socket lives in a different core in the m:n model to be
> ordered there). If user really wants to reuse a message, they must be
> careful not to modify it because it may result in modifing the pending
> messages.
>
> I think the best way is to copy the message if user want to resend it,
> and keep the ceph_assert(!msg->get_seq()). It may looks good to reuse a
> message under lossy policy, but the correctness is now up to user not to
> modify it inplace.

see also https://github.com/ceph/ceph/pull/39786

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/mon/MonClient.cc

index 7baa3b34f1fc77c1c9f8ea8ed171da8e6303148e..5b68ab8da7de83c366b6ff2676ac40c79fbca186 100644 (file)
@@ -1010,9 +1010,8 @@ Client::run_command(std::string&& cmd,
   m->set_tid(tid);
   m->cmd = {std::move(cmd)};
   m->set_data(std::move(bl));
-  mon_commands.emplace_back(m);
-  auto& command = mon_commands.back();
-  return send_message(command.req).then([&result=command.result] {
+  auto& command = mon_commands.emplace_back(make_message<MMonCommand>(*m));
+  return send_message(std::move(m)).then([&result=command.result] {
     return result.get_future();
   });
 }
@@ -1042,7 +1041,7 @@ seastar::future<> Client::on_session_opened()
   }).then([this] {
     return seastar::parallel_for_each(mon_commands,
       [this](auto &command) {
-      return send_message(command.req);
+      return send_message(make_message<MMonCommand>(*command.req));
     });
   });
 }