From 67fa7260619a2a75bc5b8ed49979af748e0c42e2 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Wed, 1 Jul 2015 00:40:37 +0800 Subject: [PATCH] AsyncConnection: Move sign_message to write_message sign_message require correct connection feature which may wrong when preparing message Signed-off-by: Haomai Wang --- src/msg/async/AsyncConnection.cc | 35 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 977415011edd5..94e940c3d6876 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -2201,23 +2201,6 @@ void AsyncConnection::prepare_send_message(uint64_t features, Message *m, buffer << " data=" << header.data_len << " off " << header.data_off << dendl; - // Now that we have all the crcs calculated, handle the - // digital signature for the message, if the AsyncConnection has session - // security set up. Some session security options do not - // actually calculate and check the signature, but they should - // handle the calls to sign_message and check_signature. PLR - if (session_security.get() == NULL) { - ldout(async_msgr->cct, 20) << __func__ << " no session security" << dendl; - } else { - if (session_security->sign_message(m)) { - ldout(async_msgr->cct, 20) << __func__ << " failed to sign m=" - << m << "): sig = " << footer.sig << dendl; - } else { - ldout(async_msgr->cct, 20) << __func__ << " signed m=" << m - << "): sig = " << footer.sig << dendl; - } - } - bl.append(m->get_payload()); bl.append(m->get_middle()); bl.append(m->get_data()); @@ -2275,6 +2258,24 @@ int AsyncConnection::write_message(Message *m, bufferlist& bl) complete_bl.claim_append(bl); + // TODO: let sign_message could be reentry? + // Now that we have all the crcs calculated, handle the + // digital signature for the message, if the AsyncConnection has session + // security set up. Some session security options do not + // actually calculate and check the signature, but they should + // handle the calls to sign_message and check_signature. PLR + if (session_security.get() == NULL) { + ldout(async_msgr->cct, 20) << __func__ << " no session security" << dendl; + } else { + if (session_security->sign_message(m)) { + ldout(async_msgr->cct, 20) << __func__ << " failed to sign m=" + << m << "): sig = " << m->get_footer().sig << dendl; + } else { + ldout(async_msgr->cct, 20) << __func__ << " signed m=" << m + << "): sig = " << m->get_footer().sig << dendl; + } + } + logger->inc(l_msgr_send_bytes, bl.length()); ldout(async_msgr->cct, 20) << __func__ << " sending " << m->get_seq() << " " << m << dendl; -- 2.39.5