You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes users might want to publish data inside the matching_listener callback. However, it might cause the deadlock.
While dropping the publisher, we will clean up the matching_listener. But if matching_listener holds a copy of publisher, the drop will not be triggered.
The only way here is to drop matching_listener explicitly, but I'm wondering there is a better solution to deal with this.
To reproduce
Here is the example:
use std::sync::Arc;use zenoh::{key_expr::KeyExpr,Wait};#[tokio::main]asyncfnmain(){let session = zenoh::open(zenoh::Config::default()).await.unwrap();let publisher = Arc::new(
session
.declare_publisher(KeyExpr::new("abc").unwrap()).await.unwrap(),);let matching_listener = publisher
.matching_listener().callback({let p = publisher.clone();move |_status| {println!("abc");
p.put("payload").wait().unwrap();}}).await.unwrap();// If we don't undeclare explicitly, the process will be stuck (deadlock)//matching_listener.undeclare().await.unwrap();println!("Should exit successfully....");}
Note that if we call matching_listener.undeclare().await.unwrap();, then everything goes well.
System info
Platform: Ubuntu 24.04
The text was updated successfully, but these errors were encountered:
Describe the bug
Sometimes users might want to publish data inside the matching_listener callback. However, it might cause the deadlock.
While dropping the publisher, we will clean up the matching_listener. But if matching_listener holds a copy of publisher, the drop will not be triggered.
The only way here is to drop matching_listener explicitly, but I'm wondering there is a better solution to deal with this.
To reproduce
Here is the example:
Note that if we call
matching_listener.undeclare().await.unwrap();
, then everything goes well.System info
The text was updated successfully, but these errors were encountered: