Fix shutdown signal handling in signer loop #409
Merged
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.
This PR is ported from breez/breez-sdk-greenlight#936
The original PR fixes an issue where
signer.run_once
can block for up to 10 minutes. This means that, if the signer was recently used, the signer loop would block on this call and disregard the shutdown signal for up to 10 minutes. The fix was to place the entire (inner) signer loop in atokio::select
, next to the shutdown signal handling.The first part of the signer loop (scheduler initialization and
maybe_upgrade
) was extracted to a separate method as well. This part is not affected by the shutdown signal.Note: in our version of the loop, we use
wait = false
, whereas here it istrue
. This could meanrun_once
behaves differently for you and might not block in the first place, but I'm not sure.