From 748b83231af135853d7a7e4e3b949af52f321269 Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Wed, 23 Mar 2011 11:03:09 -0400 Subject: [PATCH] Bug 542401 - Look into whether Firefox should set TCP_NODELAY for non-SSL HTTP socket r=jduell indeed without nagle disabled (which is what nodelay does) a pipeline can be interrupted for a full rtt waiting for an ack, which defeats the purpose of pipelining. Other parts of FF can just coalesce the writes internally, but sometimes that is not possible for pipelines which may not have an opportunity for a pipelined request when the "runt" packet goes out, but discovers such an opportunity a long time before the rtt is expired. In other places (such as long posts) we do a fine job of coalescing already, so this should not result in any extra packets on the wire, just improved latency. --HG-- extra : rebase_source : f83f5b080a3da5875abaee001e8af18503fcff38 --- netwerk/base/src/nsSocketTransport2.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index 3f95dfdde2ad..214f0aa1b569 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -1131,6 +1131,13 @@ nsSocketTransport::InitiateSocket() status = PR_SetSocketOption(fd, &opt); NS_ASSERTION(status == PR_SUCCESS, "unable to make socket non-blocking"); + // disable the nagle algorithm - if we rely on it to coalesce writes into + // full packets the final packet of a multi segment POST/PUT or pipeline + // sequence is delayed a full rtt + opt.option = PR_SockOpt_NoDelay; + opt.value.no_delay = PR_TRUE; + PR_SetSocketOption(fd, &opt); + // if the network.tcp.sendbuffer preference is set, use it to size SO_SNDBUF // The Windows default of 8KB is too small and as of vista sp1, autotuning // only applies to receive window