Problem
Startup can deadlock when C_Connect registers event handlers while holding the lifecycle mutex and the production registration callback calls clientSnapshot, which re-enters that mutex.
Proposed solution
Coordinate once-only registration under the lifecycle mutex, execute the registration callback outside it, and allow a panic to reset registration so a later attempt can retry. Add bounded behavior and concurrency regression coverage.
Acceptance criteria
- Registration callbacks never execute while the lifecycle mutex is held.
- Concurrent callers register handlers exactly once.
- A panicking registration does not permanently mark handlers as registered.
- Focused Go tests,
go test ./..., go vet ./..., formatting, and whitespace checks pass.
Problem
Startup can deadlock when
C_Connectregisters event handlers while holding the lifecycle mutex and the production registration callback callsclientSnapshot, which re-enters that mutex.Proposed solution
Coordinate once-only registration under the lifecycle mutex, execute the registration callback outside it, and allow a panic to reset registration so a later attempt can retry. Add bounded behavior and concurrency regression coverage.
Acceptance criteria
go test ./...,go vet ./..., formatting, and whitespace checks pass.