Add tcp_nodelay flag that is by default on

This commit is contained in:
Roman Gershman 2022-02-27 15:40:20 +02:00
parent d1291be0b7
commit edf74d2494
4 changed files with 13 additions and 4 deletions

2
helio

@ -1 +1 @@
Subproject commit ec055f6bb2476aaebda441cbf1fc3c738bf5a4c6 Subproject commit 1b01326ec8689e559dcf4c5be6f328055479e808

View File

@ -36,6 +36,9 @@ void RunEngine(ProactorPool* pool, AcceptServer* acceptor, HttpListener<>* http)
} // namespace dfly } // namespace dfly
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
gflags::SetUsageMessage("dragonfly [FLAGS]");
gflags::SetVersionString("v0.2");
MainInitGuard guard(&argc, &argv); MainInitGuard guard(&argc, &argv);
CHECK_GT(FLAGS_port, 0u); CHECK_GT(FLAGS_port, 0u);

View File

@ -1,4 +1,4 @@
// Copyright 2021, Roman Gershman. All rights reserved. // Copyright 2022, Roman Gershman. All rights reserved.
// See LICENSE for licensing terms. // See LICENSE for licensing terms.
// //
@ -22,6 +22,8 @@
#include "util/tls/tls_socket.h" #include "util/tls/tls_socket.h"
#include "util/uring/uring_socket.h" #include "util/uring/uring_socket.h"
DEFINE_bool(tcp_nodelay, true, "Configures dragonfly connections with socket option TCP_NODELAY");
using namespace util; using namespace util;
using namespace std; using namespace std;
using nonstd::make_unexpected; using nonstd::make_unexpected;
@ -137,9 +139,12 @@ void Connection::UnregisterShutdownHook(ShutdownHandle id) {
void Connection::HandleRequests() { void Connection::HandleRequests() {
this_fiber::properties<FiberProps>().set_name("DflyConnection"); this_fiber::properties<FiberProps>().set_name("DflyConnection");
int val = 1;
LinuxSocketBase* lsb = static_cast<LinuxSocketBase*>(socket_.get()); LinuxSocketBase* lsb = static_cast<LinuxSocketBase*>(socket_.get());
if (FLAGS_tcp_nodelay) {
int val = 1;
CHECK_EQ(0, setsockopt(lsb->native_handle(), SOL_TCP, TCP_NODELAY, &val, sizeof(val))); CHECK_EQ(0, setsockopt(lsb->native_handle(), SOL_TCP, TCP_NODELAY, &val, sizeof(val)));
}
auto remote_ep = lsb->RemoteEndpoint(); auto remote_ep = lsb->RemoteEndpoint();

View File

@ -25,6 +25,7 @@ VOLUME /data
WORKDIR /data WORKDIR /data
COPY tools/docker/entrypoint.sh /usr/local/bin/entrypoint.sh COPY tools/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY --from=builder /build/build-opt/dragonfly /usr/local/bin/ COPY --from=builder /build/build-opt/dragonfly /usr/local/bin/
RUN dragonfly -version
ENTRYPOINT ["entrypoint.sh"] ENTRYPOINT ["entrypoint.sh"]