mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-26 13:31:00 +00:00
net/quinn: Improve datagram handling
We now check if the peer actually supports Datagram and refusing to proceed if it does not. Since the datagram size can actually change over the lifetime of a connection according to variation in path MTU estimate, also check buffer size before trying to send. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1613>
This commit is contained in:
parent
dbad98132f
commit
bc5ed023e4
2 changed files with 46 additions and 6 deletions
|
@ -498,6 +498,15 @@ impl QuinnQuicSink {
|
||||||
};
|
};
|
||||||
|
|
||||||
if use_datagram {
|
if use_datagram {
|
||||||
|
match conn.max_datagram_size() {
|
||||||
|
Some(size) => {
|
||||||
|
if src.len() > size {
|
||||||
|
return Err(Some(gst::error_msg!(
|
||||||
|
gst::ResourceError::Failed,
|
||||||
|
["Sending data failed, current max datagram size: {size}"]
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
match conn.send_datagram(Bytes::copy_from_slice(src)) {
|
match conn.send_datagram(Bytes::copy_from_slice(src)) {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => Err(Some(gst::error_msg!(
|
Err(e) => Err(Some(gst::error_msg!(
|
||||||
|
@ -505,6 +514,13 @@ impl QuinnQuicSink {
|
||||||
["Sending data failed: {}", e]
|
["Sending data failed: {}", e]
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* We check for datagram being unsupported by peer in
|
||||||
|
* start/init_connection, so we should never reach here.
|
||||||
|
*/
|
||||||
|
None => unreachable!(),
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let send = &mut stream.as_mut().unwrap();
|
let send = &mut stream.as_mut().unwrap();
|
||||||
|
|
||||||
|
@ -627,6 +643,18 @@ impl QuinnQuicSink {
|
||||||
|
|
||||||
Some(res)
|
Some(res)
|
||||||
} else {
|
} else {
|
||||||
|
match connection.max_datagram_size() {
|
||||||
|
Some(datagram_size) => {
|
||||||
|
gst::info!(CAT, imp: self, "Datagram size reported by peer: {datagram_size}");
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(WaitError::FutureError(gst::error_msg!(
|
||||||
|
gst::ResourceError::Failed,
|
||||||
|
["Datagram unsupported by the peer"]
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -690,6 +690,18 @@ impl QuinnQuicSrc {
|
||||||
|
|
||||||
Some(res)
|
Some(res)
|
||||||
} else {
|
} else {
|
||||||
|
match connection.max_datagram_size() {
|
||||||
|
Some(datagram_size) => {
|
||||||
|
gst::info!(CAT, imp: self, "Datagram size reported by peer: {datagram_size}");
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(WaitError::FutureError(gst::error_msg!(
|
||||||
|
gst::ResourceError::Failed,
|
||||||
|
["Datagram unsupported by the peer"]
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue