Skip to content

fix: channel-safety in StopWatch and signal handling#41

Merged
caiwl merged 1 commit into
masterfrom
caiwl/bugs/channel-safety
Jun 24, 2026
Merged

fix: channel-safety in StopWatch and signal handling#41
caiwl merged 1 commit into
masterfrom
caiwl/bugs/channel-safety

Conversation

@caiwl

@caiwl caiwl commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🤖 Generated with Claude Code

Three related send-on-closed-channel hazards:

1. file/etcd StopWatch sent on s.stop while the watch goroutine's defer
   closed it. On the panic-recovery exit path the channel could be closed
   before StopWatch ran, making the send panic. Now StopWatch closes s.stop
   (idempotent via stopOnce) and the goroutine defers no longer close it.
   For etcd this also wakes ALL inner watch goroutines (a single send only
   woke one, leaking the rest after a watch restart).

2. cmd main.go closed intChan after the first signal while signal.Notify was
   still registered; a second SIGINT/SIGTERM would panic. Replaced with
   signal.Stop(intChan).

Co-Authored-By: Claude <noreply@anthropic.com>
@caiwl caiwl merged commit f62d258 into master Jun 24, 2026
9 checks passed
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