-
Notifications
You must be signed in to change notification settings - Fork 991
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
feat(webrtc): implement fin ack #5687
base: master
Are you sure you want to change the base?
Conversation
Thank you for your contribution @tesol2y090 and sorry for the delay here! Will try to give this a review in the next days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay here @tesol2y090.
Some first comments.
misc/webrtc-utils/src/stream.rs
Outdated
// Check if we've received FIN_ACK or deadline has passed | ||
if self.state.fin_ack_received() | ||
|| self | ||
.fin_ack_deadline | ||
.is_some_and(|deadline| Instant::now() >= deadline) | ||
{ | ||
if !self.state.fin_ack_received() { | ||
tracing::warn!("FIN_ACK timeout, forcing close"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do early returns instead of nested if-statements here?
misc/webrtc-utils/src/stream.rs
Outdated
.expect("to not close twice") | ||
.send(GracefullyClosed {}); | ||
// Check if we've received FIN_ACK or deadline has passed | ||
if self.state.fin_ack_received() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, but don't we need to somehow continue reading here to be able to receive the FIN_ACK
?
With AsyncWriteExt
for instance a future will be created that only returns after poll_close
succeeded i.e. no concurrent call to poll_read
happens. With the current impl, I don't think a FIN_ACK
will ever be read in that case?
On the other hand, we'd then have to discard the read messages or buffer them. Not sure how this is handled e.g. in QUIC, or in the go implementation.
/// FIN_ACK timeout | ||
const FIN_ACK_TIMEOUT: Duration = Duration::from_secs(10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this number part of specs or was discussed somewhere?
This is time that we'll have to wait each time when closing a stream if the remote doesn't support FIN_ACK
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right. I follow the go-libp2p implementation. https://github.com/libp2p/go-libp2p/blob/master/p2p/transport/webrtc/stream.go#L45
Description
Implements FIN_ACK support for WebRTC streams to ensure reliable closure handshaking as specified in the WebRTC spec. This adds:
FIN_ACK
#4600Notes & open questions
Instant
for deadline tracking instead of tokio timer to avoid extra dependenciesChange checklist