diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 193322f2fa..f75e1f7a12 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -169,6 +169,7 @@ def get_socket(conf, default_port=8080): sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # in my experience, sockets can hang around forever without keepalive sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) if hasattr(socket, 'TCP_KEEPIDLE'): sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 600) if warn_ssl: diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index 085364c267..869fbe2593 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -246,11 +246,13 @@ class TestWSGI(unittest.TestCase): socket.SO_REUSEADDR: 1, socket.SO_KEEPALIVE: 1, }, + socket.IPPROTO_TCP: { + socket.TCP_NODELAY: 1, + } } if hasattr(socket, 'TCP_KEEPIDLE'): - expected_socket_opts[socket.IPPROTO_TCP] = { - socket.TCP_KEEPIDLE: 600, - } + expected_socket_opts[socket.IPPROTO_TCP][ + socket.TCP_KEEPIDLE] = 600 self.assertEquals(sock.opts, expected_socket_opts) # test ssl sock = wsgi.get_socket(ssl_conf)