Skip to content

Commit

Permalink
udp: document possible panics in UdpSocketState::new()
Browse files Browse the repository at this point in the history
  • Loading branch information
stormshield-damiend authored and Ralith committed Dec 29, 2023
1 parent 1377dbd commit 1ad1e9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions quinn-udp/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ pub struct UdpSocketState {
}

impl UdpSocketState {
/// Tokio-compatible UDP socket with some useful specializations
///
/// # Panics
/// - If `CMSG_LEN` is too small to store a [`libc::in6_pktinfo`] and one `libc::c_int` (for ECN)
/// - If [`libc::cmsghdr`] has stricter alignment requirements than [`cmsg::Aligned`]
pub fn new(sock: UdpSockRef<'_>) -> io::Result<Self> {
let io = sock.0;
let mut cmsg_platform_space = 0;
Expand Down
5 changes: 5 additions & 0 deletions quinn-udp/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ pub struct UdpSocketState {
}

impl UdpSocketState {
/// Create a QUIC-friendly UDP socket for Windows
///
/// # Panics
/// - If `CMSG_LEN` is too small to store a [`WinSock::IN6_PKTINFO`] and one `i32` (for ECN)
/// - If [`WinSock::CMSGHDR`] has stricter alignment requirements than [`cmsg::Aligned`]
pub fn new(socket: UdpSockRef<'_>) -> io::Result<Self> {
assert!(
CMSG_LEN
Expand Down

0 comments on commit 1ad1e9d

Please sign in to comment.