From: Kefu Chai Date: Mon, 8 Apr 2019 05:48:02 +0000 (+0800) Subject: crimson/osd: consolidate the code to initialize msgrs X-Git-Tag: v15.1.0~2988^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=18ac3767dab9acccb0e3b7f7e72c700ee0b7e259;p=ceph-ci.git crimson/osd: consolidate the code to initialize msgrs 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 --- diff --git a/src/crimson/osd/heartbeat.cc b/src/crimson/osd/heartbeat.cc index 2ff5270e4d1..a44fd7e79a8 100644 --- a/src/crimson/osd/heartbeat.cc +++ b/src/crimson/osd/heartbeat.cc @@ -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] { diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index 79a932cb1e5..157b123b725 100644 --- a/src/crimson/osd/main.cc +++ b/src/crimson/osd/main.cc @@ -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(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(cluster_msgr.local()), reference_wrapper(client_msgr.local()), diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 945f0cd6dc1..bfb561651f1 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -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());