diff --git a/io/zenoh-transport/src/unicast/transport.rs b/io/zenoh-transport/src/unicast/transport.rs index 18a0e44ebb..16f384afba 100644 --- a/io/zenoh-transport/src/unicast/transport.rs +++ b/io/zenoh-transport/src/unicast/transport.rs @@ -390,29 +390,21 @@ impl TransportUnicastInner { pub(crate) async fn close_link(&self, link: &LinkUnicast, reason: u8) -> ZResult<()> { log::trace!("Closing link {} with peer: {}", link, self.config.pid); - let guard = zread!(self.links); - if let Some(l) = zlinkget!(guard, link) { - let mut pipeline = l.pipeline.clone(); - // Drop the guard - drop(guard); - - // Schedule the close message for transmission - if let Some(pipeline) = pipeline.take() { - // Close message to be sent on the target link - let peer_id = Some(self.config.manager.pid()); - let reason_id = reason; - let link_only = true; // This is should always be true when closing a link - let attachment = None; // No attachment here - let msg = TransportMessage::make_close(peer_id, reason_id, link_only, attachment); - - pipeline.push_transport_message(msg, Priority::Background); - } + let mut pipeline = zlinkget!(zread!(self.links), link) + .map(|l| l.pipeline.clone()) + .ok_or_else(|| zerror!("Cannot close Link {:?}: not found", link))?; + if let Some(p) = pipeline.take() { + // Close message to be sent on the target link + let peer_id = Some(self.config.manager.pid()); + let reason_id = reason; + let link_only = true; // This is should always be true when closing a link + let attachment = None; // No attachment here + let msg = TransportMessage::make_close(peer_id, reason_id, link_only, attachment); - // Remove the link from the channel - self.del_link(link).await?; + p.push_transport_message(msg, Priority::Background); } - - Ok(()) + // Remove the link from the channel + self.del_link(link).await } pub(crate) async fn close(&self, reason: u8) -> ZResult<()> { diff --git a/zenoh-dragon.png b/zenoh-dragon.png index 96519e9e29..cb540e1070 100644 Binary files a/zenoh-dragon.png and b/zenoh-dragon.png differ diff --git a/zenoh/src/net/routing/network.rs b/zenoh/src/net/routing/network.rs index d66c3dcf76..9edbd15314 100644 --- a/zenoh/src/net/routing/network.rs +++ b/zenoh/src/net/routing/network.rs @@ -304,7 +304,7 @@ impl Network { } Some(( pid, - link_state.whatami.or(Some(WhatAmI::Router)).unwrap(), + link_state.whatami.unwrap_or(WhatAmI::Router), link_state.locators, link_state.sn, link_state.links, @@ -313,7 +313,7 @@ impl Network { match src_link.get_pid(&link_state.psid) { Some(pid) => Some(( *pid, - link_state.whatami.or(Some(WhatAmI::Router)).unwrap(), + link_state.whatami.unwrap_or(WhatAmI::Router), link_state.locators, link_state.sn, link_state.links, diff --git a/zenoh/src/net/runtime/orchestrator.rs b/zenoh/src/net/runtime/orchestrator.rs index 6144977e4b..d07c09ccf8 100644 --- a/zenoh/src/net/runtime/orchestrator.rs +++ b/zenoh/src/net/runtime/orchestrator.rs @@ -450,11 +450,9 @@ impl Runtime { #[allow(clippy::or_fun_call)] let local_addr = socket .local_addr() - .or::(Ok(SocketAddr::new(addr, 0).into())) - .unwrap() + .unwrap_or(SocketAddr::new(addr, 0).into()) .as_socket() - .or(Some(SocketAddr::new(addr, 0))) - .unwrap(); + .unwrap_or(SocketAddr::new(addr, 0)); log::debug!("UDP port bound to {}", local_addr); } Err(err) => { @@ -551,7 +549,7 @@ impl Runtime { if let Some(msg) = zbuf.reader().read_transport_message() { log::trace!("Received {:?} from {}", msg.body, peer); if let TransportBody::Hello(hello) = &msg.body { - let whatami = hello.whatami.or(Some(WhatAmI::Router)).unwrap(); + let whatami = hello.whatami.unwrap_or(WhatAmI::Router); if matcher.matches(whatami) { if let Loop::Break = f(hello.clone()).await { break;