mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-13 09:06:41 +00:00
reverseproxy: use sync.WaitGroup.Go in WebTransport pump
Replace the wg.Add(6) + six "go func() { defer wg.Done(); fn() }()"
calls with sync.WaitGroup.Go (Go 1.25+, the project's minimum
version). Same number of goroutines; less boilerplate.
This commit is contained in:
parent
04dff423b3
commit
4899e53c2d
1 changed files with 6 additions and 7 deletions
|
|
@ -57,19 +57,18 @@ type webtransportPump struct {
|
|||
|
||||
func (p *webtransportPump) run() {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(6)
|
||||
|
||||
// Bidirectional streams in both directions.
|
||||
go func() { defer wg.Done(); p.acceptBidi(p.client, p.upstream, p.closeUpstream) }()
|
||||
go func() { defer wg.Done(); p.acceptBidi(p.upstream, p.client, p.closeClient) }()
|
||||
wg.Go(func() { p.acceptBidi(p.client, p.upstream, p.closeUpstream) })
|
||||
wg.Go(func() { p.acceptBidi(p.upstream, p.client, p.closeClient) })
|
||||
|
||||
// Unidirectional streams in both directions.
|
||||
go func() { defer wg.Done(); p.acceptUni(p.client, p.upstream, p.closeUpstream) }()
|
||||
go func() { defer wg.Done(); p.acceptUni(p.upstream, p.client, p.closeClient) }()
|
||||
wg.Go(func() { p.acceptUni(p.client, p.upstream, p.closeUpstream) })
|
||||
wg.Go(func() { p.acceptUni(p.upstream, p.client, p.closeClient) })
|
||||
|
||||
// Datagrams in both directions.
|
||||
go func() { defer wg.Done(); p.pumpDatagrams(p.client, p.upstream, p.closeUpstream) }()
|
||||
go func() { defer wg.Done(); p.pumpDatagrams(p.upstream, p.client, p.closeClient) }()
|
||||
wg.Go(func() { p.pumpDatagrams(p.client, p.upstream, p.closeUpstream) })
|
||||
wg.Go(func() { p.pumpDatagrams(p.upstream, p.client, p.closeClient) })
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue