]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: move implementation into .cc file 37010/head
authorKefu Chai <kchai@redhat.com>
Sun, 6 Sep 2020 10:32:44 +0000 (18:32 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 6 Sep 2020 10:33:34 +0000 (18:33 +0800)
for faster compilation.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/net/Socket.cc
src/crimson/net/Socket.h

index 1aabd4ced422451e2b66436ca8c09e9afe7671d2..5fa41e646bc6fabf4df88633e5455bc0c2c71f10 100644 (file)
@@ -196,4 +196,70 @@ void Socket::set_trap(bp_type_t type, bp_action_t action, socket_blocker* blocke
 }
 #endif
 
+seastar::future<> FixedCPUServerSocket::listen(entity_addr_t addr)
+{
+  assert(seastar::this_shard_id() == cpu);
+  logger().trace("FixedCPUServerSocket::listen({})...", addr);
+  return container().invoke_on_all([addr] (auto& ss) {
+    ss.addr = addr;
+    seastar::socket_address s_addr(addr.in4_addr());
+    seastar::listen_options lo;
+    lo.reuse_address = true;
+    lo.set_fixed_cpu(ss.cpu);
+    ss.listener = seastar::listen(s_addr, lo);
+  }).handle_exception_type([addr] (const std::system_error& e) {
+    if (e.code() == std::errc::address_in_use) {
+      logger().trace("FixedCPUServerSocket::listen({}): address in use", addr);
+      throw;
+    } else {
+      logger().error("FixedCPUServerSocket::listen({}): "
+                     "got unexpeted error {}", addr, e);
+      ceph_abort();
+    }
+  });
+}
+
+seastar::future<> FixedCPUServerSocket::shutdown()
+{
+  assert(seastar::this_shard_id() == cpu);
+  logger().trace("FixedCPUServerSocket({})::shutdown()...", addr);
+  return container().invoke_on_all([] (auto& ss) {
+    if (ss.listener) {
+      ss.listener->abort_accept();
+    }
+    return ss.shutdown_gate.close();
+  }).then([this] {
+    return reset();
+  });
+}
+
+seastar::future<> FixedCPUServerSocket::destroy()
+{
+  assert(seastar::this_shard_id() == cpu);
+  return shutdown().then([this] {
+    // we should only construct/stop shards on #0
+    return container().invoke_on(0, [] (auto& ss) {
+      assert(ss.service);
+      return ss.service->stop().finally([cleanup = std::move(ss.service)] {});
+    });
+  });
+}
+
+seastar::future<FixedCPUServerSocket*> FixedCPUServerSocket::create()
+{
+  auto cpu = seastar::this_shard_id();
+  // we should only construct/stop shards on #0
+  return seastar::smp::submit_to(0, [cpu] {
+    auto service = std::make_unique<sharded_service_t>();
+    return service->start(cpu, construct_tag{}
+    ).then([service = std::move(service)] () mutable {
+      auto p_shard = service.get();
+      p_shard->local().service = std::move(service);
+      return p_shard;
+    });
+  }).then([] (auto p_shard) {
+    return &p_shard->local();
+  });
+}
+
 } // namespace crimson::net
index f3d8bd8b6d719745be8d858d006e741020a108d1..8b05a884896ef1cc770e3ae422e907ff596574f8 100644 (file)
@@ -197,27 +197,7 @@ public:
   FixedCPUServerSocket(const FixedCPUServerSocket&) = delete;
   FixedCPUServerSocket& operator=(const FixedCPUServerSocket&) = delete;
 
-  seastar::future<> listen(entity_addr_t addr) {
-    assert(seastar::this_shard_id() == cpu);
-    logger().trace("FixedCPUServerSocket::listen({})...", addr);
-    return container().invoke_on_all([addr] (auto& ss) {
-      ss.addr = addr;
-      seastar::socket_address s_addr(addr.in4_addr());
-      seastar::listen_options lo;
-      lo.reuse_address = true;
-      lo.set_fixed_cpu(ss.cpu);
-      ss.listener = seastar::listen(s_addr, lo);
-    }).handle_exception_type([addr] (const std::system_error& e) {
-      if (e.code() == std::errc::address_in_use) {
-        logger().trace("FixedCPUServerSocket::listen({}): address in use", addr);
-        throw;
-      } else {
-        logger().error("FixedCPUServerSocket::listen({}): "
-                       "got unexpeted error {}", addr, e);
-        ceph_abort();
-      }
-    });
-  }
+  seastar::future<> listen(entity_addr_t addr);
 
   // fn_accept should be a nothrow function of type
   // seastar::future<>(SocketRef, entity_addr_t)
@@ -277,45 +257,9 @@ public:
     });
   }
 
-  seastar::future<> shutdown() {
-    assert(seastar::this_shard_id() == cpu);
-    logger().trace("FixedCPUServerSocket({})::shutdown()...", addr);
-    return container().invoke_on_all([] (auto& ss) {
-      if (ss.listener) {
-        ss.listener->abort_accept();
-      }
-      return ss.shutdown_gate.close();
-    }).then([this] {
-      return reset();
-    });
-  }
-
-  seastar::future<> destroy() {
-    assert(seastar::this_shard_id() == cpu);
-    return shutdown().then([this] {
-      // we should only construct/stop shards on #0
-      return container().invoke_on(0, [] (auto& ss) {
-        assert(ss.service);
-        return ss.service->stop().finally([cleanup = std::move(ss.service)] {});
-      });
-    });
-  }
-
-  static seastar::future<FixedCPUServerSocket*> create() {
-    auto cpu = seastar::this_shard_id();
-    // we should only construct/stop shards on #0
-    return seastar::smp::submit_to(0, [cpu] {
-      auto service = std::make_unique<sharded_service_t>();
-      return service->start(cpu, construct_tag{}
-      ).then([service = std::move(service)] () mutable {
-        auto p_shard = service.get();
-        p_shard->local().service = std::move(service);
-        return p_shard;
-      });
-    }).then([] (auto p_shard) {
-      return &p_shard->local();
-    });
-  }
+  seastar::future<> shutdown();
+  seastar::future<> destroy();
+  static seastar::future<FixedCPUServerSocket*> create();
 };
 
 } // namespace crimson::net