Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions rs/moq-relay/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,7 @@ impl Config {
if self.handoff.socket.is_none() {
return Ok(());
}
#[cfg(not(target_os = "linux"))]
anyhow::bail!("handoff.socket is Linux-only");
anyhow::ensure!(cfg!(target_os = "linux"), "handoff.socket is Linux-only");
// Static and API peers share one dial socket on a fixed port, bound at startup and
// not handed on: a successor could not bind it beside the relay it replaces.
anyhow::ensure!(
Expand Down
9 changes: 6 additions & 3 deletions rs/moq-relay/src/handoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ pub struct Config {
}

/// The flag that runs a stand-in, which its relay must not see again.
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
#[cfg(any(target_os = "linux", test))]
const SUPERVISE_FLAG: &str = "--handoff-supervise";

/// The arguments a stand-in starts its relay with: its own, but for the flag that
/// made it a stand-in.
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
#[cfg(any(target_os = "linux", test))]
fn relay_args(args: impl IntoIterator<Item = std::ffi::OsString>) -> Vec<std::ffi::OsString> {
let mut positional = false;
args.into_iter()
Expand Down Expand Up @@ -177,7 +177,10 @@ struct Group {
}

/// What a serving [`Handoff`] tells the rest of the relay.
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
#[cfg_attr(
not(target_os = "linux"),
expect(dead_code, reason = "off Linux no Handoff exists to read them")
)]
pub(crate) struct Events {
/// Set once a successor took over: stop accepting and drain.
pub handed: tokio::sync::watch::Sender<bool>,
Expand Down
9 changes: 9 additions & 0 deletions rs/moq-sock/src/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,13 @@ pub const MAX_SHARDS: u16 = 256;

/// What the steering filter computes for one group.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(
not(target_os = "linux"),
expect(
dead_code,
reason = "only Linux's filter reads it, and elsewhere a group never binds"
)
)]
struct Program {
/// Members per generation.
count: u16,
Expand Down Expand Up @@ -1060,7 +1067,9 @@ mod tests {
packet
}

#[cfg(target_os = "linux")]
const V1: [u8; 4] = [0, 0, 0, 1];
#[cfg(target_os = "linux")]
const V2: [u8; 4] = [0x6b, 0x33, 0x43, 0xcf];

/// Every packet a client sends with a connection ID the server chose.
Expand Down
5 changes: 2 additions & 3 deletions rs/moq-transcode/benches/ladder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//! Run with `cargo bench -p moq-transcode --bench ladder`.

use std::sync::Arc;
use std::time::Duration;

use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use moq_transcode::{Config, Ladder, Rung};
Expand Down Expand Up @@ -98,12 +97,12 @@ async fn fanout(sinks: &mut [(moq_video::Size, moq_video::encode::Sink)], frame:

/// CPU time the calling thread has used, which on a current-thread runtime is the worker's.
#[cfg(unix)]
fn thread_cpu() -> Duration {
fn thread_cpu() -> std::time::Duration {
let mut time = libc::timespec { tv_sec: 0, tv_nsec: 0 };
// SAFETY: `time` is a valid, initialized output pointer for this supported clock.
let result = unsafe { libc::clock_gettime(libc::CLOCK_THREAD_CPUTIME_ID, &mut time) };
assert_eq!(result, 0, "thread CPU clock: {}", std::io::Error::last_os_error());
Duration::new(
std::time::Duration::new(
u64::try_from(time.tv_sec).unwrap(),
u32::try_from(time.tv_nsec).unwrap(),
)
Expand Down
Loading