]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
AsyncConnection: Move sign_message to write_message 5107/head
authorHaomai Wang <haomaiwang@gmail.com>
Tue, 30 Jun 2015 16:40:37 +0000 (00:40 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Tue, 30 Jun 2015 16:58:34 +0000 (00:58 +0800)
sign_message require correct connection feature which may wrong when preparing
message

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/msg/async/AsyncConnection.cc

index 977415011edd59a36bee72d5731f26af5281364d..94e940c3d6876bdde713259957e357614c3179e0 100644 (file)
@@ -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;