]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async: clean up code. 30883/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Tue, 15 Oct 2019 05:16:22 +0000 (13:16 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 15 Oct 2019 05:16:22 +0000 (13:16 +0800)
Currently, function submit_message only used by send_to, so conbine
them to one.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/msg/async/AsyncMessenger.cc
src/msg/async/AsyncMessenger.h

index 37c7182f61d4b6e9d34c9e0180bd59ee7f411e2e..d761a540858f6618ad891b5cf4dae8299c35436b 100644 (file)
@@ -639,8 +639,6 @@ entity_addrvec_t AsyncMessenger::_filter_addrs(const entity_addrvec_t& addrs)
 
 int AsyncMessenger::send_to(Message *m, int type, const entity_addrvec_t& addrs)
 {
-  std::lock_guard l{lock};
-
   FUNCTRACE(cct);
   ceph_assert(m);
 
@@ -662,9 +660,19 @@ int AsyncMessenger::send_to(Message *m, int type, const entity_addrvec_t& addrs)
     return -EINVAL;
   }
 
-  auto av = _filter_addrs(addrs);
-  const AsyncConnectionRef& conn = _lookup_conn(av);
-  submit_message(m, conn, av, type);
+  if (cct->_conf->ms_dump_on_send) {
+    m->encode(-1, MSG_CRC_ALL);
+    ldout(cct, 0) << __func__ << " submit_message " << *m << "\n";
+    m->get_payload().hexdump(*_dout);
+    if (m->get_data().length() > 0) {
+      *_dout << " data:\n";
+      m->get_data().hexdump(*_dout);
+    }
+    *_dout << dendl;
+    m->clear_payload();
+  }
+
+  connect_to(type, addrs, false)->send_message(m);
   return 0;
 }
 
@@ -697,52 +705,6 @@ ConnectionRef AsyncMessenger::connect_to(int type,
   return conn;
 }
 
-void AsyncMessenger::submit_message(Message *m, const AsyncConnectionRef& con,
-                                    const entity_addrvec_t& dest_addrs,
-                                   int dest_type)
-{
-  if (cct->_conf->ms_dump_on_send) {
-    m->encode(-1, MSG_CRC_ALL);
-    ldout(cct, 0) << __func__ << " submit_message " << *m << "\n";
-    m->get_payload().hexdump(*_dout);
-    if (m->get_data().length() > 0) {
-      *_dout << " data:\n";
-      m->get_data().hexdump(*_dout);
-    }
-    *_dout << dendl;
-    m->clear_payload();
-  }
-
-  // existing connection?
-  if (con) {
-    con->send_message(m);
-    return ;
-  }
-
-  // local?
-  if (*my_addrs == dest_addrs ||
-      (dest_addrs.v.size() == 1 &&
-       my_addrs->contains(dest_addrs.front()))) {
-    // local
-    local_connection->send_message(m);
-    return ;
-  }
-
-  // remote, no existing connection.
-  const Policy& policy = get_policy(dest_type);
-  if (policy.server) {
-    ldout(cct, 20) << __func__ << " " << *m << " remote, " << dest_addrs
-        << ", lossy server for target type "
-        << ceph_entity_type_name(dest_type) << ", no session, dropping." << dendl;
-    m->put();
-  } else {
-    ldout(cct,20) << __func__ << " " << *m << " remote, " << dest_addrs
-                 << ", new connection." << dendl;
-    auto&& new_con = create_connect(dest_addrs, dest_type, false);
-    new_con->send_message(m);
-  }
-}
-
 /**
  * If my_addr doesn't have an IP set, this function
  * will fill it in from the passed addr. Otherwise it does nothing and returns.
index 71b5d8ba9ba51d555d401b8538fed2a6c35da155..76e20dcc356948dde23658ac1ecbc79365337857 100644 (file)
@@ -200,20 +200,6 @@ private:
   AsyncConnectionRef create_connect(const entity_addrvec_t& addrs, int type,
                                    bool anon);
 
-  /**
-   * Queue up a Message for delivery to the entity specified
-   * by addr and dest_type.
-   * submit_message() is responsible for creating
-   * new AsyncConnection (and closing old ones) as necessary.
-   *
-   * @param m The Message to queue up. This function eats a reference.
-   * @param con The existing Connection to use, or NULL if you don't know of one.
-   * @param dest_addr The address to send the Message to.
-   * @param dest_type The peer type of the address we're sending to
-   * just drop silently under failure.
-   */
-  void submit_message(Message *m, const AsyncConnectionRef& con,
-                      const entity_addrvec_t& dest_addrs, int dest_type);
 
   void _finish_bind(const entity_addrvec_t& bind_addrs,
                    const entity_addrvec_t& listen_addrs);