Skip to content

peerswapd: make shutdown signal delivery reliable - #456

Open
daixiheguu wants to merge 1 commit into
ElementsProject:masterfrom
daixiheguu:fix-buffered-signal-channel
Open

peerswapd: make shutdown signal delivery reliable#456
daixiheguu wants to merge 1 commit into
ElementsProject:masterfrom
daixiheguu:fix-buffered-signal-channel

Conversation

@daixiheguu

Copy link
Copy Markdown

Use a one-element buffered channel for process signals and unregister it with signal.Stop during shutdown.

os/signal.Notify does not block when delivering a signal, so an unbuffered channel can lose a signal when the receiver is not ready. The channel also should not be closed while it remains registered with os/signal, because a later delivery could panic.

This keeps the existing shutdown flow while making signal ownership and delivery safe.

Tested with:

go test ./cmd/peerswaplnd/peerswapd

Signed-off-by: daixiheguu <daixihegu@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant