Compare commits

..

2 Commits

Author SHA1 Message Date
Remember
3540910879 fix(backoff): close of closed out channel (#3871)
* fix: close of closed channel

* feat: replace Try0 to std
2023-12-21 11:43:42 +08:00
fatedier
2d67e2e0c6 remove copilot for pr (#3857) 2023-12-18 10:53:02 +08:00
2 changed files with 8 additions and 10 deletions

View File

@@ -1,6 +1,3 @@
### Summary
copilot:summary
### WHY
<!-- author to complete -->

View File

@@ -16,10 +16,9 @@ package wait
import (
"math/rand"
"sync"
"time"
"github.com/samber/lo"
"github.com/fatedier/frp/pkg/util/util"
)
@@ -182,16 +181,18 @@ func Until(f func(), period time.Duration, stopCh <-chan struct{}) {
func MergeAndCloseOnAnyStopChannel[T any](upstreams ...<-chan T) <-chan T {
out := make(chan T)
closeOnce := sync.Once{}
for _, upstream := range upstreams {
ch := upstream
go lo.Try0(func() {
go func() {
select {
case <-ch:
close(out)
closeOnce.Do(func() {
close(out)
})
case <-out:
}
})
}()
}
return out
}