headscale/hscontrol/mapper
Kristoffer Dalby 051a38a4c4 mapper/batcher: track worker goroutines and stop ticker on Close
Close() previously closed the done channel and returned immediately,
without waiting for worker goroutines to exit. This caused goroutine
leaks in tests and allowed workers to race with connection teardown.
The ticker was also never stopped, leaking its internal goroutine.

Add a sync.WaitGroup to track the doWork goroutine and every worker
it spawns. Close() now calls wg.Wait() after signalling shutdown,
ensuring all goroutines have exited before tearing down connections.
Also stop the ticker to prevent resource leaks.

Document that a Batcher must not be reused after Close().
2026-03-14 02:52:28 -07:00
..
batcher.go mapper/batcher: track worker goroutines and stop ticker on Close 2026-03-14 02:52:28 -07:00
batcher_bench_test.go mapper: remove Batcher interface, rename to Batcher struct 2026-03-14 02:52:28 -07:00
batcher_concurrency_test.go mapper: remove Batcher interface, rename to Batcher struct 2026-03-14 02:52:28 -07:00
batcher_scale_bench_test.go mapper/batcher: add scale benchmarks 2026-03-14 02:52:28 -07:00
batcher_test.go mapper: remove Batcher interface, rename to Batcher struct 2026-03-14 02:52:28 -07:00
batcher_unit_test.go mapper/batcher: add unit tests and benchmarks 2026-03-14 02:52:28 -07:00
builder.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
builder_test.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
mapper.go mapper: remove Batcher interface, rename to Batcher struct 2026-03-14 02:52:28 -07:00
mapper_test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
tail_test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00