From a71eeda4697dc3188ddac1206b22284b4ff6ce93 Mon Sep 17 00:00:00 2001 From: Mike Jagdis Date: Mon, 29 Apr 2024 11:32:59 +0100 Subject: [PATCH 1/3] Set TCP_NODELAY on connections Signed-off-by: Mike Jagdis --- src/Globals.h | 1 + src/OSSupport/ServerHandleImpl.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/Globals.h b/src/Globals.h index 0b6ff8ac59..7c2af3d119 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -98,6 +98,7 @@ #include #include + #include #include #include #endif diff --git a/src/OSSupport/ServerHandleImpl.cpp b/src/OSSupport/ServerHandleImpl.cpp index e68f827575..bb26d3b2ad 100644 --- a/src/OSSupport/ServerHandleImpl.cpp +++ b/src/OSSupport/ServerHandleImpl.cpp @@ -328,6 +328,9 @@ void cServerHandleImpl::Callback(evconnlistener * a_Listener, evutil_socket_t a_ return; } + const int one = 1; + setsockopt(a_Socket, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); + // Create a new cTCPLink for the incoming connection: cTCPLinkImplPtr Link = std::make_shared(a_Socket, LinkCallbacks, Self->m_SelfPtr, a_Addr, static_cast(a_Len)); { From 4db2ef50612ce1e22e5543c7d0ce87359e2bf421 Mon Sep 17 00:00:00 2001 From: Mike Jagdis Date: Mon, 29 Apr 2024 12:37:37 +0100 Subject: [PATCH 2/3] Windows wants a char * not a void * :-( Signed-off-by: Mike Jagdis --- src/OSSupport/ServerHandleImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OSSupport/ServerHandleImpl.cpp b/src/OSSupport/ServerHandleImpl.cpp index bb26d3b2ad..e498b53164 100644 --- a/src/OSSupport/ServerHandleImpl.cpp +++ b/src/OSSupport/ServerHandleImpl.cpp @@ -329,7 +329,7 @@ void cServerHandleImpl::Callback(evconnlistener * a_Listener, evutil_socket_t a_ } const int one = 1; - setsockopt(a_Socket, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); + setsockopt(a_Socket, IPPROTO_TCP, TCP_NODELAY, (const char *)&one, sizeof(one)); // Create a new cTCPLink for the incoming connection: cTCPLinkImplPtr Link = std::make_shared(a_Socket, LinkCallbacks, Self->m_SelfPtr, a_Addr, static_cast(a_Len)); From 392679e7e69fbd0ed803b38b8d545028c7195870 Mon Sep 17 00:00:00 2001 From: Mike Jagdis Date: Mon, 29 Apr 2024 12:59:32 +0100 Subject: [PATCH 3/3] And clang objects to old style casts Signed-off-by: Mike Jagdis --- src/OSSupport/ServerHandleImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OSSupport/ServerHandleImpl.cpp b/src/OSSupport/ServerHandleImpl.cpp index e498b53164..669a0f83f0 100644 --- a/src/OSSupport/ServerHandleImpl.cpp +++ b/src/OSSupport/ServerHandleImpl.cpp @@ -329,7 +329,7 @@ void cServerHandleImpl::Callback(evconnlistener * a_Listener, evutil_socket_t a_ } const int one = 1; - setsockopt(a_Socket, IPPROTO_TCP, TCP_NODELAY, (const char *)&one, sizeof(one)); + setsockopt(a_Socket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&one), sizeof(one)); // Create a new cTCPLink for the incoming connection: cTCPLinkImplPtr Link = std::make_shared(a_Socket, LinkCallbacks, Self->m_SelfPtr, a_Addr, static_cast(a_Len));