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

Liveliness token are mistakenly undeclared #1320

Closed
YuanYuYuan opened this issue Aug 21, 2024 · 1 comment · Fixed by #1321
Closed

Liveliness token are mistakenly undeclared #1320

YuanYuYuan opened this issue Aug 21, 2024 · 1 comment · Fixed by #1321
Labels
bug Something isn't working

Comments

@YuanYuYuan
Copy link
Contributor

YuanYuYuan commented Aug 21, 2024

Describe the bug

A local liveliness token undeclaration will trigger the other token undeclaration in a chain reaction.

To reproduce

use zenoh::{prelude::*, Config};
use zenoh::sample::SampleKind;

#[tokio::main]
async fn main() {
    // Initiate logging
    zenoh::try_init_log_from_env();

    println!("Opening session...");
    let session = zenoh::open(Config::default()).await.unwrap();
    let subscriber = session
        .liveliness()
        // .declare_subscriber("@ros2_lv/0/**")
        .declare_subscriber("**")
        .callback(|sample| {
            match sample.kind() {
                SampleKind::Put => println!(
                    ">> [LivelinessSubscriber] New alive token ('{}')",
                    sample.key_expr().as_str()
                ),
                SampleKind::Delete => println!(
                    ">> [LivelinessSubscriber] Dropped token ('{}')",
                    sample.key_expr().as_str()
                ),
            }
        })
        .await
        .unwrap();

    // Create a node
    println!("Create a node");
    let node_token = session.liveliness().declare_token(format!("node")).await.unwrap();

    // Create a publisher
    println!("Create a publisher");
    let pub_token = session.liveliness().declare_token(format!("pub")).await.unwrap();

    // Create subscriber
    println!("Create a subscriber");
    let sub_token = session.liveliness().declare_token(format!("sub")).await.unwrap();

    // Destroy a publisher
    println!("Destroy a publisher");
    pub_token.undeclare().await.unwrap();

    println!("Press CTRL-C to undeclare LivelinessToken and quit...");
    std::thread::park();

    sub_token.undeclare().await.unwrap();
    node_token.undeclare().await.unwrap();
}
Opening session...
2024-08-21T14:44:26.656773Z  INFO main ThreadId(01) zenoh::net::runtime: Using ZID: 49758512d68759c06b8cce305e60b6ef
2024-08-21T14:44:26.658523Z  INFO main ThreadId(01) zenoh::net::runtime::orchestrator: Zenoh can be reached at: tcp/[fe80::694a:ae45:bf2b:33a0]:33891
2024-08-21T14:44:26.658551Z  INFO main ThreadId(01) zenoh::net::runtime::orchestrator: Zenoh can be reached at: tcp/192.168.1.140:33891
2024-08-21T14:44:26.658768Z  INFO main ThreadId(01) zenoh::net::runtime::orchestrator: zenohd listening scout messages on 224.0.0.224:7446
Create a node
>> [LivelinessSubscriber] New alive token ('node')
Create a publisher
>> [LivelinessSubscriber] New alive token ('pub')
Create a subscriber
>> [LivelinessSubscriber] New alive token ('sub')
Destroy a publisher
>> [LivelinessSubscriber] Dropped token ('pub')
>> [LivelinessSubscriber] Dropped token ('node')
>> [LivelinessSubscriber] Dropped token ('sub')
Press CTRL-C to undeclare LivelinessToken and quit...

System info

@YuanYuYuan YuanYuYuan added the bug Something isn't working label Aug 21, 2024
@OlivierHecart OlivierHecart linked a pull request Aug 21, 2024 that will close this issue
@Mallets
Copy link
Member

Mallets commented Aug 22, 2024

Closed by #1321

@Mallets Mallets closed this as completed Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants