XHTTP XMUX: Fix OpenUsage never gets reduced

Introduced in https://github.com/XTLS/Xray-core/pull/4163
This commit is contained in:
RPRX 2024-12-20 06:19:10 +00:00 committed by GitHub
parent cab2fdefd3
commit 1410b6335b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -372,7 +372,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
if xmuxClient2 != nil && xmuxClient2 != xmuxClient { if xmuxClient2 != nil && xmuxClient2 != xmuxClient {
xmuxClient2.OpenUsage.Add(1) xmuxClient2.OpenUsage.Add(1)
} }
var once atomic.Int32 var closed atomic.Int32
conn := splitConn{ conn := splitConn{
writer: writer, writer: writer,
@ -380,7 +380,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
remoteAddr: remoteAddr, remoteAddr: remoteAddr,
localAddr: localAddr, localAddr: localAddr,
onClose: func() { onClose: func() {
if once.Add(-1) < 0 { if closed.Add(1) > 1 {
return return
} }
if xmuxClient != nil { if xmuxClient != nil {