mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-12-18 13:14:36 +03:00
Clear preConns in defer
Some checks failed
Build and Release for Windows 7 / check-assets (push) Has been cancelled
Build and Release for Windows 7 / build (win7-32, 386, windows) (push) Has been cancelled
Build and Release for Windows 7 / build (win7-64, amd64, windows) (push) Has been cancelled
Build and Release / check-assets (push) Has been cancelled
Build and Release / build (386, freebsd, ) (push) Has been cancelled
Build and Release / build (386, linux, ) (push) Has been cancelled
Build and Release / build (386, openbsd, ) (push) Has been cancelled
Build and Release / build (386, windows, ) (push) Has been cancelled
Build and Release / build (amd64, android, android-amd64) (push) Has been cancelled
Build and Release / build (amd64, darwin, ) (push) Has been cancelled
Build and Release / build (amd64, freebsd, ) (push) Has been cancelled
Build and Release / build (amd64, linux, ) (push) Has been cancelled
Build and Release / build (amd64, openbsd, ) (push) Has been cancelled
Build and Release / build (amd64, windows, ) (push) Has been cancelled
Build and Release / build (arm, 5, linux) (push) Has been cancelled
Build and Release / build (arm, 6, linux) (push) Has been cancelled
Build and Release / build (arm, 7, freebsd) (push) Has been cancelled
Build and Release / build (arm, 7, linux) (push) Has been cancelled
Build and Release / build (arm, 7, openbsd) (push) Has been cancelled
Build and Release / build (arm, 7, windows) (push) Has been cancelled
Build and Release / build (arm64, android) (push) Has been cancelled
Build and Release / build (arm64, darwin) (push) Has been cancelled
Build and Release / build (arm64, freebsd) (push) Has been cancelled
Build and Release / build (arm64, linux) (push) Has been cancelled
Build and Release / build (arm64, openbsd) (push) Has been cancelled
Build and Release / build (arm64, windows) (push) Has been cancelled
Build and Release / build (loong64, linux) (push) Has been cancelled
Build and Release / build (mips, linux) (push) Has been cancelled
Build and Release / build (mips64, linux) (push) Has been cancelled
Build and Release / build (mips64le, linux) (push) Has been cancelled
Build and Release / build (mipsle, linux) (push) Has been cancelled
Build and Release / build (ppc64, linux) (push) Has been cancelled
Build and Release / build (ppc64le, linux) (push) Has been cancelled
Build and Release / build (riscv64, linux) (push) Has been cancelled
Build and Release / build (s390x, linux) (push) Has been cancelled
Test / check-assets (push) Has been cancelled
Test / test (macos-latest) (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
Test / test (windows-latest) (push) Has been cancelled
Some checks failed
Build and Release for Windows 7 / check-assets (push) Has been cancelled
Build and Release for Windows 7 / build (win7-32, 386, windows) (push) Has been cancelled
Build and Release for Windows 7 / build (win7-64, amd64, windows) (push) Has been cancelled
Build and Release / check-assets (push) Has been cancelled
Build and Release / build (386, freebsd, ) (push) Has been cancelled
Build and Release / build (386, linux, ) (push) Has been cancelled
Build and Release / build (386, openbsd, ) (push) Has been cancelled
Build and Release / build (386, windows, ) (push) Has been cancelled
Build and Release / build (amd64, android, android-amd64) (push) Has been cancelled
Build and Release / build (amd64, darwin, ) (push) Has been cancelled
Build and Release / build (amd64, freebsd, ) (push) Has been cancelled
Build and Release / build (amd64, linux, ) (push) Has been cancelled
Build and Release / build (amd64, openbsd, ) (push) Has been cancelled
Build and Release / build (amd64, windows, ) (push) Has been cancelled
Build and Release / build (arm, 5, linux) (push) Has been cancelled
Build and Release / build (arm, 6, linux) (push) Has been cancelled
Build and Release / build (arm, 7, freebsd) (push) Has been cancelled
Build and Release / build (arm, 7, linux) (push) Has been cancelled
Build and Release / build (arm, 7, openbsd) (push) Has been cancelled
Build and Release / build (arm, 7, windows) (push) Has been cancelled
Build and Release / build (arm64, android) (push) Has been cancelled
Build and Release / build (arm64, darwin) (push) Has been cancelled
Build and Release / build (arm64, freebsd) (push) Has been cancelled
Build and Release / build (arm64, linux) (push) Has been cancelled
Build and Release / build (arm64, openbsd) (push) Has been cancelled
Build and Release / build (arm64, windows) (push) Has been cancelled
Build and Release / build (loong64, linux) (push) Has been cancelled
Build and Release / build (mips, linux) (push) Has been cancelled
Build and Release / build (mips64, linux) (push) Has been cancelled
Build and Release / build (mips64le, linux) (push) Has been cancelled
Build and Release / build (mipsle, linux) (push) Has been cancelled
Build and Release / build (ppc64, linux) (push) Has been cancelled
Build and Release / build (ppc64le, linux) (push) Has been cancelled
Build and Release / build (riscv64, linux) (push) Has been cancelled
Build and Release / build (s390x, linux) (push) Has been cancelled
Test / check-assets (push) Has been cancelled
Test / test (macos-latest) (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
Test / test (windows-latest) (push) Has been cancelled
This commit is contained in:
@@ -121,10 +121,6 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
|
|||||||
func (h *Handler) Close() error {
|
func (h *Handler) Close() error {
|
||||||
if h.preConnStop != nil {
|
if h.preConnStop != nil {
|
||||||
close(h.preConnStop)
|
close(h.preConnStop)
|
||||||
for range h.testpre {
|
|
||||||
conn := <-h.preConns
|
|
||||||
common.CloseIfExists(conn)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if h.reverse != nil {
|
if h.reverse != nil {
|
||||||
return h.reverse.Close()
|
return h.reverse.Close()
|
||||||
@@ -147,6 +143,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|||||||
if h.testpre > 0 && h.reverse == nil {
|
if h.testpre > 0 && h.reverse == nil {
|
||||||
h.initConns.Do(func() {
|
h.initConns.Do(func() {
|
||||||
h.preConns = make(chan stat.Connection, h.testpre)
|
h.preConns = make(chan stat.Connection, h.testpre)
|
||||||
|
h.preConnWait = make(chan struct{})
|
||||||
h.preConnStop = make(chan struct{})
|
h.preConnStop = make(chan struct{})
|
||||||
go h.preConnWorker(dialer, rec.Destination)
|
go h.preConnWorker(dialer, rec.Destination)
|
||||||
})
|
})
|
||||||
@@ -472,7 +469,13 @@ func (h *Handler) preConnWorker(dialer internet.Dialer, dest net.Destination) {
|
|||||||
errors.LogError(context.Background(), "failed to dial VLESS pre connection: ", err)
|
errors.LogError(context.Background(), "failed to dial VLESS pre connection: ", err)
|
||||||
common.CloseIfExists(conn)
|
common.CloseIfExists(conn)
|
||||||
}
|
}
|
||||||
conns <- conn
|
select {
|
||||||
|
case <-h.preConnStop:
|
||||||
|
common.CloseIfExists(conn)
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
conns <- conn
|
||||||
|
}
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
go dial() // get a conn immediately
|
go dial() // get a conn immediately
|
||||||
@@ -485,6 +488,16 @@ func (h *Handler) preConnWorker(dialer internet.Dialer, dest net.Destination) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
defer func() {
|
||||||
|
close(h.preConns)
|
||||||
|
for {
|
||||||
|
conn, ok := <-h.preConns
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
common.CloseIfExists(conn)
|
||||||
|
}
|
||||||
|
}()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case conn := <-conns:
|
case conn := <-conns:
|
||||||
|
|||||||
Reference in New Issue
Block a user