-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not swallow FIN frames without data #439
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #439 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 25 25
Lines 4868 4867 -1
=========================================
- Hits 4868 4867 -1 ☔ View full report in Codecov by Sentry. |
Thanks so much for digging into this, it does look like a tricky situation! Double thanks for providing a unit test :) I haven't looked at this part of the code, so my apologies if my comment is incorrect, but something doesn't feel right about the stream ending in response to use sending something as opposed to receiving an ACK. |
See my answer above. One more clarification: This is the stream sender ending, not the entire stream. The stream itself is not necessarily finished (the stream receiver may still be active). |
Right, I'm quite clear that we're only talking about the sender part, but let's take the case of a unidirectional stream on which we'll only be sending. In this case, when the sender part finishes, the whole stream finishes and we discard its state. I agree with the additional condition you added ( What I don't agree with is the change in |
If we remove the change to def test_sender_fin_then_ack(self):
stream = QuicStream()
# send some data
stream.sender.write(b"data")
frame = stream.sender.get_frame(8)
self.assertEqual(frame.data, b"data")
# request EOF
stream.sender.write(b"", end_stream=True)
self.assertFalse(stream.sender.buffer_is_empty)
# receive acknowledgement for data
stream.sender.on_data_delivery(QuicDeliveryState.ACKED, 0, 4)
self.assertFalse(stream.sender.is_finished)
# send EOF
frame = stream.sender.get_frame(8)
self.assertEqual(frame.data, b"")
self.assertTrue(frame.fin)
self.assertEqual(frame.offset, 4)
self.assertFalse(stream.sender.is_finished)
# receive acknowledgement for EOF
stream.sender.on_data_delivery(QuicDeliveryState.ACKED, 4, 4)
self.assertTrue(stream.sender.is_finished) |
D'oh! I totally missed that mechanic. Thanks for pointing that out, I've just pushed a fix that removes the premature |
If you don't mind I think I need to think some more about whether we're 100% OK now. I'm wondering whether there isn't yet another pitfall here where we have sent out the FIN, but the receiver only ACK'd the data but not the FIN. In this situation, simply looking at the offset which was acknowledged doesn't tell us whether the FIN was ACK'd, or am I wrong? This might mean changing the |
Right - I naively expected the connection to handle retransmission, but if that's handled by QuicStreamSender itself then we need a way to detect FIN acks + new state that tracks that. This also needs to handle the case that the ACK for the FIN is not the last ACK for the stream (i.e. there's other data still in flight). |
Co-authored-by: Maximilian Hils <[email protected]>
Superseeded by #441 |
This PR fixes #438. Thanks for your hard work on aioquic! 🍰