| Index: net/socket/tcp_socket_win.cc
|
| diff --git a/net/socket/tcp_socket_win.cc b/net/socket/tcp_socket_win.cc
|
| index 827dd72f340edacfca54e9fed6c89d1f9ff0177e..872a56026293cd4c5ee60fba0bcbdb2762c8ec9e 100644
|
| --- a/net/socket/tcp_socket_win.cc
|
| +++ b/net/socket/tcp_socket_win.cc
|
| @@ -49,6 +49,36 @@
|
| }
|
|
|
| // Disable Nagle.
|
| +// The Nagle implementation on windows is governed by RFC 896. The idea
|
| +// behind Nagle is to reduce small packets on the network. When Nagle is
|
| +// enabled, if a partial packet has been sent, the TCP stack will disallow
|
| +// further *partial* packets until an ACK has been received from the other
|
| +// side. Good applications should always strive to send as much data as
|
| +// possible and avoid partial-packet sends. However, in most real world
|
| +// applications, there are edge cases where this does not happen, and two
|
| +// partial packets may be sent back to back. For a browser, it is NEVER
|
| +// a benefit to delay for an RTT before the second packet is sent.
|
| +//
|
| +// As a practical example in Chromium today, consider the case of a small
|
| +// POST. I have verified this:
|
| +// Client writes 649 bytes of header (partial packet #1)
|
| +// Client writes 50 bytes of POST data (partial packet #2)
|
| +// In the above example, with Nagle, a RTT delay is inserted between these
|
| +// two sends due to nagle. RTTs can easily be 100ms or more. The best
|
| +// fix is to make sure that for POSTing data, we write as much data as
|
| +// possible and minimize partial packets. We will fix that. But disabling
|
| +// Nagle also ensure we don't run into this delay in other edge cases.
|
| +// See also:
|
| +// http://technet.microsoft.com/en-us/library/bb726981.aspx
|
| +bool DisableNagle(SOCKET socket, bool disable) {
|
| + BOOL val = disable ? TRUE : FALSE;
|
| + int rv = setsockopt(socket, IPPROTO_TCP, TCP_NODELAY,
|
| + reinterpret_cast<const char*>(&val),
|
| + sizeof(val));
|
| + DCHECK(!rv) << "Could not disable nagle";
|
| + return rv == 0;
|
| +}
|
| +
|
| // Enable TCP Keep-Alive to prevent NAT routers from timing out TCP
|
| // connections. See http://crbug.com/27400 for details.
|
| bool SetTCPKeepAlive(SOCKET socket, BOOL enable, int delay_secs) {
|
| @@ -549,7 +579,7 @@
|
| }
|
|
|
| void TCPSocketWin::SetDefaultOptionsForClient() {
|
| - SetTCPNoDelay(socket_, /*no_delay=*/true);
|
| + DisableNagle(socket_, true);
|
| SetTCPKeepAlive(socket_, true, kTCPKeepAliveSeconds);
|
| }
|
|
|
| @@ -594,7 +624,7 @@
|
| }
|
|
|
| bool TCPSocketWin::SetNoDelay(bool no_delay) {
|
| - return SetTCPNoDelay(socket_, no_delay);
|
| + return DisableNagle(socket_, no_delay);
|
| }
|
|
|
| void TCPSocketWin::Close() {
|
|
|