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

Review tokio runtime being used #875

Merged
merged 3 commits into from
Apr 1, 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
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions commons/zenoh-macros/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn main() {
let version_rs = std::path::PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("version.rs");
let mut version_rs = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(version_rs)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-links/zenoh-link-tcp/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl LinkUnicastTrait for LinkUnicastTcp {
// impl Drop for LinkUnicastTcp {
// fn drop(&mut self) {
// // Close the underlying TCP socket
// zenoh_runtime::ZRuntime::TX.block_in_place(async {
// zenoh_runtime::ZRuntime::Acceptor.block_in_place(async {
// let _ = self.get_mut_socket().shutdown().await;
// });
// }
Expand Down
4 changes: 2 additions & 2 deletions io/zenoh-links/zenoh-link-tls/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ impl Drop for LinkUnicastTls {
fn drop(&mut self) {
// Close the underlying TCP stream
let (tcp_stream, _) = self.get_sock_mut().get_mut();
let _ =
zenoh_runtime::ZRuntime::TX.block_in_place(async move { tcp_stream.shutdown().await });
let _ = zenoh_runtime::ZRuntime::Acceptor
.block_in_place(async move { tcp_stream.shutdown().await });
}
}

Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-links/zenoh-link-unixsock_stream/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl LinkUnicastTrait for LinkUnicastUnixSocketStream {
impl Drop for LinkUnicastUnixSocketStream {
fn drop(&mut self) {
// Close the underlying UnixSocketStream socket
let _ = zenoh_runtime::ZRuntime::TX
let _ = zenoh_runtime::ZRuntime::Acceptor
.block_in_place(async move { self.get_mut_socket().shutdown().await });
}
}
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-links/zenoh-link-ws/src/unicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl LinkUnicastTrait for LinkUnicastWs {

impl Drop for LinkUnicastWs {
fn drop(&mut self) {
zenoh_runtime::ZRuntime::TX.block_in_place(async {
zenoh_runtime::ZRuntime::Acceptor.block_in_place(async {
let mut guard = zasynclock!(self.send);
// Close the underlying TCP socket
guard.close().await.unwrap_or_else(|e| {
Expand Down
4 changes: 2 additions & 2 deletions io/zenoh-transport/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ impl TransportManager {

// TODO(yuyuan): Can we make this async as above?
pub fn get_locators(&self) -> Vec<Locator> {
let mut lsu = zenoh_runtime::ZRuntime::TX.block_in_place(self.get_locators_unicast());
let mut lsm = zenoh_runtime::ZRuntime::TX.block_in_place(self.get_locators_multicast());
let mut lsu = zenoh_runtime::ZRuntime::Net.block_in_place(self.get_locators_unicast());
let mut lsm = zenoh_runtime::ZRuntime::Net.block_in_place(self.get_locators_multicast());
lsu.append(&mut lsm);
lsu
}
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-transport/src/unicast/universal/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl TransportLinkUnicastUniversal {
// to finish in the close() joining its handle
// TODO(yuyuan): do more study to check which ZRuntime should be used or refine the
// termination
zenoh_runtime::ZRuntime::TX
zenoh_runtime::ZRuntime::Net
.spawn(async move { transport.del_link(tx.inner.link()).await });
}
};
Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/src/publication_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'a> PublicationCache<'a> {
let token = TerminatableTask::create_cancellation_token();
let token2 = token.clone();
let task = TerminatableTask::spawn(
zenoh_runtime::ZRuntime::TX,
zenoh_runtime::ZRuntime::Application,
async move {
let mut cache: HashMap<OwnedKeyExpr, VecDeque<Sample>> =
HashMap::with_capacity(resources_limit.unwrap_or(32));
Expand Down
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 @@ -408,7 +408,7 @@ impl Network {

if !self.autoconnect.is_empty() {
// Connect discovered peers
if zenoh_runtime::ZRuntime::Net
if zenoh_runtime::ZRuntime::Acceptor
.block_in_place(strong_runtime.manager().get_transport_unicast(&zid))
.is_none()
&& self.autoconnect.matches(whatami)
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/scouting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ fn scout(
let cancellation_token = TerminatableTask::create_cancellation_token();
let cancellation_token_clone = cancellation_token.clone();
let task = TerminatableTask::spawn(
zenoh_runtime::ZRuntime::Net,
zenoh_runtime::ZRuntime::Acceptor,
async move {
let scout = Runtime::scout(&sockets, what, &addr, move |hello| {
let callback = callback.clone();
Expand Down
4 changes: 2 additions & 2 deletions zenoh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ impl Session {
// Cannot hold session lock when calling tables (matching_status())
// TODO: check which ZRuntime should be used
self.task_controller
.spawn_with_rt(zenoh_runtime::ZRuntime::RX, {
.spawn_with_rt(zenoh_runtime::ZRuntime::Net, {
let session = self.clone();
let msub = msub.clone();
async move {
Expand Down Expand Up @@ -1546,7 +1546,7 @@ impl Session {
// Cannot hold session lock when calling tables (matching_status())
// TODO: check which ZRuntime should be used
self.task_controller
.spawn_with_rt(zenoh_runtime::ZRuntime::RX, {
.spawn_with_rt(zenoh_runtime::ZRuntime::Net, {
let session = self.clone();
let msub = msub.clone();
async move {
Expand Down
3 changes: 1 addition & 2 deletions zenoh/tests/connection_retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ fn retry_config_overriding() {
.insert_json5("listen/exit_on_failure", "false")
.unwrap();

let expected = vec![
// global value
let expected = [
ConnectionRetryConf {
period_init_ms: 3000,
period_max_ms: 6000,
Expand Down