From: Yingxin Date: Wed, 7 Nov 2018 11:58:24 +0000 (+0800) Subject: crimson/net: remove recursive call to handle_connect_reply() X-Git-Tag: v14.1.0~862^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F25176%2Fhead;p=ceph.git crimson/net: remove recursive call to handle_connect_reply() Signed-off-by: Yingxin --- diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index 4e7bd572e71f..a78bd5864bbd 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -656,42 +656,42 @@ SocketConnection::handle_connect_reply(msgr_tag_t tag) // TODO: state wait throw std::system_error(make_error_code(error::negotiation_failure)); case CEPH_MSGR_TAG_SEQ: - break; case CEPH_MSGR_TAG_READY: - break; - } - if (auto missing = (policy.features_required & ~(uint64_t)h.reply.features); - missing) { - logger().error("{} missing required features", __func__); - throw std::system_error(make_error_code(error::negotiation_failure)); - } - if (tag == CEPH_MSGR_TAG_SEQ) { - return socket->read_exactly(sizeof(seq_num_t)) - .then([this] (auto buf) { - auto acked_seq = reinterpret_cast(buf.get()); - discard_up_to(&out_q, *acked_seq); - return socket->write_flush(make_static_packet(in_seq)); + if (auto missing = (policy.features_required & ~(uint64_t)h.reply.features); + missing) { + logger().error("{} missing required features", __func__); + throw std::system_error(make_error_code(error::negotiation_failure)); + } + return seastar::futurize_apply([this, tag] { + if (tag == CEPH_MSGR_TAG_SEQ) { + return socket->read_exactly(sizeof(seq_num_t)) + .then([this] (auto buf) { + auto acked_seq = reinterpret_cast(buf.get()); + discard_up_to(&out_q, *acked_seq); + return socket->write_flush(make_static_packet(in_seq)); + }); + } + // tag CEPH_MSGR_TAG_READY + return seastar::now(); }).then([this] { - return handle_connect_reply(CEPH_MSGR_TAG_READY); + // hooray! + h.peer_global_seq = h.reply.global_seq; + policy.lossy = h.reply.flags & CEPH_MSG_CONNECT_LOSSY; + h.connect_seq++; + h.backoff = 0ms; + set_features(h.reply.features & h.connect.features); + if (h.authorizer) { + session_security.reset( + get_auth_session_handler(nullptr, + h.authorizer->protocol, + h.authorizer->session_key, + features)); + } + h.authorizer.reset(); + return seastar::make_ready_future(stop_t::yes); }); - } - if (tag == CEPH_MSGR_TAG_READY) { - // hooray! - h.peer_global_seq = h.reply.global_seq; - policy.lossy = h.reply.flags & CEPH_MSG_CONNECT_LOSSY; - h.connect_seq++; - h.backoff = 0ms; - set_features(h.reply.features & h.connect.features); - if (h.authorizer) { - session_security.reset( - get_auth_session_handler(nullptr, - h.authorizer->protocol, - h.authorizer->session_key, - features)); - } - h.authorizer.reset(); - return seastar::make_ready_future(stop_t::yes); - } else { + break; + default: // unknown tag logger().error("{} got unknown tag", __func__, int(tag)); throw std::system_error(make_error_code(error::negotiation_failure));