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

Workaround to fix concurrent transport init bug #1528

Merged
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 io/zenoh-transport/src/unicast/lowlatency/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl TransportUnicastTrait for TransportUnicastLowlatency {
self.internal_start_rx(other_lease);
});

Ok((start_tx, start_rx, ack))
Ok((start_tx, start_rx, ack, None))
}

/*************************************/
Expand Down
22 changes: 13 additions & 9 deletions io/zenoh-transport/src/unicast/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ impl TransportManager {
}

// Add the link to the transport
let (start_tx, start_rx, ack) = transport
let (start_tx, start_rx, ack, add_link_guard) = transport
.add_link(link, other_initial_sn, other_lease)
.await
.map_err(InitTransportError::Link)?;
Expand All @@ -469,6 +469,8 @@ impl TransportManager {

start_rx();

drop(add_link_guard);

Ok(transport)
}

Expand Down Expand Up @@ -556,14 +558,14 @@ impl TransportManager {
};

// Add the link to the transport
let (start_tx, start_rx, ack) = match t.add_link(link, other_initial_sn, other_lease).await
{
Ok(val) => val,
Err(e) => {
let _ = t.close(e.2).await;
return Err(InitTransportError::Link(e));
}
};
let (start_tx, start_rx, ack, add_link_guard) =
match t.add_link(link, other_initial_sn, other_lease).await {
Ok(val) => val,
Err(e) => {
let _ = t.close(e.2).await;
return Err(InitTransportError::Link(e));
}
};

macro_rules! transport_error {
($s:expr, $reason:expr) => {
Expand Down Expand Up @@ -597,6 +599,8 @@ impl TransportManager {

start_rx();

drop(add_link_guard);

zcondfeat!(
"shared-memory",
{
Expand Down
1 change: 1 addition & 0 deletions io/zenoh-transport/src/unicast/transport_unicast_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub(crate) type AddLinkResult<'a> = Result<
Box<dyn FnOnce() + Send + Sync + 'a>,
Box<dyn FnOnce() + Send + Sync + 'a>,
MaybeOpenAck,
Option<AsyncMutexGuard<'a, ()>>,
),
LinkError,
>;
Expand Down
3 changes: 1 addition & 2 deletions io/zenoh-transport/src/unicast/universal/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ impl TransportUnicastTrait for TransportUnicastUniversal {
*guard = links.into_boxed_slice();

drop(guard);
drop(add_link_guard);

// create a callback to start the link
let transport = self.clone();
Expand All @@ -307,7 +306,7 @@ impl TransportUnicastTrait for TransportUnicastUniversal {
link.start_rx(transport, other_lease);
});

Ok((start_tx, start_rx, ack))
Ok((start_tx, start_rx, ack, Some(add_link_guard)))
}

/*************************************/
Expand Down