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