mirror of
https://github.com/n0-computer/noq.git
synced 2026-11-15 21:09:07 +00:00
chore: Warn for unused_qualifications
(cherry picked from commit 531b6dd347)
This commit is contained in:
committed by
Diva Martínez
parent
2cc4e3f25b
commit
34530a8238
+1
-1
@@ -31,7 +31,7 @@ pub fn configure_tracing_subscriber() {
|
||||
|
||||
/// Creates a server endpoint which runs on the given runtime
|
||||
pub fn server_endpoint(
|
||||
rt: &tokio::runtime::Runtime,
|
||||
rt: &Runtime,
|
||||
cert: CertificateDer<'static>,
|
||||
key: PrivateKeyDer<'static>,
|
||||
opt: &Opt,
|
||||
|
||||
@@ -914,7 +914,7 @@ impl From<VarInt> for IdleTimeout {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<Duration> for IdleTimeout {
|
||||
impl TryFrom<Duration> for IdleTimeout {
|
||||
type Error = VarIntBoundsExceeded;
|
||||
|
||||
fn try_from(timeout: Duration) -> Result<Self, Self::Error> {
|
||||
|
||||
@@ -711,7 +711,7 @@ impl Connection {
|
||||
|
||||
self.abandoned_paths.insert(path_id);
|
||||
|
||||
for timer in timer::PathTimer::VALUES {
|
||||
for timer in PathTimer::VALUES {
|
||||
// match for completeness
|
||||
let keep_timer = match timer {
|
||||
// These timers deal with sending and receiving PATH_CHALLENGE and
|
||||
@@ -864,7 +864,7 @@ impl Connection {
|
||||
.paths
|
||||
.get_mut(&path_id)
|
||||
.ok_or(ClosedPath { _private: () })?;
|
||||
let prev = std::mem::replace(&mut path.data.idle_timeout, timeout);
|
||||
let prev = mem::replace(&mut path.data.idle_timeout, timeout);
|
||||
|
||||
// Adjust the PathIdle timer, accounting for already-elapsed idle time.
|
||||
if !self.state.is_closed() {
|
||||
@@ -903,7 +903,7 @@ impl Connection {
|
||||
.paths
|
||||
.get_mut(&path_id)
|
||||
.ok_or(ClosedPath { _private: () })?;
|
||||
Ok(std::mem::replace(&mut path.data.keep_alive, interval))
|
||||
Ok(mem::replace(&mut path.data.keep_alive, interval))
|
||||
}
|
||||
|
||||
/// Find an open, validated path that's on the same network path as the given network path.
|
||||
@@ -1550,7 +1550,7 @@ impl Connection {
|
||||
// Clamp the datagram to at most the minimum MTU to ensure that loss
|
||||
// probes can get through and enable recovery even if the path MTU
|
||||
// has shrank unexpectedly.
|
||||
transmit.start_new_datagram_with_size(std::cmp::min(
|
||||
transmit.start_new_datagram_with_size(cmp::min(
|
||||
usize::from(INITIAL_MTU),
|
||||
transmit.segment_size(),
|
||||
));
|
||||
@@ -6289,8 +6289,7 @@ impl Connection {
|
||||
&& space_id == SpaceId::Data
|
||||
&& path.pending.observed_address
|
||||
{
|
||||
let frame =
|
||||
frame::ObservedAddr::new(path.network_path.remote, self.next_observed_addr_seq_no);
|
||||
let frame = ObservedAddr::new(path.network_path.remote, self.next_observed_addr_seq_no);
|
||||
if builder.frame_space_remaining() > frame.size() {
|
||||
builder.write_frame(frame, stats);
|
||||
|
||||
@@ -7216,7 +7215,7 @@ impl AbandonedPaths {
|
||||
}
|
||||
|
||||
/// Hints when the caller identifies a network change.
|
||||
pub trait NetworkChangeHint: std::fmt::Debug + 'static {
|
||||
pub trait NetworkChangeHint: fmt::Debug + 'static {
|
||||
/// Inform the connection if a path may recover after a network change.
|
||||
///
|
||||
/// After network changes, paths may not be recoverable. In this case, waiting for the path to
|
||||
|
||||
@@ -523,7 +523,7 @@ impl QlogRecvPacket {
|
||||
pub(crate) fn frame(&mut self, frame: &Frame) {
|
||||
#[cfg(feature = "qlog")]
|
||||
{
|
||||
if matches!(frame, crate::Frame::Padding) {
|
||||
if matches!(frame, Frame::Padding) {
|
||||
self.padding += 1;
|
||||
} else {
|
||||
self.emit_padding();
|
||||
@@ -728,7 +728,7 @@ impl ToQlog for frame::MaxStreams {
|
||||
}
|
||||
|
||||
#[cfg(feature = "qlog")]
|
||||
impl ToQlog for frame::StreamsBlocked {
|
||||
impl ToQlog for StreamsBlocked {
|
||||
fn to_qlog(&self) -> QuicFrame {
|
||||
QuicFrame::StreamsBlocked {
|
||||
stream_type: self.dir.into(),
|
||||
|
||||
@@ -749,7 +749,7 @@ impl PendingNewCids {
|
||||
|
||||
/// Pops the next issued CID to transmit from the queue.
|
||||
pub(super) fn pop(&mut self) -> Option<IssuedCid> {
|
||||
if !std::mem::replace(&mut self.sorted, true) {
|
||||
if !mem::replace(&mut self.sorted, true) {
|
||||
self.cids
|
||||
.sort_by_key(|cid| cmp::Reverse((cid.path_id, cid.sequence)));
|
||||
}
|
||||
@@ -1004,7 +1004,7 @@ impl Dedup {
|
||||
type Window = u128;
|
||||
|
||||
/// Number of packets tracked by `Dedup`.
|
||||
const WINDOW_SIZE: u64 = 1 + mem::size_of::<Window>() as u64 * 8;
|
||||
const WINDOW_SIZE: u64 = 1 + size_of::<Window>() as u64 * 8;
|
||||
/// Indicates which data is available for sending
|
||||
///
|
||||
/// This applies to a particular space ID that was queried and all refers to on-path data.
|
||||
@@ -1574,7 +1574,7 @@ mod test {
|
||||
fn sent_packet_size() {
|
||||
// The tracking state of sent packets should be minimal, and not grow
|
||||
// over time.
|
||||
assert!(std::mem::size_of::<SentPacket>() <= 128);
|
||||
assert!(size_of::<SentPacket>() <= 128);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -91,8 +91,7 @@ impl State {
|
||||
if close.error_code == TransportErrorCode::PROTOCOL_VIOLATION {
|
||||
ConnectionError::TransportError(TransportError::new(
|
||||
close.error_code,
|
||||
std::string::String::from_utf8_lossy(&close.reason[..])
|
||||
.to_string(),
|
||||
String::from_utf8_lossy(&close.reason[..]).to_string(),
|
||||
))
|
||||
} else {
|
||||
ConnectionError::ConnectionClosed(close)
|
||||
|
||||
@@ -125,7 +125,7 @@ impl<K, V, const SIZE: usize> Default for SmallMap<K, V, SIZE> {
|
||||
|
||||
impl<K, V, const SIZE: usize> SmallMap<K, V, SIZE>
|
||||
where
|
||||
K: std::cmp::Eq + std::hash::Hash + IdentityHashable,
|
||||
K: Eq + std::hash::Hash + IdentityHashable,
|
||||
{
|
||||
fn insert(&mut self, key: K, value: V) -> Option<V> {
|
||||
// check stack for space
|
||||
|
||||
@@ -222,7 +222,7 @@ const RETRY_INTEGRITY_NONCE_V1: [u8; 12] = [
|
||||
0x46, 0x15, 0x99, 0xd3, 0x5d, 0x63, 0x2b, 0xf2, 0x23, 0x98, 0x25, 0xbb,
|
||||
];
|
||||
|
||||
impl crypto::HeaderKey for Box<dyn HeaderProtectionKey> {
|
||||
impl HeaderKey for Box<dyn HeaderProtectionKey> {
|
||||
fn decrypt(&self, pn_offset: usize, packet: &mut [u8]) {
|
||||
let (header, sample) = packet.split_at_mut(pn_offset + 4);
|
||||
let (first, rest) = header.split_at_mut(1);
|
||||
@@ -378,7 +378,7 @@ impl crypto::ClientConfig for QuicClientConfig {
|
||||
version,
|
||||
got_handshake_data: false,
|
||||
next_secrets: None,
|
||||
inner: rustls::quic::Connection::Client(
|
||||
inner: Connection::Client(
|
||||
rustls::quic::ClientConnection::new(
|
||||
self.inner.clone(),
|
||||
version,
|
||||
@@ -461,7 +461,7 @@ impl QuicServerConfig {
|
||||
pub(crate) fn new(
|
||||
cert_chain: Vec<CertificateDer<'static>>,
|
||||
key: PrivateKeyDer<'static>,
|
||||
) -> Result<Self, rustls::Error> {
|
||||
) -> Result<Self, Error> {
|
||||
let inner = Self::inner(cert_chain, key)?;
|
||||
Ok(Self {
|
||||
// We're confident that the *ring* default provider contains TLS13_AES_128_GCM_SHA256
|
||||
@@ -499,7 +499,7 @@ impl QuicServerConfig {
|
||||
pub(crate) fn inner(
|
||||
cert_chain: Vec<CertificateDer<'static>>,
|
||||
key: PrivateKeyDer<'static>,
|
||||
) -> Result<rustls::ServerConfig, rustls::Error> {
|
||||
) -> Result<rustls::ServerConfig, Error> {
|
||||
let mut inner = rustls::ServerConfig::builder_with_provider(configured_provider())
|
||||
.with_protocol_versions(&[&rustls::version::TLS13])
|
||||
.unwrap() // The *ring* default provider supports TLS 1.3
|
||||
@@ -543,7 +543,7 @@ impl crypto::ServerConfig for QuicServerConfig {
|
||||
version,
|
||||
got_handshake_data: false,
|
||||
next_secrets: None,
|
||||
inner: rustls::quic::Connection::Server(
|
||||
inner: Connection::Server(
|
||||
rustls::quic::ServerConnection::new(self.inner.clone(), version, to_vec(params))
|
||||
.unwrap(),
|
||||
),
|
||||
@@ -590,9 +590,7 @@ pub(crate) fn initial_suite_from_provider(
|
||||
.cipher_suites
|
||||
.iter()
|
||||
.find_map(|cs| match (cs.suite(), cs.tls13()) {
|
||||
(rustls::CipherSuite::TLS13_AES_128_GCM_SHA256, Some(suite)) => {
|
||||
Some(suite.quic_suite())
|
||||
}
|
||||
(CipherSuite::TLS13_AES_128_GCM_SHA256, Some(suite)) => Some(suite.quic_suite()),
|
||||
_ => None,
|
||||
})
|
||||
.flatten()
|
||||
|
||||
@@ -167,7 +167,7 @@ impl FrameType {
|
||||
|
||||
impl Decodable for FrameType {
|
||||
fn decode<B: Buf>(buf: &mut B) -> coding::Result<Self> {
|
||||
Self::try_from(buf.get_var()?).map_err(|_| coding::UnexpectedEnd)
|
||||
Self::try_from(buf.get_var()?).map_err(|_| UnexpectedEnd)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -903,11 +903,11 @@ pub struct ConnectionClose {
|
||||
/// Type of frame that caused the close
|
||||
pub frame_type: MaybeFrame,
|
||||
/// Human-readable reason for the close
|
||||
#[cfg_attr(test, strategy(proptest::collection::vec(any::<u8>(), 0..64).prop_map(Bytes::from)))]
|
||||
#[cfg_attr(test, strategy(collection::vec(any::<u8>(), 0..64).prop_map(Bytes::from)))]
|
||||
pub reason: Bytes,
|
||||
}
|
||||
|
||||
impl fmt::Display for ConnectionClose {
|
||||
impl Display for ConnectionClose {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.error_code.fmt(f)?;
|
||||
if !self.reason.as_ref().is_empty() {
|
||||
@@ -954,11 +954,11 @@ pub struct ApplicationClose {
|
||||
/// Application-specific reason code
|
||||
pub error_code: VarInt,
|
||||
/// Human-readable reason for the close
|
||||
#[cfg_attr(test, strategy(proptest::collection::vec(any::<u8>(), 0..64).prop_map(Bytes::from)))]
|
||||
#[cfg_attr(test, strategy(collection::vec(any::<u8>(), 0..64).prop_map(Bytes::from)))]
|
||||
pub reason: Bytes,
|
||||
}
|
||||
|
||||
impl fmt::Display for ApplicationClose {
|
||||
impl Display for ApplicationClose {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if !self.reason.as_ref().is_empty() {
|
||||
f.write_str(&String::from_utf8_lossy(&self.reason))?;
|
||||
@@ -1882,7 +1882,7 @@ pub(crate) struct NewConnectionId {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn connection_id_and_reset_token() -> impl Strategy<Value = (crate::ConnectionId, ResetToken)> {
|
||||
fn connection_id_and_reset_token() -> impl Strategy<Value = (ConnectionId, ResetToken)> {
|
||||
(any::<ConnectionId>(), any::<[u8; 64]>()).prop_map(|(id, reset_key)| {
|
||||
#[cfg(all(feature = "aws-lc-rs", not(feature = "ring")))]
|
||||
use aws_lc_rs::hmac;
|
||||
@@ -2114,7 +2114,7 @@ pub(crate) struct ObservedAddr {
|
||||
}
|
||||
|
||||
impl ObservedAddr {
|
||||
pub(crate) fn new<N: Into<VarInt>>(remote: std::net::SocketAddr, seq_no: N) -> Self {
|
||||
pub(crate) fn new<N: Into<VarInt>>(remote: SocketAddr, seq_no: N) -> Self {
|
||||
Self {
|
||||
ip: remote.ip(),
|
||||
port: remote.port(),
|
||||
@@ -2740,7 +2740,7 @@ mod test {
|
||||
sequence: 31,
|
||||
retire_prior_to: 13,
|
||||
id: ConnectionId::new(&[0xAB; 8]),
|
||||
reset_token: ResetToken::from([0xCD; crate::RESET_TOKEN_SIZE]),
|
||||
reset_token: ResetToken::from([0xCD; RESET_TOKEN_SIZE]),
|
||||
};
|
||||
let mut buf = Vec::new();
|
||||
cid.encode(&mut buf);
|
||||
|
||||
@@ -245,7 +245,7 @@ impl fmt::Display for Dir {
|
||||
/// Identifier for a stream within a particular connection
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[cfg_attr(test, derive(Arbitrary))]
|
||||
pub struct StreamId(#[cfg_attr(test, strategy(crate::varint::varint_u64()))] u64);
|
||||
pub struct StreamId(#[cfg_attr(test, strategy(varint::varint_u64()))] u64);
|
||||
|
||||
impl fmt::Display for StreamId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
||||
@@ -4533,7 +4533,7 @@ fn throughput() -> TestResult {
|
||||
.with_routes(BwLimitedRouting::new(
|
||||
Pair::CLIENT_ADDR,
|
||||
Pair::SERVER_ADDR,
|
||||
crate::Instant::now(),
|
||||
Instant::now(),
|
||||
BwLimitConfig {
|
||||
bytes_per_second: BPS_LIMIT,
|
||||
buffer_size: 50 * 1500, // buffer that fits ~50 full packets
|
||||
@@ -4593,7 +4593,7 @@ fn send_bytes(mut send_stream: crate::SendStream<'_>, bytes_to_send: &mut usize)
|
||||
Ok(written) => {
|
||||
*bytes_to_send -= written;
|
||||
}
|
||||
Err(crate::WriteError::Blocked) => return Ok(()),
|
||||
Err(WriteError::Blocked) => return Ok(()),
|
||||
Err(e) => panic!("{e:?}"),
|
||||
}
|
||||
}
|
||||
@@ -4602,14 +4602,14 @@ fn send_bytes(mut send_stream: crate::SendStream<'_>, bytes_to_send: &mut usize)
|
||||
Ok(written) => {
|
||||
*bytes_to_send -= written;
|
||||
}
|
||||
Err(crate::WriteError::Blocked) => return Ok(()),
|
||||
Err(WriteError::Blocked) => return Ok(()),
|
||||
Err(e) => panic!("{e:?}"),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn recv_bytes(mut recv_stream: crate::RecvStream<'_>, bytes_received: &mut usize) {
|
||||
fn recv_bytes(mut recv_stream: RecvStream<'_>, bytes_received: &mut usize) {
|
||||
let Ok(mut chunks) = recv_stream.read(true) else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ fn non_zero_length_cids() {
|
||||
0
|
||||
}
|
||||
|
||||
fn cid_lifetime(&self) -> Option<std::time::Duration> {
|
||||
fn cid_lifetime(&self) -> Option<Duration> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ fn non_zero_length_cids() {
|
||||
.expect_err("server did not raise error for connection");
|
||||
match accept_err {
|
||||
crate::ConnectionError::TransportError(error) => {
|
||||
assert_eq!(error.code, crate::TransportErrorCode::PROTOCOL_VIOLATION);
|
||||
assert_eq!(error.code, TransportErrorCode::PROTOCOL_VIOLATION);
|
||||
}
|
||||
_ => panic!("Not a TransportError"),
|
||||
}
|
||||
@@ -142,7 +142,7 @@ fn path_close_last_path() {
|
||||
#[test]
|
||||
fn cid_issued_multipath() {
|
||||
let _guard = subscribe();
|
||||
const ACTIVE_CID_LIMIT: u64 = crate::cid_queue::CidQueue::LEN as _;
|
||||
const ACTIVE_CID_LIMIT: u64 = CidQueue::LEN as _;
|
||||
let mut pair = ConnPair::builder().enable_multipath().connect();
|
||||
|
||||
let client_stats = pair.stats(Client);
|
||||
@@ -374,12 +374,12 @@ fn open_path() -> TestResult {
|
||||
pair.drive();
|
||||
assert_matches!(
|
||||
pair.poll(Client),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
pair.poll(Server),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -402,12 +402,12 @@ fn open_path_key_update() -> TestResult {
|
||||
pair.drive();
|
||||
assert_matches!(
|
||||
pair.poll(Client),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
pair.poll(Server),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -844,11 +844,11 @@ fn mtud_on_two_paths() -> TestResult {
|
||||
// Ensure the path opened correctly.
|
||||
assert_matches!(
|
||||
pair.poll(Client),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
assert_matches!(
|
||||
pair.poll(Server),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
|
||||
// MTU should be 1200 for both paths.
|
||||
@@ -2124,11 +2124,11 @@ fn path_open_challenge_lost() -> TestResult {
|
||||
pair.drive();
|
||||
assert_matches!(
|
||||
pair.poll(Client),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
assert_matches!(
|
||||
pair.poll(Server),
|
||||
Some(Event::Path(crate::PathEvent::Established { id })) if id == path_id
|
||||
Some(Event::Path(PathEvent::Established { id })) if id == path_id
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1177,7 +1177,7 @@ impl InboundQueue {
|
||||
|
||||
/// Drains all packets, yielding each with its `recv_time`.
|
||||
pub(super) fn drain(&mut self) -> impl Iterator<Item = (Instant, Inbound)> {
|
||||
std::mem::take(&mut self.inner)
|
||||
mem::take(&mut self.inner)
|
||||
.into_iter()
|
||||
.map(|((t, _), v)| (t, v))
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ impl TransportParameterId {
|
||||
];
|
||||
}
|
||||
|
||||
impl std::cmp::PartialEq<u64> for TransportParameterId {
|
||||
impl PartialEq<u64> for TransportParameterId {
|
||||
fn eq(&self, other: &u64) -> bool {
|
||||
*other == (*self as u64)
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ impl From<u32> for VarInt {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<u64> for VarInt {
|
||||
impl TryFrom<u64> for VarInt {
|
||||
type Error = VarIntBoundsExceeded;
|
||||
/// Succeeds iff `x` < 2^62
|
||||
fn try_from(x: u64) -> Result<Self, VarIntBoundsExceeded> {
|
||||
@@ -104,7 +104,7 @@ impl std::convert::TryFrom<u64> for VarInt {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<u128> for VarInt {
|
||||
impl TryFrom<u128> for VarInt {
|
||||
type Error = VarIntBoundsExceeded;
|
||||
/// Succeeds iff `x` < 2^62
|
||||
fn try_from(x: u128) -> Result<Self, VarIntBoundsExceeded> {
|
||||
@@ -112,7 +112,7 @@ impl std::convert::TryFrom<u128> for VarInt {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::TryFrom<usize> for VarInt {
|
||||
impl TryFrom<usize> for VarInt {
|
||||
type Error = VarIntBoundsExceeded;
|
||||
/// Succeeds iff `x` < 2^62
|
||||
fn try_from(x: usize) -> Result<Self, VarIntBoundsExceeded> {
|
||||
|
||||
@@ -136,7 +136,7 @@ fn sendmsg_x_fn() -> Option<SendmsgXFn> {
|
||||
// SAFETY: `resolve_symbol` only returns non-zero addresses obtained from `dlsym`, which
|
||||
// guarantees a callable symbol whose type matches the declaration above.
|
||||
resolve_symbol(&ADDR, c"sendmsg_x")
|
||||
.map(|addr| unsafe { std::mem::transmute::<usize, SendmsgXFn>(addr) })
|
||||
.map(|addr| unsafe { mem::transmute::<usize, SendmsgXFn>(addr) })
|
||||
}
|
||||
|
||||
type SendmsgXFn =
|
||||
@@ -182,7 +182,7 @@ fn prepare_recv_x(
|
||||
hdr: &mut msghdr_x,
|
||||
) {
|
||||
hdr.msg_name = name.as_mut_ptr() as _;
|
||||
hdr.msg_namelen = mem::size_of::<libc::sockaddr_storage>() as _;
|
||||
hdr.msg_namelen = size_of::<libc::sockaddr_storage>() as _;
|
||||
hdr.msg_iov = buf as *mut IoSliceMut<'_> as *mut libc::iovec;
|
||||
hdr.msg_iovlen = 1;
|
||||
hdr.msg_control = ctrl.0.as_mut_ptr() as _;
|
||||
@@ -199,7 +199,7 @@ fn recvmsg_x_fn() -> Option<RecvmsgXFn> {
|
||||
// SAFETY: `resolve_symbol` only returns non-zero addresses obtained from `dlsym`, which
|
||||
// guarantees a callable symbol whose type matches the declaration above.
|
||||
resolve_symbol(&ADDR, c"recvmsg_x")
|
||||
.map(|addr| unsafe { std::mem::transmute::<usize, RecvmsgXFn>(addr) })
|
||||
.map(|addr| unsafe { mem::transmute::<usize, RecvmsgXFn>(addr) })
|
||||
}
|
||||
|
||||
type RecvmsgXFn =
|
||||
|
||||
+7
-11
@@ -1,6 +1,6 @@
|
||||
use std::{
|
||||
ffi::{c_int, c_uchar},
|
||||
mem, ptr,
|
||||
ptr,
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
@@ -43,8 +43,8 @@ impl<'a, M: MsgHdr> Encoder<'a, M> {
|
||||
/// - If insufficient buffer space remains.
|
||||
/// - If `T` has stricter alignment requirements than `M::ControlMessage`
|
||||
pub(crate) fn push<T: Copy>(&mut self, level: c_int, ty: c_int, value: T) {
|
||||
assert!(mem::align_of::<T>() <= mem::align_of::<M::ControlMessage>());
|
||||
let space = M::ControlMessage::cmsg_space(mem::size_of_val(&value));
|
||||
assert!(align_of::<T>() <= align_of::<M::ControlMessage>());
|
||||
let space = M::ControlMessage::cmsg_space(size_of_val(&value));
|
||||
assert!(
|
||||
self.hdr.control_len() >= self.len + space,
|
||||
"control message buffer too small. Required: {}, Available: {}",
|
||||
@@ -52,11 +52,7 @@ impl<'a, M: MsgHdr> Encoder<'a, M> {
|
||||
self.hdr.control_len()
|
||||
);
|
||||
let cmsg = self.cmsg.take().expect("no control buffer space remaining");
|
||||
cmsg.set(
|
||||
level,
|
||||
ty,
|
||||
M::ControlMessage::cmsg_len(mem::size_of_val(&value)),
|
||||
);
|
||||
cmsg.set(level, ty, M::ControlMessage::cmsg_len(size_of_val(&value)));
|
||||
unsafe {
|
||||
ptr::write(cmsg.cmsg_data() as *const T as *mut T, value);
|
||||
}
|
||||
@@ -82,8 +78,8 @@ impl<M: MsgHdr> Drop for Encoder<'_, M> {
|
||||
///
|
||||
/// `cmsg` must refer to a native cmsg containing a payload of type `T`
|
||||
pub(crate) unsafe fn decode<T: Copy, C: CMsgHdr>(cmsg: &impl CMsgHdr) -> T {
|
||||
assert!(mem::align_of::<T>() <= mem::align_of::<C>());
|
||||
debug_assert_eq!(cmsg.len(), C::cmsg_len(mem::size_of::<T>()));
|
||||
assert!(align_of::<T>() <= align_of::<C>());
|
||||
debug_assert_eq!(cmsg.len(), C::cmsg_len(size_of::<T>()));
|
||||
unsafe { ptr::read(cmsg.cmsg_data() as *const T) }
|
||||
}
|
||||
|
||||
@@ -118,7 +114,7 @@ impl<'a, M: MsgHdr> Iterator for Iter<'a, M> {
|
||||
// On MacOS < 14 CMSG_NXTHDR might continuously return a zeroed cmsg. In
|
||||
// such case, return `None` instead, thus indicating the end of
|
||||
// the cmsghdr chain.
|
||||
if current.len() < mem::size_of::<M::ControlMessage>() {
|
||||
if current.len() < size_of::<M::ControlMessage>() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -179,7 +179,7 @@ impl Transmit<'_> {
|
||||
|
||||
/// Log at most 1 IO error per minute
|
||||
#[cfg(not(wasm_browser))]
|
||||
const IO_ERROR_LOG_INTERVAL: Duration = std::time::Duration::from_secs(60);
|
||||
const IO_ERROR_LOG_INTERVAL: Duration = Duration::from_secs(60);
|
||||
|
||||
/// Logs a warning message when sendmsg fails
|
||||
///
|
||||
|
||||
+7
-9
@@ -62,16 +62,16 @@ impl UdpSocketState {
|
||||
|| cfg!(solarish)
|
||||
{
|
||||
cmsg_platform_space +=
|
||||
unsafe { libc::CMSG_SPACE(mem::size_of::<libc::in6_pktinfo>() as _) as usize };
|
||||
unsafe { libc::CMSG_SPACE(size_of::<libc::in6_pktinfo>() as _) as usize };
|
||||
}
|
||||
|
||||
assert!(
|
||||
cmsg::LEN
|
||||
>= unsafe { libc::CMSG_SPACE(mem::size_of::<libc::c_int>() as _) as usize }
|
||||
>= unsafe { libc::CMSG_SPACE(size_of::<libc::c_int>() as _) as usize }
|
||||
+ cmsg_platform_space
|
||||
);
|
||||
assert!(
|
||||
mem::align_of::<libc::cmsghdr>() <= mem::align_of::<cmsg::Aligned<[u8; 0]>>(),
|
||||
align_of::<libc::cmsghdr>() <= align_of::<cmsg::Aligned<[u8; 0]>>(),
|
||||
"control message buffers will be misaligned"
|
||||
);
|
||||
|
||||
@@ -432,9 +432,7 @@ fn send(
|
||||
crate::log::info!(
|
||||
"`libc::sendmsg` failed with {e}; halting segmentation offload"
|
||||
);
|
||||
state
|
||||
.max_gso_segments
|
||||
.store(1, std::sync::atomic::Ordering::Relaxed);
|
||||
state.max_gso_segments.store(1, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,7 +671,7 @@ fn prepare_recv(
|
||||
hdr: &mut libc::msghdr,
|
||||
) {
|
||||
hdr.msg_name = name.as_mut_ptr() as _;
|
||||
hdr.msg_namelen = mem::size_of::<libc::sockaddr_storage>() as _;
|
||||
hdr.msg_namelen = size_of::<libc::sockaddr_storage>() as _;
|
||||
hdr.msg_iov = buf as *mut IoSliceMut<'_> as *mut libc::iovec;
|
||||
hdr.msg_iovlen = 1;
|
||||
hdr.msg_control = ctrl.0.as_mut_ptr() as _;
|
||||
@@ -740,7 +738,7 @@ impl ControlMetadata {
|
||||
// https://bugreport.apple.com/web/?problemID=48761855
|
||||
#[allow(clippy::unnecessary_cast)] // cmsg.cmsg_len defined as size_t
|
||||
if cfg!(apple)
|
||||
&& cmsg.cmsg_len as usize == libc::CMSG_LEN(mem::size_of::<u8>() as _) as usize
|
||||
&& cmsg.cmsg_len as usize == libc::CMSG_LEN(size_of::<u8>() as _) as usize
|
||||
{
|
||||
self.ecn_bits = cmsg::decode::<u8, libc::cmsghdr>(cmsg);
|
||||
} else {
|
||||
@@ -871,7 +869,7 @@ pub(crate) fn set_socket_option(
|
||||
level,
|
||||
name,
|
||||
&value as *const _ as _,
|
||||
mem::size_of_val(&value) as _,
|
||||
size_of_val(&value) as _,
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
+12
-12
@@ -40,12 +40,12 @@ impl UdpSocketState {
|
||||
pub fn new(socket: UdpSockRef<'_>) -> io::Result<Self> {
|
||||
assert!(
|
||||
CMSG_LEN
|
||||
>= WinSock::CMSGHDR::cmsg_space(mem::size_of::<WinSock::IN6_PKTINFO>())
|
||||
+ WinSock::CMSGHDR::cmsg_space(mem::size_of::<c_int>())
|
||||
+ WinSock::CMSGHDR::cmsg_space(mem::size_of::<u32>())
|
||||
>= WinSock::CMSGHDR::cmsg_space(size_of::<WinSock::IN6_PKTINFO>())
|
||||
+ WinSock::CMSGHDR::cmsg_space(size_of::<c_int>())
|
||||
+ WinSock::CMSGHDR::cmsg_space(size_of::<u32>())
|
||||
);
|
||||
assert!(
|
||||
mem::align_of::<WinSock::CMSGHDR>() <= mem::align_of::<cmsg::Aligned<[u8; 0]>>(),
|
||||
align_of::<WinSock::CMSGHDR>() <= align_of::<cmsg::Aligned<[u8; 0]>>(),
|
||||
"control message buffers will be misaligned"
|
||||
);
|
||||
|
||||
@@ -81,7 +81,7 @@ impl UdpSocketState {
|
||||
let is_ipv4 = if is_ipv6 {
|
||||
let v6only = unsafe {
|
||||
let mut result: u32 = 0;
|
||||
let mut len = mem::size_of_val(&result) as i32;
|
||||
let mut len = size_of_val(&result) as i32;
|
||||
let rc = WinSock::getsockopt(
|
||||
socket.0.as_raw_socket() as _,
|
||||
WinSock::IPPROTO_IPV6,
|
||||
@@ -291,7 +291,7 @@ impl UdpSocketState {
|
||||
|
||||
let mut wsa_msg = WinSock::WSAMSG {
|
||||
name: &mut source as *mut _ as *mut _,
|
||||
namelen: mem::size_of_val(&source) as _,
|
||||
namelen: size_of_val(&source) as _,
|
||||
lpBuffers: &mut data,
|
||||
Control: ctrl,
|
||||
dwBufferCount: 1,
|
||||
@@ -314,7 +314,7 @@ impl UdpSocketState {
|
||||
|
||||
let addr = unsafe {
|
||||
let (_, addr) = socket2::SockAddr::try_init(|addr_storage, len| {
|
||||
*len = mem::size_of_val(&source) as _;
|
||||
*len = size_of_val(&source) as _;
|
||||
ptr::copy_nonoverlapping(&source, addr_storage as _, 1);
|
||||
Ok(())
|
||||
})?;
|
||||
@@ -568,7 +568,7 @@ fn disable_udp_ioctl(socket: &impl AsRawSocket, control_code: u32) -> io::Result
|
||||
socket.as_raw_socket() as usize,
|
||||
control_code,
|
||||
&disabled as *const _ as *const _,
|
||||
mem::size_of_val(&disabled) as u32,
|
||||
size_of_val(&disabled) as u32,
|
||||
ptr::null_mut(),
|
||||
0,
|
||||
&mut bytes_returned,
|
||||
@@ -595,7 +595,7 @@ fn set_socket_option(
|
||||
level,
|
||||
name,
|
||||
&value as *const _ as _,
|
||||
mem::size_of_val(&value) as _,
|
||||
size_of_val(&value) as _,
|
||||
)
|
||||
};
|
||||
|
||||
@@ -632,9 +632,9 @@ static WSARECVMSG_PTR: LazyLock<WinSock::LPFN_WSARECVMSG> = LazyLock::new(|| {
|
||||
s as _,
|
||||
WinSock::SIO_GET_EXTENSION_FUNCTION_POINTER,
|
||||
&guid as *const _ as *const _,
|
||||
mem::size_of_val(&guid) as u32,
|
||||
size_of_val(&guid) as u32,
|
||||
&mut wsa_recvmsg_ptr as *mut _ as *mut _,
|
||||
mem::size_of_val(&wsa_recvmsg_ptr) as u32,
|
||||
size_of_val(&wsa_recvmsg_ptr) as u32,
|
||||
&mut len,
|
||||
ptr::null_mut(),
|
||||
None,
|
||||
@@ -646,7 +646,7 @@ static WSARECVMSG_PTR: LazyLock<WinSock::LPFN_WSARECVMSG> = LazyLock::new(|| {
|
||||
"ignoring WSARecvMsg function pointer due to ioctl error: {}",
|
||||
io::Error::last_os_error()
|
||||
);
|
||||
} else if len as usize != mem::size_of::<WinSock::LPFN_WSARECVMSG>() {
|
||||
} else if len as usize != size_of::<WinSock::LPFN_WSARECVMSG>() {
|
||||
debug!("ignoring WSARecvMsg function pointer due to pointer size mismatch");
|
||||
wsa_recvmsg_ptr = None;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ fn ecn_v6_dualstack() {
|
||||
eprintln!("Skipping ECN test on Wine (ECN not supported)");
|
||||
return;
|
||||
}
|
||||
let recv = socket2::Socket::new(
|
||||
let recv = Socket::new(
|
||||
socket2::Domain::IPV6,
|
||||
socket2::Type::DGRAM,
|
||||
Some(socket2::Protocol::UDP),
|
||||
@@ -177,7 +177,7 @@ fn ecn_v4_mapped_v6() {
|
||||
eprintln!("Skipping ECN test on Wine (ECN not supported)");
|
||||
return;
|
||||
}
|
||||
let send = socket2::Socket::new(
|
||||
let send = Socket::new(
|
||||
socket2::Domain::IPV6,
|
||||
socket2::Type::DGRAM,
|
||||
Some(socket2::Protocol::UDP),
|
||||
@@ -253,13 +253,13 @@ fn socket_buffers() {
|
||||
1 // Everyone else is sane.
|
||||
};
|
||||
|
||||
let send = socket2::Socket::new(
|
||||
let send = Socket::new(
|
||||
socket2::Domain::IPV4,
|
||||
socket2::Type::DGRAM,
|
||||
Some(socket2::Protocol::UDP),
|
||||
)
|
||||
.unwrap();
|
||||
let recv = socket2::Socket::new(
|
||||
let recv = Socket::new(
|
||||
socket2::Domain::IPV4,
|
||||
socket2::Type::DGRAM,
|
||||
Some(socket2::Protocol::UDP),
|
||||
|
||||
@@ -1863,7 +1863,7 @@ impl Drop for State {
|
||||
// Ensure the endpoint can tidy up
|
||||
let _ = self
|
||||
.endpoint_events
|
||||
.send((self.handle, proto::EndpointEvent::drained()));
|
||||
.send((self.handle, EndpointEvent::drained()));
|
||||
}
|
||||
|
||||
if !self.on_closed.is_empty()
|
||||
|
||||
+5
-5
@@ -111,7 +111,7 @@ enum ConnectionEvent {
|
||||
LocalAddressChanged(Option<Arc<dyn NetworkChangeHint + Sync + Send>>),
|
||||
}
|
||||
|
||||
fn udp_transmit<'a>(t: &proto::Transmit, buffer: &'a [u8]) -> udp::Transmit<'a> {
|
||||
fn udp_transmit<'a>(t: &Transmit, buffer: &'a [u8]) -> udp::Transmit<'a> {
|
||||
udp::Transmit {
|
||||
destination: t.destination,
|
||||
ecn: t.ecn.map(udp_ecn),
|
||||
@@ -121,11 +121,11 @@ fn udp_transmit<'a>(t: &proto::Transmit, buffer: &'a [u8]) -> udp::Transmit<'a>
|
||||
}
|
||||
}
|
||||
|
||||
fn udp_ecn(ecn: proto::EcnCodepoint) -> udp::EcnCodepoint {
|
||||
fn udp_ecn(ecn: EcnCodepoint) -> udp::EcnCodepoint {
|
||||
match ecn {
|
||||
proto::EcnCodepoint::Ect0 => udp::EcnCodepoint::Ect0,
|
||||
proto::EcnCodepoint::Ect1 => udp::EcnCodepoint::Ect1,
|
||||
proto::EcnCodepoint::Ce => udp::EcnCodepoint::Ce,
|
||||
EcnCodepoint::Ect0 => udp::EcnCodepoint::Ect0,
|
||||
EcnCodepoint::Ect1 => udp::EcnCodepoint::Ect1,
|
||||
EcnCodepoint::Ce => udp::EcnCodepoint::Ce,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,9 +22,9 @@ mod tracking {
|
||||
inner: std::sync::Mutex<Inner<T>>,
|
||||
}
|
||||
|
||||
impl<T: Debug> std::fmt::Debug for Mutex<T> {
|
||||
impl<T: Debug> Debug for Mutex<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Debug::fmt(&self.inner, f)
|
||||
Debug::fmt(&self.inner, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ impl<Socket, MakeWritableFutFn, WriteableFut>
|
||||
}
|
||||
}
|
||||
|
||||
impl<Socket, MakeWritableFutFn, WritableFut> super::UdpSender
|
||||
impl<Socket, MakeWritableFutFn, WritableFut> UdpSender
|
||||
for UdpSenderHelper<Socket, MakeWritableFutFn, WritableFut>
|
||||
where
|
||||
Socket: UdpSenderHelperSocket,
|
||||
@@ -161,7 +161,7 @@ where
|
||||
{
|
||||
fn poll_send(
|
||||
self: Pin<&mut Self>,
|
||||
transmit: &udp::Transmit<'_>,
|
||||
transmit: &Transmit<'_>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<io::Result<()>> {
|
||||
let mut this = self.project();
|
||||
@@ -210,7 +210,7 @@ trait UdpSenderHelperSocket: Send + Sync + 'static {
|
||||
/// If not write-ready, this is allowed to return [`std::io::ErrorKind::WouldBlock`].
|
||||
///
|
||||
/// The [`UdpSenderHelper`] will use this to implement [`UdpSender::poll_send`].
|
||||
fn try_send(&self, transmit: &udp::Transmit<'_>) -> io::Result<()>;
|
||||
fn try_send(&self, transmit: &Transmit<'_>) -> io::Result<()>;
|
||||
|
||||
/// See [`UdpSender::max_transmit_segments`].
|
||||
fn max_transmit_segments(&self) -> NonZeroUsize;
|
||||
|
||||
@@ -79,7 +79,7 @@ impl AsyncUdpSocket for UdpSocket {
|
||||
fn poll_recv(
|
||||
&mut self,
|
||||
cx: &mut Context<'_>,
|
||||
bufs: &mut [std::io::IoSliceMut<'_>],
|
||||
bufs: &mut [io::IoSliceMut<'_>],
|
||||
meta: &mut [udp::RecvMeta],
|
||||
) -> Poll<io::Result<usize>> {
|
||||
loop {
|
||||
|
||||
+11
-11
@@ -61,9 +61,9 @@ fn handshake_timeout() {
|
||||
let mut roots = RootCertStore::empty();
|
||||
roots.add(cert.cert.into()).unwrap();
|
||||
|
||||
let mut client_config = crate::ClientConfig::with_root_certificates(Arc::new(roots)).unwrap();
|
||||
let mut client_config = ClientConfig::with_root_certificates(Arc::new(roots)).unwrap();
|
||||
const IDLE_TIMEOUT: Duration = Duration::from_millis(500);
|
||||
let mut transport_config = crate::TransportConfig::default();
|
||||
let mut transport_config = TransportConfig::default();
|
||||
transport_config
|
||||
.max_idle_timeout(Some(IDLE_TIMEOUT.try_into().unwrap()))
|
||||
.initial_rtt(Duration::from_millis(10));
|
||||
@@ -80,7 +80,7 @@ fn handshake_timeout() {
|
||||
.unwrap()
|
||||
.await
|
||||
{
|
||||
Err(crate::ConnectionError::TimedOut) => {}
|
||||
Err(ConnectionError::TimedOut) => {}
|
||||
Err(e) => panic!("unexpected error: {e:?}"),
|
||||
Ok(_) => panic!("unexpected success"),
|
||||
}
|
||||
@@ -121,7 +121,7 @@ async fn close_endpoint() {
|
||||
.unwrap();
|
||||
endpoint.close(0u32.into(), &[]);
|
||||
match conn.await {
|
||||
Err(crate::ConnectionError::LocallyClosed) => (),
|
||||
Err(ConnectionError::LocallyClosed) => (),
|
||||
Err(e) => panic!("unexpected error: {e}"),
|
||||
Ok(_) => {
|
||||
panic!("unexpected success");
|
||||
@@ -256,7 +256,7 @@ async fn ip_blocking() {
|
||||
.await
|
||||
.expect_err("server should have blocked this");
|
||||
assert!(
|
||||
matches!(e, crate::ConnectionError::ConnectionClosed(_)),
|
||||
matches!(e, ConnectionError::ConnectionClosed(_)),
|
||||
"wrong error"
|
||||
);
|
||||
},
|
||||
@@ -321,7 +321,7 @@ impl EndpointFactory {
|
||||
crate::ServerConfig::with_single_cert(vec![self.cert.cert.der().clone()], key).unwrap();
|
||||
server_config.transport_config(transport_config.clone());
|
||||
|
||||
let mut roots = rustls::RootCertStore::empty();
|
||||
let mut roots = RootCertStore::empty();
|
||||
roots.add(self.cert.cert.der().clone()).unwrap();
|
||||
let endpoint = Endpoint::new(
|
||||
self.endpoint_config.clone(),
|
||||
@@ -558,7 +558,7 @@ fn run_echo(args: EchoArgs) {
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
let mut roots = rustls::RootCertStore::empty();
|
||||
let mut roots = RootCertStore::empty();
|
||||
roots.add(cert).unwrap();
|
||||
let mut client_crypto =
|
||||
rustls::ClientConfig::builder_with_provider(default_provider().into())
|
||||
@@ -703,7 +703,7 @@ fn subscribe() -> tracing::subscriber::DefaultGuard {
|
||||
|
||||
struct TestWriter;
|
||||
|
||||
impl std::io::Write for TestWriter {
|
||||
impl io::Write for TestWriter {
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
print!(
|
||||
"{}",
|
||||
@@ -732,7 +732,7 @@ async fn rebind_recv() {
|
||||
let key = PrivatePkcs8KeyDer::from(cert.signing_key.serialize_der());
|
||||
let cert = CertificateDer::from(cert.cert);
|
||||
|
||||
let mut roots = rustls::RootCertStore::empty();
|
||||
let mut roots = RootCertStore::empty();
|
||||
roots.add(cert.clone()).unwrap();
|
||||
|
||||
let client = Endpoint::client(SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0)).unwrap();
|
||||
@@ -1098,7 +1098,7 @@ async fn test_multipath_observed_address() {
|
||||
// TODO(@divma): this is not fixed by removing the early check of remote CIDs, at least not
|
||||
// right now. Removing the check makes poll_transmit panic somewhere. So, eval removing
|
||||
// this sleep after the poll_transmit unwraps have been addressed
|
||||
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
let path = conn
|
||||
.open_path(FourTuple::from_remote(server_addr), PathStatus::Available)
|
||||
.await
|
||||
@@ -1860,7 +1860,7 @@ impl crate::runtime::Runtime for PanicPropagatingRuntime {
|
||||
self.tasks.lock().unwrap().spawn(future);
|
||||
}
|
||||
|
||||
fn wrap_udp_socket(&self, sock: std::net::UdpSocket) -> io::Result<Box<dyn AsyncUdpSocket>> {
|
||||
fn wrap_udp_socket(&self, sock: UdpSocket) -> io::Result<Box<dyn AsyncUdpSocket>> {
|
||||
TokioRuntime.wrap_udp_socket(sock)
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ fn connect_n_nodes_to_1_and_send_1mb_data() {
|
||||
|
||||
let expected_messages = 50;
|
||||
|
||||
let crc = crc::Crc::<u32>::new(&crc::CRC_32_ISO_HDLC);
|
||||
let crc = Crc::<u32>::new(&crc::CRC_32_ISO_HDLC);
|
||||
let shared2 = shared.clone();
|
||||
let endpoint2 = endpoint.clone();
|
||||
let read_incoming_data = async move {
|
||||
@@ -92,8 +92,8 @@ fn connect_n_nodes_to_1_and_send_1mb_data() {
|
||||
}
|
||||
}
|
||||
|
||||
async fn read_from_peer(mut stream: noq::RecvStream) -> Result<(), noq::ConnectionError> {
|
||||
let crc = crc::Crc::<u32>::new(&crc::CRC_32_ISO_HDLC);
|
||||
async fn read_from_peer(mut stream: noq::RecvStream) -> Result<(), ConnectionError> {
|
||||
let crc = Crc::<u32>::new(&crc::CRC_32_ISO_HDLC);
|
||||
match stream.read_to_end(1024 * 1024 * 5).await {
|
||||
Ok(data) => {
|
||||
assert!(hash_correct(&data, &crc));
|
||||
|
||||
+3
-3
@@ -121,7 +121,7 @@ impl Stats {
|
||||
#[cfg(feature = "json-output")]
|
||||
pub fn print_json(&self, path: &Path) -> io::Result<()> {
|
||||
if path == Path::new("-") {
|
||||
json::print(self, std::io::stdout());
|
||||
json::print(self, io::stdout());
|
||||
} else {
|
||||
let file = File::create(path)?;
|
||||
json::print(self, file)
|
||||
@@ -281,7 +281,7 @@ mod json {
|
||||
|
||||
fn serialize_timestamp<S>(time: &SystemTime, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
S: Serializer,
|
||||
{
|
||||
use serde::ser::SerializeMap;
|
||||
let mut state = s.serialize_map(Some(1))?;
|
||||
@@ -355,7 +355,7 @@ mod json {
|
||||
|
||||
impl Stream {
|
||||
fn from_stream_interval_stats(
|
||||
stats: &stats::StreamIntervalStats,
|
||||
stats: &StreamIntervalStats,
|
||||
period: &stats::IntervalPeriod,
|
||||
) -> Self {
|
||||
let bits_per_second = stats.bytes as f64 * 8.0 / period.seconds;
|
||||
|
||||
Reference in New Issue
Block a user