Commit e9231a5f authored by Toby Dickenson's avatar Toby Dickenson

turn on TCP_NODELAY, in both directions. This avoids latency when a request or...

turn on TCP_NODELAY, in both directions. This avoids latency when a request or response doesnt fit in one packet. ZEO is already doing its best to buffer data before calling send, so TCP_NODELAY can do little harm
parent 2a862819
...@@ -262,6 +262,7 @@ class ConnectThread(threading.Thread): ...@@ -262,6 +262,7 @@ class ConnectThread(threading.Thread):
domain, err), level=zLOG.ERROR) domain, err), level=zLOG.ERROR)
continue continue
s.setblocking(0) s.setblocking(0)
s.setsockopt(socket.IPPROTO_TCP, 1, 1) # TCP_NODELAY
self.sockets[s] = addr self.sockets[s] = addr
# connect() raises Connected iff it succeeds # connect() raises Connected iff it succeeds
# XXX can still block for a while if addr requires DNS # XXX can still block for a while if addr requires DNS
......
...@@ -41,6 +41,7 @@ class Dispatcher(asyncore.dispatcher): ...@@ -41,6 +41,7 @@ class Dispatcher(asyncore.dispatcher):
self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
else: else:
self.create_socket(socket.AF_UNIX, socket.SOCK_STREAM) self.create_socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.setsockopt(socket.IPPROTO_TCP, 1, 1) # TCP_NODELAY
self.set_reuse_addr() self.set_reuse_addr()
log("listening on %s" % str(self.addr)) log("listening on %s" % str(self.addr))
self.bind(self.addr) self.bind(self.addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment