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 <noreply@anthropic.com>
This commit is contained in:
1 parent
dbad88e8c3
commit
ee990c8c1b
1 file changed
+10
@@ -35,6 +35,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -378,6 +380,14 @@ std::string TcpConnection::sslCommonName(void) const
|
|||||||
void TcpConnection::setSocket(int sock)
|
void TcpConnection::setSocket(int sock)
|
||||||
{
|
{
|
||||||
this->sock = 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.setFd(sock, FdWatch::FD_WATCH_RD);
|
||||||
rd_watch.setEnabled(sock >= 0);
|
rd_watch.setEnabled(sock >= 0);
|
||||||
m_wr_watch.setEnabled(false);
|
m_wr_watch.setEnabled(false);
|
||||||
|
|||||||
Reference in new issue
Block a user