mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #27906: Fix socket accept exhaustion during high TCP traffic.
Patch by Kevin Conway.
This commit is contained in:
parent
4357cf6202
commit
a1b0e7db73
6 changed files with 60 additions and 36 deletions
|
@ -1634,7 +1634,7 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
|
|||
self.loop.call_later.assert_called_with(constants.ACCEPT_RETRY_DELAY,
|
||||
# self.loop._start_serving
|
||||
mock.ANY,
|
||||
MyProto, sock, None, None)
|
||||
MyProto, sock, None, None, mock.ANY)
|
||||
|
||||
def test_call_coroutine(self):
|
||||
@asyncio.coroutine
|
||||
|
|
|
@ -687,6 +687,20 @@ class BaseSelectorEventLoopTests(test_utils.TestCase):
|
|||
selectors.EVENT_WRITE)])
|
||||
self.loop.remove_writer.assert_called_with(1)
|
||||
|
||||
def test_accept_connection_multiple(self):
|
||||
sock = mock.Mock()
|
||||
sock.accept.return_value = (mock.Mock(), mock.Mock())
|
||||
backlog = 100
|
||||
# Mock the coroutine generation for a connection to prevent
|
||||
# warnings related to un-awaited coroutines.
|
||||
mock_obj = mock.patch.object
|
||||
with mock_obj(self.loop, '_accept_connection2') as accept2_mock:
|
||||
accept2_mock.return_value = None
|
||||
with mock_obj(self.loop, 'create_task') as task_mock:
|
||||
task_mock.return_value = None
|
||||
self.loop._accept_connection(mock.Mock(), sock, backlog=backlog)
|
||||
self.assertEqual(sock.accept.call_count, backlog)
|
||||
|
||||
|
||||
class SelectorTransportTests(test_utils.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue