From 623f61e63e7b5129b657cb01f754bd69dd6db3fb Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Fri, 24 Jul 2020 21:53:05 +0300 Subject: [PATCH] messaging_service: Unglobal messaging service instance Remove the global messaging_service, keep it on the main stack. But also store a pointer on it in debug namespace for debugging. Signed-off-by: Pavel Emelyanov --- main.cc | 10 +++++++--- message/messaging_service.hh | 10 ---------- message/messaging_service_fwd.hh | 2 -- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/main.cc b/main.cc index a59668fbe4..fe5d45762e 100644 --- a/main.cc +++ b/main.cc @@ -418,6 +418,10 @@ static auto defer_verbose_shutdown(const char* what, Func&& func) { return ::make_shared(std::move(ret)); } +namespace debug { +sharded* the_messaging_service; +} + int main(int ac, char** av) { // Allow core dumps. The would be disabled by default if // CAP_SYS_NICE was added to the binary, as is suggested by the @@ -495,6 +499,7 @@ int main(int ac, char** av) { utils::directories dirs; sharded feature_service; sharded snapshot_ctl; + sharded messaging; return app.run(ac, av, [&] () -> future { @@ -523,7 +528,7 @@ int main(int ac, char** av) { return seastar::async([cfg, ext, &db, &qp, &proxy, &mm, &mm_notifier, &ctx, &opts, &dirs, &prometheus_server, &cf_cache_hitrate_calculator, &load_meter, &feature_service, - &token_metadata, &snapshot_ctl] { + &token_metadata, &snapshot_ctl, &messaging] { try { ::stop_signal stop_signal; // we can move this earlier to support SIGINT during initialization read_config(opts, *cfg).get(); @@ -778,8 +783,7 @@ int main(int ac, char** av) { scfg.streaming = dbcfg.streaming_scheduling_group; scfg.gossip = scheduling_group(); - sharded& messaging = netw::get_messaging_service(); - + debug::the_messaging_service = &messaging; netw::init_messaging_service(messaging, std::move(mscfg), std::move(scfg), trust_store, cert, key, prio, clauth); auto stop_ms = defer_verbose_shutdown("messaging service", [&messaging] { netw::uninit_messaging_service(messaging).get(); diff --git a/message/messaging_service.hh b/message/messaging_service.hh index 7ea770434d..ee3c9f5a19 100644 --- a/message/messaging_service.hh +++ b/message/messaging_service.hh @@ -561,16 +561,6 @@ public: unsigned get_rpc_client_idx(messaging_verb verb) const; }; -extern distributed _the_messaging_service; - -inline distributed& get_messaging_service() { - return _the_messaging_service; -} - -inline messaging_service& get_local_messaging_service() { - return _the_messaging_service.local(); -} - void init_messaging_service(sharded& ms, messaging_service::config cfg, messaging_service::scheduling_config scheduling_config, sstring ms_trust_store, sstring ms_cert, sstring ms_key, sstring ms_tls_prio, bool ms_client_auth); diff --git a/message/messaging_service_fwd.hh b/message/messaging_service_fwd.hh index 40938ad1b0..c42bfc3a42 100644 --- a/message/messaging_service_fwd.hh +++ b/message/messaging_service_fwd.hh @@ -27,6 +27,4 @@ struct msg_addr; enum class messaging_verb; class messaging_service; -messaging_service& get_local_messaging_service(); - }