]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/seastar/demos/tcp_demo.cc
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / demos / tcp_demo.cc
index fd14a33b8303df128de1a4db5c5680272575d543..c93f4cee9049c829970f3b35652594e890d67c6a 100644 (file)
@@ -22,6 +22,7 @@
 #include <seastar/net/ip.hh>
 #include <seastar/net/virtio.hh>
 #include <seastar/net/tcp.hh>
+#include <fmt/printf.h>
 
 using namespace seastar;
 using namespace net;
@@ -34,21 +35,23 @@ struct tcp_test {
         tcp::connection tcp_conn;
         explicit connection(tcp::connection tc) : tcp_conn(std::move(tc)) {}
         void run() {
-            tcp_conn.wait_for_data().then([this] {
+            // Read packets and echo back in the background.
+            (void)tcp_conn.wait_for_data().then([this] {
                 auto p = tcp_conn.read();
                 if (!p.len()) {
                     tcp_conn.close_write();
                     return;
                 }
                 fmt::print("read {:d} bytes\n", p.len());
-                tcp_conn.send(std::move(p));
+                (void)tcp_conn.send(std::move(p));
                 run();
             });
         }
     };
     tcp_test(ipv4& inet) : inet(inet), _listener(inet.get_tcp().listen(10000)) {}
     void run() {
-        _listener.accept().then([this] (tcp::connection conn) {
+        // Run all connections in the background.
+        (void)_listener.accept().then([this] (tcp::connection conn) {
             (new connection(std::move(conn)))->run();
             run();
         });
@@ -64,7 +67,7 @@ int main(int ac, char** av) {
     ipv4 inet(&netif);
     inet.set_host_address(ipv4_address("192.168.122.2"));
     tcp_test tt(inet);
-    engine().when_started().then([&tt] { tt.run(); });
+    (void)engine().when_started().then([&tt] { tt.run(); });
     engine().run();
 }