]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Adding tcp_nodelay option to Beast 27367/head
authorofriedma <48631098+ofriedma@users.noreply.github.com>
Sat, 16 Mar 2019 19:38:08 +0000 (21:38 +0200)
committerPrashant D <pdhange@redhat.com>
Thu, 4 Apr 2019 01:34:31 +0000 (21:34 -0400)
beast frontend option to set the TCP_NODELAY socket option to match the tcp_nodelay option in civetweb.

Fixes: https://tracker.ceph.com/issues/34308
Signed-off-by: Or Friedmann <ofriedma@redhat.com>
(cherry picked from commit fb1bff7bce9937e832cff12b50ebb8d43b1d2bd4)

doc/radosgw/frontends.rst
src/rgw/rgw_asio_frontend.cc

index a33a42392f3627a60aaca659349a40212d28b38c..ce58c6ee2c9b594ec87b10416f09de7672bb8fd5 100644 (file)
@@ -57,6 +57,19 @@ Options
 :Type: String
 :Default: None
 
+``tcp_nodelay``
+
+:Description: If set the socket option will disable Nagle's algorithm on 
+              the connection which means that packets will be sent as soon 
+              as possible instead of waiting for a full buffer or timeout to occur.
+
+              ``1`` Disable Nagel's algorithm for all sockets.
+
+              ``0`` Keep the default: Nagel's algorithm enabled.
+
+:Type: Integer (0 or 1)
+:Default: 0
+
 
 Civetweb
 ========
index 3c6ae446990eed00b52469ea6d3e1f457c44508e..684940b00924ecf6f0dd9ad98f4b33a2c3b7bfb4 100644 (file)
@@ -218,6 +218,7 @@ class AsioFrontend {
     tcp::acceptor acceptor;
     tcp::socket socket;
     bool use_ssl = false;
+    bool use_nodelay = false;
 
     Listener(boost::asio::io_service& service)
       : acceptor(service), socket(service) {}
@@ -255,7 +256,7 @@ unsigned short parse_port(const char *input, boost::system::error_code& ec)
   }
   return port;
 }
-
+       
 tcp::endpoint parse_endpoint(boost::asio::string_view input,
                              unsigned short default_port,
                              boost::system::error_code& ec)
@@ -358,7 +359,14 @@ int AsioFrontend::init()
     listeners.emplace_back(service);
     listeners.back().endpoint = endpoint;
   }
-
+  // parse tcp nodelay
+  auto nodelay = config.find("tcp_nodelay");
+  if (nodelay != config.end()) {
+    for (auto& l : listeners) {
+      l.use_nodelay = (nodelay->second == "1");
+    }
+  }
+  
   // start listeners
   for (auto& l : listeners) {
     l.acceptor.open(l.endpoint.protocol(), ec);
@@ -476,6 +484,8 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec)
     throw ec;
   }
   auto socket = std::move(l.socket);
+  tcp::no_delay options(l.use_nodelay);
+  socket.set_option(options,ec);
   l.acceptor.async_accept(l.socket,
                           [this, &l] (boost::system::error_code ec) {
                             accept(l, ec);