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

Nolocal close #1632

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

yellowhatter
Copy link
Contributor

Implement close in the way it can be safely waited and awaited in atexit

@yellowhatter yellowhatter self-assigned this Dec 5, 2024
@yellowhatter yellowhatter added enhancement Existing things could work better release Part of the next release labels Dec 5, 2024
@yellowhatter yellowhatter marked this pull request as ready for review December 5, 2024 13:36
@yellowhatter yellowhatter requested a review from milyin December 5, 2024 13:36
@evshary
Copy link
Contributor

evshary commented Dec 10, 2024

It still failed when I tested with the following code

use std::sync::OnceLock;
use zenoh::{Config, Session, Wait};
static SESSION: OnceLock<Session> = OnceLock::new();

fn main() {
    let s = SESSION.get_or_init(|| zenoh::open(Config::default()).wait().unwrap());
    println!("> zid: {}", s.zid());
    unsafe { libc::atexit(close_session) };
}

extern "C" fn close_session() {
    SESSION.get().unwrap().close().wait().unwrap();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Existing things could work better release Part of the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants