More waitgroup
This commit is contained in:
parent
35262a9e03
commit
8837065bca
1 changed files with 10 additions and 5 deletions
15
main.go
15
main.go
|
@ -143,12 +143,11 @@ func main() {
|
||||||
zones.Upsert(cfg.EtherTalk.NetStart, cfg.EtherTalk.ZoneName, true)
|
zones.Upsert(cfg.EtherTalk.NetStart, cfg.EtherTalk.ZoneName, true)
|
||||||
|
|
||||||
// -------------------------------- Peers ---------------------------------
|
// -------------------------------- Peers ---------------------------------
|
||||||
// Wait until all peer handlers have finished before closing the port
|
var wg sync.WaitGroup
|
||||||
var handlersWG sync.WaitGroup
|
|
||||||
goPeerHandler := func(p *router.Peer) {
|
goPeerHandler := func(p *router.Peer) {
|
||||||
handlersWG.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer handlersWG.Done()
|
defer wg.Done()
|
||||||
p.Handle(ctx)
|
p.Handle(ctx)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -241,7 +240,10 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------- Raw AppleTalk/AARP inbound ----------------------
|
// ---------------------- Raw AppleTalk/AARP inbound ----------------------
|
||||||
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
ctx, setStatus, done := status.AddSimpleItem(ctx, "EtherTalk inbound")
|
ctx, setStatus, done := status.AddSimpleItem(ctx, "EtherTalk inbound")
|
||||||
defer done()
|
defer done()
|
||||||
|
|
||||||
|
@ -366,7 +368,10 @@ func main() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// ----------------------------- AURP inbound -----------------------------
|
// ----------------------------- AURP inbound -----------------------------
|
||||||
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
ctx, setStatus, done := status.AddSimpleItem(ctx, "AURP inbound")
|
ctx, setStatus, done := status.AddSimpleItem(ctx, "AURP inbound")
|
||||||
defer done()
|
defer done()
|
||||||
setStatus("Running")
|
setStatus("Running")
|
||||||
|
@ -500,7 +505,7 @@ func main() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// -------------------------------- Close ---------------------------------
|
// -------------------------------- Close ---------------------------------
|
||||||
handlersWG.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hashable net.UDPAddr
|
// Hashable net.UDPAddr
|
||||||
|
|
Loading…
Reference in a new issue