| 432 | } |
| 433 | |
| 434 | void ProtocolV2::send_message(Message *m) { |
| 435 | uint64_t f = connection->get_features(); |
| 436 | |
| 437 | // TODO: Currently not all messages supports reencode like MOSDMap, so here |
| 438 | // only let fast dispatch support messages prepare message |
| 439 | const bool can_fast_prepare = messenger->ms_can_fast_dispatch(m); |
| 440 | bool is_prepared; |
| 441 | if (can_fast_prepare && f) { |
| 442 | prepare_send_message(f, m); |
| 443 | is_prepared = can_fast_prepare; |
| 444 | } else { |
| 445 | is_prepared = false; |
| 446 | } |
| 447 | |
| 448 | std::lock_guard<std::mutex> l(connection->write_lock); |
| 449 | // "features" changes will change the payload encoding |
| 450 | if (can_fast_prepare && (!can_write || connection->get_features() != f)) { |
| 451 | // ensure the correctness of message encoding |
| 452 | m->clear_payload(); |
| 453 | is_prepared = false; |
| 454 | ldout(cct, 10) << __func__ << " clear encoded buffer previous " << f |
| 455 | << " != " << connection->get_features() << dendl; |
| 456 | } |
| 457 | if (state == CLOSED) { |
| 458 | ldout(cct, 10) << __func__ << " connection closed." |
| 459 | << " Drop message " << m << dendl; |
| 460 | m->put(); |
| 461 | } else { |
| 462 | ldout(cct, 5) << __func__ << " enqueueing message m=" << m |
| 463 | << " type=" << m->get_type() << " " << *m << dendl; |
| 464 | m->queue_start = ceph::mono_clock::now(); |
| 465 | m->trace.event("async enqueueing message"); |
| 466 | out_queue[m->get_priority()].emplace_back( |
| 467 | out_queue_entry_t{is_prepared, m}); |
| 468 | ldout(cct, 15) << __func__ << " message queued for async transmission m=" << m |
| 469 | << dendl; |
| 470 | if (((!replacing && can_write) || state == STANDBY) && !write_in_progress) { |
| 471 | write_in_progress = true; |
| 472 | connection->center->dispatch_event_external(connection->write_handler); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | void ProtocolV2::send_keepalive() { |
| 478 | ldout(cct, 10) << __func__ << dendl; |
no test coverage detected