| 290 | : m_msgrs{{name, &m}} {} |
| 291 | |
| 292 | int AsyncMessengerSocketHook::call( |
| 293 | std::string_view command, const cmdmap_t& cmdmap, const bufferlist&, |
| 294 | Formatter* f, std::ostream& errss, ceph::buffer::list& out) { |
| 295 | if (command == "messenger dump") { |
| 296 | std::string name; |
| 297 | if (common::cmd_getval(cmdmap, "msgr", name)) { |
| 298 | if (auto it = m_msgrs.find(name); it != m_msgrs.end()) { |
| 299 | std::vector<std::string> opts; |
| 300 | const bool tcp_info = |
| 301 | common::cmd_getval_or<bool>(cmdmap, "tcp_info", false); |
| 302 | const bool has_filter = |
| 303 | common::cmd_getval(cmdmap, "dumpcontents", opts); |
| 304 | const std::set<std::string> optset(opts.begin(), opts.end()); |
| 305 | const bool all = !has_filter || optset.contains("all"); |
| 306 | const auto filter_fn = [&](const std::string& key) { |
| 307 | if (key == "tcp_info") { |
| 308 | return tcp_info; |
| 309 | } else if (all) { |
| 310 | return true; |
| 311 | } else { |
| 312 | return optset.contains(key); |
| 313 | } |
| 314 | }; |
| 315 | |
| 316 | const auto msgr = (*it).second; |
| 317 | f->open_object_section("status"); |
| 318 | f->dump_string("name", name); |
| 319 | f->open_object_section("messenger"); |
| 320 | msgr->dump(f, filter_fn); |
| 321 | f->close_section(); // messenger |
| 322 | f->close_section(); // status |
| 323 | return 0; |
| 324 | } else { |
| 325 | return -ENOENT; |
| 326 | } |
| 327 | } else { |
| 328 | f->open_object_section("status"); |
| 329 | f->open_array_section("messengers"); |
| 330 | for (const auto& [name, _] : m_msgrs) { |
| 331 | f->dump_string("name", name); |
| 332 | } |
| 333 | f->close_section(); |
| 334 | f->close_section(); |
| 335 | return 0; |
| 336 | } |
| 337 | } |
| 338 | return -ENOSYS; |
| 339 | } |
| 340 | |
| 341 | bool AsyncMessengerSocketHook::add_messenger( |
| 342 | const std::string& name, AsyncMessenger& msgr) { |
nothing calls this directly
no test coverage detected