From ee990c8c1bdf53bb0e623688247fd7d94d3ed4a7 Mon Sep 17 00:00:00 2001 From: bjorne Date: Tue, 10 Nov 2026 11:50:48 +0100 Subject: [PATCH] async: set TCP_NODELAY on all TCP connections Outbound client/trunk connections went through TcpConnection::setSocket() which never disabled Nagle (TCP_NODELAY was set only on the server/inbound side in AsyncTcpServerBase). On a high-RTT inter-reflector trunk this coalesced audio frames into ~1 RTT bursts (measured ~147 ms gaps), causing choppy audio downstream. Set TCP_NODELAY in setSocket() so every TCP connection (inbound and outbound) sends frames immediately. Co-Authored-By: Claude Opus 4.8 --- src/async/core/AsyncTcpConnection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/async/core/AsyncTcpConnection.cpp b/src/async/core/AsyncTcpConnection.cpp index 655737b..8c78a8c 100644 --- a/src/async/core/AsyncTcpConnection.cpp +++ b/src/async/core/AsyncTcpConnection.cpp @@ -35,6 +35,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include +#include +#include #include #include #include @@ -378,6 +380,14 @@ std::string TcpConnection::sslCommonName(void) const void TcpConnection::setSocket(int sock) { this->sock = sock; + if (sock >= 0) + { + int on = 1; + if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&on, sizeof(on)) == -1) + { + perror("setsockopt(TcpConnection, TCP_NODELAY)"); + } + } rd_watch.setFd(sock, FdWatch::FD_WATCH_RD); rd_watch.setEnabled(sock >= 0); m_wr_watch.setEnabled(false);