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 peers start conditions bug #1477

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/hat/p2p_peer/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ impl Network {
.get_transport_unicast(&zid)
.await
.is_none()
&& runtime.connect_peer(&zid, &locators).await
{
runtime.connect_peer(&zid, &locators).await;
runtime
.start_conditions()
.terminate_peer_connector_zid(zid)
Expand Down
12 changes: 8 additions & 4 deletions zenoh/src/net/runtime/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ impl Runtime {
}
}

/// Returns `true` if a new Transport instance has been opened with `zid`.
/// Returns `true` if a new Transport instance is established with `zid` or had already been established.
#[must_use]
async fn connect(&self, zid: &ZenohIdProto, scouted_locators: &[Locator]) -> bool {
if !self.insert_pending_connection(*zid).await {
Expand Down Expand Up @@ -1024,7 +1024,8 @@ impl Runtime {
}
}

pub async fn connect_peer(&self, zid: &ZenohIdProto, locators: &[Locator]) {
/// Returns `true` if a new Transport instance is established with `zid` or had already been established.
pub async fn connect_peer(&self, zid: &ZenohIdProto, locators: &[Locator]) -> bool {
OlivierHecart marked this conversation as resolved.
Show resolved Hide resolved
let manager = self.manager();
if zid != &manager.zid() {
let has_unicast = manager.get_transport_unicast(zid).await.is_some();
Expand All @@ -1042,10 +1043,13 @@ impl Runtime {

if !has_unicast && !has_multicast {
tracing::debug!("Try to connect to peer {} via any of {:?}", zid, locators);
let _ = self.connect(zid, locators).await;
self.connect(zid, locators).await
} else {
tracing::trace!("Already connected scouted peer: {}", zid);
true
}
} else {
true
}
}

Expand Down Expand Up @@ -1089,7 +1093,7 @@ impl Runtime {
) {
Runtime::scout(ucast_sockets, what, addr, move |hello| async move {
if !hello.locators.is_empty() {
self.connect_peer(&hello.zid, &hello.locators).await
self.connect_peer(&hello.zid, &hello.locators).await;
} else {
tracing::warn!("Received Hello with no locators: {:?}", hello);
}
Expand Down
Loading