From b34c81bfdef9420616412cfead64a73a60327296 Mon Sep 17 00:00:00 2001 From: ofriedma <48631098+ofriedma@users.noreply.github.com> Date: Sat, 16 Mar 2019 21:38:08 +0200 Subject: [PATCH] rgw: Adding tcp_nodelay option to Beast 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 (cherry picked from commit fb1bff7bce9937e832cff12b50ebb8d43b1d2bd4) Conflicts: src/rgw/rgw_asio_frontend.cc : Resolved for parse_endpoint --- doc/radosgw/frontends.rst | 13 +++++++++++++ src/rgw/rgw_asio_frontend.cc | 13 +++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/radosgw/frontends.rst b/doc/radosgw/frontends.rst index 7c0b2cced830..1bcbe2eda696 100644 --- a/doc/radosgw/frontends.rst +++ b/doc/radosgw/frontends.rst @@ -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 ======== diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index e974ae7bf8e0..fc331e218777 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -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,6 @@ unsigned short parse_port(const char *input, boost::system::error_code& ec) } return port; } - tcp::endpoint parse_endpoint(BOOST_ASIO_STRING_VIEW_PARAM input, unsigned short default_port, boost::system::error_code& ec) @@ -358,7 +358,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 +483,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); -- 2.47.3