Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
irvingoujAtDevolution committed Jan 11, 2024
1 parent d8365ad commit f04bb5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions crates/network-scanner/src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub struct BroadcastStream {
receiver: tokio::sync::mpsc::Receiver<anyhow::Result<(Vec<MaybeUninit<u8>>, SockAddr), std::io::Error>>,
verifier: Vec<u8>,
should_verify: bool,
handle: tokio::task::JoinHandle<anyhow::Result<()>>,
}

impl BroadcastStream {
Expand Down Expand Up @@ -115,7 +116,7 @@ pub async fn boardcast(ip: Ipv4Addr, read_time_out: Option<Duration>) -> anyhow:
.send_to(&packet.to_bytes(true), SockAddr::from(SocketAddr::new(ip.into(), 0)))
.await?;
let (sender, receiver) = tokio::sync::mpsc::channel(255);
tokio::task::spawn(async move {
let handle = tokio::task::spawn(async move {
let mut buffer = [MaybeUninit::uninit(); icmp_v4::ICMPV4_MTU];
loop {
let result = socket.recv_from(&mut buffer).await;
Expand All @@ -130,14 +131,16 @@ pub async fn boardcast(ip: Ipv4Addr, read_time_out: Option<Duration>) -> anyhow:
};

let buffer_copy = buffer[..size].as_ref().to_vec();
sender.send(Ok((buffer_copy, addr))).await.unwrap();
sender.send(Ok((buffer_copy, addr))).await?;
}
Ok::<(), anyhow::Error>(())
});

Ok(BroadcastStream {
receiver,
verifier,
should_verify: true,
handle,
})
}

Expand Down
2 changes: 1 addition & 1 deletion crates/network-scanner/src/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn blocking_ping(ip: Ipv4Addr) -> anyhow::Result<()> {
}
}

/// Assume the `buf`fer to be initialised.
/// Assume the `buf`fer to be initialized.
///
/// # Safety
///
Expand Down

0 comments on commit f04bb5e

Please sign in to comment.