Default nodelay value needs to be set for all sockets. #9235
Description
The API indicates that the nodelay option is enabled by default http://nodejs.org/api/net.html#net_socket_setnodelay_nodelay
However, when debugging failures in this test for 0.12 - test/simple/test-http-request-end.js we discovered that the failures were because nodelay was not set for the sockets on AIX.
For linux, the default at the OS level seems to be to enable TCP_NODELAY so all sockets have TCP_NODELAY set. The default for AIX is for TCP_NODELAY to be false.
Since the Node API specifies that the default for nodelay is true it should make the required calls in order to ensure that nodelay is set to true, regardless of the default for the OS.
I looked at the libuv code and I don't see any code in the OS specific files for any of the platforms that would adjust the default for any platform.
This patch on net.js adjusts the creation of TCP objects so that by default nodelay is true for all sockets.
diff --git a/lib/net.js b/lib/net.js index d353ff7..d655dd3 100644 --- a/lib/net.js +++ b/lib/net.js @@ -48,7 +48,12 @@ function createPipe() { // constructor for lazy loading function createTCP() { var TCP = process.binding('tcp_wrap').TCP; - return new TCP(); + var handle = new TCP(); + // The api indicates the default for noDelay is true. This is not + // true by default at the OS level on all platforms (ex AIX) + // so set it to ensure it is set at the OS level. + handle.setNoDelay(true); + return handle; }
If this is the right fix I can create a pull request.