From 1410b6335ba81aaa20f6cf460ec640501b968cef Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 20 Dec 2024 06:19:10 +0000 Subject: [PATCH] XHTTP XMUX: Fix OpenUsage never gets reduced Introduced in https://github.com/XTLS/Xray-core/pull/4163 --- transport/internet/splithttp/dialer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index cc792a1f..c0189d58 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -372,7 +372,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if xmuxClient2 != nil && xmuxClient2 != xmuxClient { xmuxClient2.OpenUsage.Add(1) } - var once atomic.Int32 + var closed atomic.Int32 conn := splitConn{ writer: writer, @@ -380,7 +380,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me remoteAddr: remoteAddr, localAddr: localAddr, onClose: func() { - if once.Add(-1) < 0 { + if closed.Add(1) > 1 { return } if xmuxClient != nil {