From e033ad49883bac276278562f9a38168c6dc58b60 Mon Sep 17 00:00:00 2001 From: Troy Date: Mon, 29 Apr 2019 09:33:56 -0700 Subject: [PATCH] Disable nagle on whois sockets (#218) This incorporates #194 with a fixed unit test. --- irrd/server/whois/protocol.py | 3 +++ irrd/server/whois/tests/test_protocol.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/irrd/server/whois/protocol.py b/irrd/server/whois/protocol.py index e1d2a4ae3..cccb5d789 100644 --- a/irrd/server/whois/protocol.py +++ b/irrd/server/whois/protocol.py @@ -35,6 +35,9 @@ def connectionMade(self) -> None: # noqa: N802 self.transport.loseConnection() return + # disable nagle + self.transport.setTcpNoDelay(True) + self.peer_str = f'[{peer.host}]:{peer.port}' self.query_parser = WhoisQueryParser(peer, self.peer_str) diff --git a/irrd/server/whois/tests/test_protocol.py b/irrd/server/whois/tests/test_protocol.py index 3599bb99f..565fbb532 100644 --- a/irrd/server/whois/tests/test_protocol.py +++ b/irrd/server/whois/tests/test_protocol.py @@ -128,7 +128,8 @@ def test_whois_protocol_access_list_permitted(self, config_override, mock_pipeli receiver.factory = mock_factory receiver.connectionMade() - assert len(mock_transport.mock_calls) == 0 + # with setTcpNoDelay(True) this should be 1 + assert len(mock_transport.mock_calls) == 1 def test_whois_protocol_access_list_denied(self, config_override): config_override({