More waitgroup

This commit is contained in:
Josh Deprez 2024-04-23 14:49:38 +10:00
parent 35262a9e03
commit 8837065bca
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

15
main.go
View file

@ -143,12 +143,11 @@ func main() {
zones.Upsert(cfg.EtherTalk.NetStart, cfg.EtherTalk.ZoneName, true)
// -------------------------------- Peers ---------------------------------
// Wait until all peer handlers have finished before closing the port
var handlersWG sync.WaitGroup
var wg sync.WaitGroup
goPeerHandler := func(p *router.Peer) {
handlersWG.Add(1)
wg.Add(1)
go func() {
defer handlersWG.Done()
defer wg.Done()
p.Handle(ctx)
}()
}
@ -241,7 +240,10 @@ func main() {
}
// ---------------------- Raw AppleTalk/AARP inbound ----------------------
wg.Add(1)
go func() {
defer wg.Done()
ctx, setStatus, done := status.AddSimpleItem(ctx, "EtherTalk inbound")
defer done()
@ -366,7 +368,10 @@ func main() {
}()
// ----------------------------- AURP inbound -----------------------------
wg.Add(1)
go func() {
defer wg.Done()
ctx, setStatus, done := status.AddSimpleItem(ctx, "AURP inbound")
defer done()
setStatus("Running")
@ -500,7 +505,7 @@ func main() {
}()
// -------------------------------- Close ---------------------------------
handlersWG.Wait()
wg.Wait()
}
// Hashable net.UDPAddr