From 2aa6e81af9f5898faf5982452bd52f385b5b2220 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 13 Jun 2023 14:43:32 +0300 Subject: [PATCH] webrtc: fix rcmgr OpenConnection call claiming that it uses a fd --- p2p/test/transport/rcmgr_test.go | 6 +++--- p2p/transport/webrtc/transport.go | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/p2p/test/transport/rcmgr_test.go b/p2p/test/transport/rcmgr_test.go index 378d1f9bab..239e474db7 100644 --- a/p2p/test/transport/rcmgr_test.go +++ b/p2p/test/transport/rcmgr_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - gomock "github.com/golang/mock/gomock" + "github.com/golang/mock/gomock" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/network" mocknetwork "github.com/libp2p/go-libp2p/core/network/mocks" @@ -55,7 +55,7 @@ func TestResourceManagerIsUsed(t *testing.T) { } expectFd := true - if strings.Contains(tc.Name, "QUIC") || strings.Contains(tc.Name, "WebTransport") { + if strings.Contains(tc.Name, "QUIC") || strings.Contains(tc.Name, "WebTransport") || strings.Contains(tc.Name, "WebRTC") { expectFd = false } @@ -86,7 +86,7 @@ func TestResourceManagerIsUsed(t *testing.T) { } return nil }) - connScope.EXPECT().Done() + connScope.EXPECT().Done().MinTimes(1) var allStreamsDone sync.WaitGroup diff --git a/p2p/transport/webrtc/transport.go b/p2p/transport/webrtc/transport.go index c3e13605c9..5ec3938d32 100644 --- a/p2p/transport/webrtc/transport.go +++ b/p2p/transport/webrtc/transport.go @@ -214,12 +214,11 @@ func (t *WebRTCTransport) listenSocket(socket *net.UDPConn) (tpt.Listener, error } func (t *WebRTCTransport) Dial(ctx context.Context, remoteMultiaddr ma.Multiaddr, p peer.ID) (tpt.CapableConn, error) { - scope, err := t.rcmgr.OpenConnection(network.DirOutbound, true, remoteMultiaddr) + scope, err := t.rcmgr.OpenConnection(network.DirOutbound, false, remoteMultiaddr) if err != nil { return nil, err } - err = scope.SetPeer(p) - if err != nil { + if err := scope.SetPeer(p); err != nil { scope.Done() return nil, err }