From 2a3c4c1a33357414227d0100896251fb2df59560 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Tue, 29 Nov 2022 09:23:28 +0800 Subject: [PATCH] fix: ensure pool's dial pass to client --- transport/tuic/pool_client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transport/tuic/pool_client.go b/transport/tuic/pool_client.go index d4e25157..97e12053 100644 --- a/transport/tuic/pool_client.go +++ b/transport/tuic/pool_client.go @@ -22,6 +22,7 @@ type dialResult struct { type PoolClient struct { *ClientOption + newClientOption *ClientOption dialResultMap map[any]dialResult dialResultMutex *sync.Mutex tcpClients *list.List[*Client] @@ -100,7 +101,7 @@ func (t *PoolClient) newClient(udp bool, opts ...dialer.Option) *Client { clientsMutex.Lock() defer clientsMutex.Unlock() - client := NewClient(t.ClientOption, udp) + client := NewClient(t.newClientOption, udp) client.poolRef = t // make sure pool has a reference client.optionRef = o client.lastVisited = time.Now() @@ -169,6 +170,9 @@ func NewClientPool(clientOption *ClientOption) *PoolClient { udpClients: list.New[*Client](), udpClientsMutex: &sync.Mutex{}, } + newClientOption := *clientOption + newClientOption.DialFn = p.dial + p.newClientOption = &newClientOption runtime.SetFinalizer(p, closeClientPool) return p }