mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-33263: Fix FD leak in _SelectorSocketTransport (GH-6450)
* bpo-33263 Fix FD leak in _SelectorSocketTransport. (GH-6450) Under particular circumstances _SelectorSocketTransport can try to add a reader even the transport is already being closed. This can lead to FD leak and invalid stated of the following connections. Fixed the SelectorSocketTransport to add the reader only if the trasport is still active.
This commit is contained in:
parent
4054b172ab
commit
a84d0b361a
3 changed files with 25 additions and 3 deletions
|
@ -871,6 +871,21 @@ class SelectorTransportTests(test_utils.TestCase):
|
|||
self.assertIsNone(tr._protocol)
|
||||
self.assertIsNone(tr._loop)
|
||||
|
||||
def test__add_reader(self):
|
||||
tr = self.create_transport()
|
||||
tr._buffer.extend(b'1')
|
||||
tr._add_reader(7, mock.sentinel)
|
||||
self.assertTrue(self.loop.readers)
|
||||
|
||||
tr._force_close(None)
|
||||
|
||||
self.assertTrue(tr.is_closing())
|
||||
self.assertFalse(self.loop.readers)
|
||||
|
||||
# can not add readers after closing
|
||||
tr._add_reader(7, mock.sentinel)
|
||||
self.assertFalse(self.loop.readers)
|
||||
|
||||
|
||||
class SelectorSocketTransportTests(test_utils.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue