Skip to content

Commit

Permalink
fix names
Browse files Browse the repository at this point in the history
  • Loading branch information
keepsimple1 committed Aug 18, 2024
1 parent e7b2f57 commit 4e7c598
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/service_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ impl ServiceDaemon {

// Read until no more packets available.
let intf = match zc.poll_ids.get(&ev.key) {
Some(ip) => ip.clone(),
Some(interface) => interface.clone(),
None => {
error!("Ip for event key {} not found", ev.key);
break;
Expand Down Expand Up @@ -900,7 +900,7 @@ struct Zeroconf {
/// Local interfaces with sockets to recv/send on these interfaces.
intf_socks: HashMap<Interface, IntfSock>,

/// Map poll id to IpAddr
/// Map poll id to Interface.
poll_ids: HashMap<usize, Interface>,

/// Next poll id value
Expand Down Expand Up @@ -963,15 +963,14 @@ impl Zeroconf {
let sock = match new_socket_bind(&intf) {
Ok(s) => s,
Err(e) => {
error!("bind a socket to {}: {}. Skipped.", &intf.ip(), e);
debug!("bind a socket to {}: {}. Skipped.", &intf.ip(), e);
continue;
}
};

intf_socks.insert(intf.clone(), IntfSock { intf, sock });
}

println!("intf socket: {}", intf_socks.len());
let monitors = Vec::new();
let service_name_len_max = SERVICE_NAME_LEN_MAX_DEFAULT;

Expand Down Expand Up @@ -1062,21 +1061,21 @@ impl Zeroconf {
}
}

/// Insert a new IP into the poll map and return key
fn add_poll(&mut self, ip: Interface) -> usize {
Self::add_poll_impl(&mut self.poll_ids, &mut self.poll_id_count, ip)
/// Insert a new interface into the poll map and return key
fn add_poll(&mut self, intf: Interface) -> usize {
Self::add_poll_impl(&mut self.poll_ids, &mut self.poll_id_count, intf)
}

/// Insert a new IP into the poll map and return key
/// Insert a new interface into the poll map and return key
/// This exist to satisfy the borrow checker
fn add_poll_impl(
poll_ids: &mut HashMap<usize, Interface>,
poll_id_count: &mut usize,
ip: Interface,
intf: Interface,
) -> usize {
let key = *poll_id_count;
*poll_id_count += 1;
let _ = (*poll_ids).insert(key, ip);
let _ = (*poll_ids).insert(key, intf);
key
}

Expand Down Expand Up @@ -1855,8 +1854,8 @@ impl Zeroconf {
}

/// Handle incoming query packets, figure out whether and what to respond.
fn handle_query(&mut self, msg: DnsIncoming, ip: &Interface) {
let intf_sock = match self.intf_socks.get(ip) {
fn handle_query(&mut self, msg: DnsIncoming, intf: &Interface) {
let intf_sock = match self.intf_socks.get(intf) {
Some(sock) => sock,
None => return,
};
Expand Down
2 changes: 1 addition & 1 deletion tests/mdns_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn integration_success() {
let mut unique_intf_idx_ip_ver_set = HashSet::new();
let mut non_idx_count = 0;
for intf in all_interfaces.iter() {
println!("intf:: {:?}", intf);
// println!("intf:: {:?}", intf);
let ip_ver = match intf.addr {
IfAddr::V4(_) => 4u8,
IfAddr::V6(_) => 6u8,
Expand Down

0 comments on commit 4e7c598

Please sign in to comment.