Skip to content

Commit

Permalink
TODO: TX_TIME is invalid for some reason
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed May 10, 2024
1 parent 0b19199 commit e8b6134
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dgram/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl RecvData {
}

/// Returns the list of cmsgs which were returned from calling `recvmsg`. If
/// `recvmsg` was called with `recv_cmsgs` set to to `false`, this will
/// return an empty slice.
/// `recvmsg` was called with its [`RecvMsgCmsgSettings::store_cmsgs`]
/// field set to to `false`, this will return an empty slice.
pub fn cmsgs(&self) -> &[ControlMessageOwned] {
&self.cmsgs
}
Expand Down
19 changes: 17 additions & 2 deletions dgram/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub fn send_msg(
cmsgs.push(ControlMessage::TxTime(&raw_time));
}

let client_addr = dst.map(SockaddrStorage::from);
raw_send_to(
&fd.as_fd(),
send_buf,
Expand All @@ -76,8 +77,9 @@ pub fn send_msg(
#[cfg(target_os = "linux")]
pub fn send_with_cmsgs(

Check failure on line 78 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche

function `send_with_cmsgs` is never used

Check failure on line 78 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche

function `send_with_cmsgs` is never used

Check failure on line 78 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche (boringssl-boring-crate)

function `send_with_cmsgs` is never used

Check failure on line 78 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche_multiarch (aarch64-unknown-linux-gnu)

function `send_with_cmsgs` is never used
fd: impl AsFd, send_buf: &[u8], cmsgs: &[ControlMessage],
client_addr: &SockaddrStorage,
dst: Option<SocketAddr>,
) -> SyscallResult<usize> {
let client_addr = dst.map(SockaddrStorage::from);
raw_send_to(&fd.as_fd(), send_buf, cmsgs, MsgFlags::empty(), client_addr)
}

Expand Down Expand Up @@ -160,6 +162,19 @@ pub fn recv_msg(
}
}

fn std_time_to_u64(time: &Instant) -> u64 {

Check failure on line 165 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche

function `std_time_to_u64` is never used

Check failure on line 165 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche

function `std_time_to_u64` is never used

Check failure on line 165 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche (boringssl-boring-crate)

function `std_time_to_u64` is never used

Check failure on line 165 in dgram/src/syscalls.rs

View workflow job for this annotation

GitHub Actions / quiche_multiarch (aarch64-unknown-linux-gnu)

function `std_time_to_u64` is never used
const NANOS_PER_SEC: u64 = 1_000_000_000;
const INSTANT_ZERO: std::time::Instant =
unsafe { std::mem::transmute(std::time::UNIX_EPOCH) };

let raw_time = time.duration_since(INSTANT_ZERO);

let sec = raw_time.as_secs();
let nsec = raw_time.subsec_nanos();

sec * NANOS_PER_SEC + nsec as u64
}

#[cfg(all(test, target_os = "linux", not(target_os = "android")))]
mod tests {
use nix::cmsg_space;
Expand Down Expand Up @@ -315,7 +330,7 @@ mod tests {

send_msg(send, send_buf, SendMsgCmsgSettings {
segment_size: None,
tx_time: Some(Instant::now() + std::time::Duration::from_millis(5)),
tx_time: Some(Instant::now() + std::time::Duration::from_secs(5)),
dst: addr,
})?;

Expand Down

0 comments on commit e8b6134

Please sign in to comment.