sign: eliminate TSA response deadlocks, send-on-closed-channel panics, and invalid --max values #2
Labels
No labels
nagonag
nagonag/ignore
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
heiko/mailseal#2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The response fan-out/fan-in logic in
sign.gocounts all entries inTSAs, but starts one goroutine only for entries whose boolean is true:Consequences:
--maxis validated against total map entries, not enabled endpoints. Zero and negative values are accepted and have nonsensical/nonterminating behavior.defer close(timestamps)and may return after enough successes while slower senders are still active; a later send can panic.Checklist: #62 (goroutines need a stop plan), #67 (channel sizing/ownership), #73 (structured goroutine groups).
Proposed fix
enabled []tsaConfigfirst.--max < 1and--max > len(enabled)before launching work.WaitGroup/errgroupand close the results channel only after all senders finish.--maxsuccesses, return an aggregate error rather than blocking.Acceptance criteria
--max=0, negative values, and values above the enabled count fail immediately.go test -race).Reviewed against
948b7a9onmaster(Go 1.26.2).Signing now emits exactly
--maxsuccesses: the accept loop breaks at--max, cancels the request context, and waits for the cancelled workers before returning. Full acceptance matrix covered (all-fail, mixed, early-success/slow-worker, cancellation,--max0/negative/over-count, race).Closing commit:
2a8c44613f5cNote: currently on local
masteronly; the link resolves once these commits are pushed (origin/masteris still at948b7a9).