mirror of
https://github.com/fatedier/frp.git
synced 2025-04-23 08:41:26 +00:00
Fix goroutine leaks
This commit is contained in:
parent
93289aab03
commit
881f21431d
@ -17,6 +17,7 @@ package proxy
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"github.com/fatedier/golib/errors"
|
||||
|
||||
@ -33,6 +34,7 @@ type XTCPProxy struct {
|
||||
cfg *v1.XTCPProxyConfig
|
||||
|
||||
closeCh chan struct{}
|
||||
closeOnce sync.Once
|
||||
}
|
||||
|
||||
func NewXTCPProxy(baseProxy *BaseProxy) Proxy {
|
||||
@ -90,7 +92,9 @@ func (pxy *XTCPProxy) Run() (remoteAddr string, err error) {
|
||||
func (pxy *XTCPProxy) Close() {
|
||||
pxy.BaseProxy.Close()
|
||||
pxy.rc.NatHoleController.CloseClient(pxy.GetName())
|
||||
pxy.closeOnce.Do(func() {
|
||||
_ = errors.PanicToError(func() {
|
||||
close(pxy.closeCh)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user