Repository navigation
cln-plugin: fix missed-wakeup deadlock in Plugin::join and Plugin::shutdown - #9757
Open
daywalker90 wants to merge 1 commit into
Open
daywalker90 wants to merge 1 commit into
daywalker90 wants to merge 1 commit into
Conversation
…:shutdown` `Plugin::wait_handle` used a `tokio::sync::broadcast::Sender<()>` with its initial receiver immediately dropped. If `PluginDriver::run` exited or `Plugin::shutdown()` was called before the caller reached `Plugin::join()`, `broadcast::Sender::send(())` failed with zero receivers and dropped the signal; subsequent `Plugin::join()` calls then hung indefinitely because `Plugin` itself still held the `Sender`. In addition, `PluginDriver::run` never observed `wait_handle`, so `Plugin::shutdown()` did not stop the driver loop. Replace the broadcast channel with a `tokio::sync::watch::Sender<bool>` (updated via `send_replace(true)`), drop a guard on driver exit so the state is always flipped even on unwind, and select on the watch channel in `PluginDriver::run` so `shutdown()` stops the driver loop cleanly. Add unit tests covering `join()` after driver exit, `shutdown()` before `join()`, and `shutdown()` waking a waiting `join()`. Changelog-Fixed: cln-plugin: fix missed-wakeup deadlock in `Plugin::join()` and make `Plugin::shutdown()` reliably stop the driver loop.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plugin::wait_handleused atokio::sync::broadcast::Sender<()>withits initial receiver immediately dropped. If
PluginDriver::runexitedor
Plugin::shutdown()was called before the caller reachedPlugin::join(),broadcast::Sender::send(())failed with zeroreceivers and dropped the signal; subsequent
Plugin::join()calls thenhung indefinitely because
Pluginitself still held theSender. Inaddition,
PluginDriver::runnever observedwait_handle, soPlugin::shutdown()did not stop the driver loop.Replace the broadcast channel with a
tokio::sync::watch::Sender<bool>(updated via
send_replace(true)), drop a guard on driver exit so thestate is always flipped even on unwind, and select on the watch channel
in
PluginDriver::runsoshutdown()stops the driver loop cleanly.Add unit tests covering
join()after driver exit,shutdown()beforejoin(), andshutdown()waking a waitingjoin().Changelog-Fixed: cln-plugin: fix missed-wakeup deadlock in
Plugin::join()and makePlugin::shutdown()reliably stop the driver loop.