subchannel: tolerate multiple pre-open inbound DATA messages

This commit is contained in:
Brian Warner 2019-08-11 18:47:21 -07:00
parent 327e72e6ac
commit 1c8c2997c7
2 changed files with 5 additions and 3 deletions

View File

@ -251,7 +251,7 @@ class SubChannel(object):
def _deliver_queued_data(self):
for data in self._pending_remote_data:
self.remote_data(data)
del self._pending_remote_data
del self._pending_remote_data
if self._pending_remote_close:
self.remote_close()
del self._pending_remote_close

View File

@ -112,11 +112,13 @@ class SubChannelAPI(unittest.TestCase):
def test_data_before_open(self):
sc, m, scid, hostaddr, peeraddr, p = make_sc(set_protocol=False)
sc.remote_data(b"data")
sc.remote_data(b"data1")
sc.remote_data(b"data2")
self.assertEqual(p.mock_calls, [])
sc._set_protocol(p)
sc._deliver_queued_data()
self.assertEqual(p.mock_calls, [mock.call.dataReceived(b"data")])
self.assertEqual(p.mock_calls, [mock.call.dataReceived(b"data1"),
mock.call.dataReceived(b"data2")])
p.mock_calls[:] = []
sc.remote_data(b"more")
self.assertEqual(p.mock_calls, [mock.call.dataReceived(b"more")])