Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug that upload speed is not tabulated correctly #116

Merged
merged 1 commit into from
Jan 14, 2020
Merged
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
27 changes: 20 additions & 7 deletions src/os/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,28 @@ pub fn get_input(

let network_frames = network_interfaces
.iter()
.map(|iface| get_datalink_channel(iface));

let available_network_frames = network_frames
.clone()
.filter_map(Result::ok)
.collect::<Vec<_>>();
.filter(|iface| iface.is_up() && !iface.ips.is_empty())
.map(|iface| (iface, get_datalink_channel(iface)));

let (available_network_frames, network_interfaces) = {
let network_frames = network_frames.clone();
let mut available_network_frames = Vec::new();
let mut available_interfaces: Vec<NetworkInterface> = Vec::new();
for (iface, rx) in network_frames.filter_map(|(iface, channel)| {
if let Ok(rx) = channel {
Some((iface, rx))
} else {
None
}
}) {
available_interfaces.push(iface.clone());
available_network_frames.push(rx);
}
(available_network_frames, available_interfaces)
};

if available_network_frames.is_empty() {
for iface in network_frames {
for (_, iface) in network_frames {
if let Some(iface_error) = iface.err() {
if let ErrorKind::PermissionDenied = iface_error.kind() {
failure::bail!(eperm_message())
Expand Down