]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: consolidate the code to initialize msgrs
authorKefu Chai <kchai@redhat.com>
Mon, 8 Apr 2019 05:48:02 +0000 (13:48 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 8 Apr 2019 07:56:58 +0000 (15:56 +0800)
no need to repeat them in difference places. we should just ready them
in main.cc where they are created.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/heartbeat.cc
src/crimson/osd/main.cc
src/crimson/osd/osd.cc

index 2ff5270e4d1af669d1717bce0e84a22f4ce3b997..a44fd7e79a8f9904f39404fbce2fe63638978102 100644 (file)
@@ -59,12 +59,6 @@ seastar::future<>
 Heartbeat::start_messenger(ceph::net::Messenger& msgr,
                            const entity_addrvec_t& addrs)
 {
-  if (local_conf()->ms_crc_data) {
-    msgr.set_crc_data();
-  }
-  if (local_conf()->ms_crc_header) {
-    msgr.set_crc_header();
-  }
   return msgr.try_bind(addrs,
                        local_conf()->ms_bind_port_min,
                        local_conf()->ms_bind_port_max).then([&msgr, this] {
index 79a932cb1e509a6716b50f0c7baff3b40dcbc273..157b123b72531192e9657b50cd2e5e511b6fd3dc 100644 (file)
@@ -101,11 +101,19 @@ int main(int argc, char* argv[])
         local_conf().parse_argv(ceph_args).get();
         const int whoami = std::stoi(local_conf()->name.get_id());
         const auto nonce = static_cast<uint32_t>(getpid());
-        const auto shard = seastar::engine().cpu_id();
-        cluster_msgr.start(entity_name_t::OSD(whoami), "cluster"s, nonce, shard).get();
-        client_msgr.start(entity_name_t::OSD(whoami), "client"s, nonce, shard).get();
-        hb_front_msgr.start(entity_name_t::OSD(whoami), "hb_front"s, nonce, shard).get();
-        hb_back_msgr.start(entity_name_t::OSD(whoami), "hb_back"s, nonce, shard).get();
+        for (auto [msgr, name] : {make_pair(std::ref(cluster_msgr), "cluster"s),
+                                  make_pair(std::ref(client_msgr), "client"s),
+                                  make_pair(std::ref(hb_front_msgr), "hb_front"s),
+                                  make_pair(std::ref(hb_back_msgr), "hb_back"s)}) {
+          const auto shard = seastar::engine().cpu_id();
+          msgr.start(entity_name_t::OSD(whoami), name, nonce, shard).get();
+          if (local_conf()->ms_crc_data) {
+            msgr.local().set_crc_data();
+          }
+          if (local_conf()->ms_crc_header) {
+            msgr.local().set_crc_header();
+          }
+        }
         osd.start_single(whoami, nonce,
           reference_wrapper<ceph::net::Messenger>(cluster_msgr.local()),
           reference_wrapper<ceph::net::Messenger>(client_msgr.local()),
index 945f0cd6dc115fd4ce8c2728a20f18cd4ea1b2eb..bfb561651f1eb5127ccc8387739939a03d430f38 100644 (file)
@@ -185,14 +185,6 @@ seastar::future<> OSD::start()
     osdmap = std::move(map);
     return load_pgs();
   }).then([this] {
-    for (auto msgr : {std::ref(cluster_msgr), std::ref(public_msgr)}) {
-      if (local_conf()->ms_crc_data) {
-        msgr.get().set_crc_data();
-      }
-      if (local_conf()->ms_crc_header) {
-        msgr.get().set_crc_header();
-      }
-    }
     dispatchers.push_front(this);
     dispatchers.push_front(monc.get());
     dispatchers.push_front(mgrc.get());