mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Move the newly introduced disable_nagle_algorithm flag into the StreamRequestHandler, where it is more appropriate.
This commit is contained in:
parent
5a85d5c4f2
commit
f1d11efb72
2 changed files with 8 additions and 17 deletions
|
@ -374,7 +374,6 @@ class TCPServer(BaseServer):
|
|||
- socket_type
|
||||
- request_queue_size (only for stream sockets)
|
||||
- allow_reuse_address
|
||||
- disable_nagle_algorithm
|
||||
|
||||
Instance variables:
|
||||
|
||||
|
@ -392,8 +391,6 @@ class TCPServer(BaseServer):
|
|||
|
||||
allow_reuse_address = False
|
||||
|
||||
disable_nagle_algorithm = False
|
||||
|
||||
def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
|
||||
"""Constructor. May be extended, do not override."""
|
||||
BaseServer.__init__(self, server_address, RequestHandlerClass)
|
||||
|
@ -444,10 +441,7 @@ class TCPServer(BaseServer):
|
|||
May be overridden.
|
||||
|
||||
"""
|
||||
request = self.socket.accept()
|
||||
if self.disable_nagle_algorithm:
|
||||
request[0].setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True)
|
||||
return request
|
||||
return self.socket.accept()
|
||||
|
||||
def close_request(self, request):
|
||||
"""Called to clean up an individual request."""
|
||||
|
@ -655,8 +649,15 @@ class StreamRequestHandler(BaseRequestHandler):
|
|||
rbufsize = -1
|
||||
wbufsize = 0
|
||||
|
||||
# Disable nagle algoritm for this socket, if True.
|
||||
# Use only when wbufsize != 0, to avoid small packets.
|
||||
disable_nagle_algorithm = False
|
||||
|
||||
def setup(self):
|
||||
self.connection = self.request
|
||||
if self.disable_nagle_algorithm:
|
||||
self.connection.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_NODELAY, True)
|
||||
self.rfile = self.connection.makefile('rb', self.rbufsize)
|
||||
self.wfile = self.connection.makefile('wb', self.wbufsize)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue