I'm trying to integrate rust-jack into my iced app. Unfortunately I ran into a problem with handling the case if the jack server shuts down. I have created a minimal example here: rust_jack_threading/src/main.rs at main · kunerd/rust_jack_threading · GitHub.
The ConnectionLost message is send, but after that the line from the link doesn't get executed.
edit 1
The shutdown callback needs to fulfill these requirements: signal-safety(7) - Linux manual page
I don't know if the usage of a channel in there violates these. Maybe someone has an idea about this.
edit 2
I have updated the code to use the async-signal-safe channel from signal_hook crate, but it still doesn't work. I guess there is something wrong with my thread organization.
Please feel free to throw any idea in, even if it doesn't directly solve the problem.
edit 3
I could reproduce the problem with a stripped down version and even without the shutdown signal handler involved. The root seems to be in async_client.deactivate() which hangs if called, after the server has been shut down.
I can get rid of the deadlock by explicitly dropping the mutex guard before this return is called:
I hope someone could explain this in more detail, so that I eventually could provide an PR.
edit
I think it deadlocks because cb, which is holding client is dropped when returning. The drop impl of client itself tries to lock and bang...deadlock. This probably needs some refactoring.
It would be nice if someone with more knowledge in this field could confirm my assumption.