Skip to content

Commit

Permalink
webrtc: fix rcmgr OpenConnection call claiming that it uses a fd
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jun 15, 2023
1 parent 461181e commit 1e17e0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions p2p/test/transport/rcmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -86,7 +86,7 @@ func TestResourceManagerIsUsed(t *testing.T) {
}
return nil
})
connScope.EXPECT().Done()
connScope.EXPECT().Done().MinTimes(1)

var allStreamsDone sync.WaitGroup

Expand Down
5 changes: 2 additions & 3 deletions p2p/transport/webrtc/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1e17e0b

Please sign in to comment.