| 558 | } |
| 559 | |
| 560 | bool DaemonServer::handle_open(const ref_t<MMgrOpen>& m) |
| 561 | { |
| 562 | std::unique_lock l(lock); |
| 563 | |
| 564 | DaemonKey key = key_from_service(m->service_name, |
| 565 | m->get_connection()->get_peer_type(), |
| 566 | m->daemon_name); |
| 567 | |
| 568 | auto con = m->get_connection(); |
| 569 | dout(10) << "from " << key << " " << con->get_peer_addr() << dendl; |
| 570 | |
| 571 | _send_configure(con); |
| 572 | |
| 573 | DaemonStatePtr daemon; |
| 574 | if (daemon_state.exists(key)) { |
| 575 | dout(20) << "updating existing DaemonState for " << key << dendl; |
| 576 | daemon = daemon_state.get(key); |
| 577 | } |
| 578 | if (!daemon) { |
| 579 | if (m->service_daemon) { |
| 580 | dout(4) << "constructing new DaemonState for " << key << dendl; |
| 581 | daemon = std::make_shared<DaemonState>(daemon_state.types); |
| 582 | daemon->key = key; |
| 583 | daemon->service_daemon = true; |
| 584 | daemon_state.insert(daemon); |
| 585 | } else { |
| 586 | /* A normal Ceph daemon has connected but we are or should be waiting on |
| 587 | * metadata for it. Close the session so that it tries to reconnect. |
| 588 | */ |
| 589 | dout(2) << "ignoring open from " << key << " " << con->get_peer_addr() |
| 590 | << "; not ready for session (expect reconnect)" << dendl; |
| 591 | con->mark_down(); |
| 592 | l.unlock(); |
| 593 | fetch_missing_metadata(key, m->get_source_addr()); |
| 594 | return true; |
| 595 | } |
| 596 | } |
| 597 | if (daemon) { |
| 598 | if (m->service_daemon) { |
| 599 | // update the metadata through the daemon state index to |
| 600 | // ensure it's kept up-to-date |
| 601 | daemon_state.update_metadata(daemon, m->daemon_metadata); |
| 602 | } |
| 603 | |
| 604 | std::lock_guard l(daemon->lock); |
| 605 | daemon->perf_counters.clear(); |
| 606 | |
| 607 | daemon->service_daemon = m->service_daemon; |
| 608 | if (m->service_daemon) { |
| 609 | daemon->service_status = m->daemon_status; |
| 610 | |
| 611 | utime_t now = ceph_clock_now(); |
| 612 | auto [d, added] = pending_service_map.get_daemon(m->service_name, |
| 613 | m->daemon_name); |
| 614 | if (added || d->gid != (uint64_t)m->get_source().num()) { |
| 615 | dout(10) << "registering " << key << " in pending_service_map" << dendl; |
| 616 | d->gid = m->get_source().num(); |
| 617 | d->addr = m->get_source_addr(); |
nothing calls this directly
no test coverage detected