Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
don't get the stream scope here
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jan 2, 2022
1 parent 1e9d065 commit 5e8e177
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
18 changes: 2 additions & 16 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
type conn struct {
sess quic.Session
transport tpt.Transport
rcmgr network.ResourceManager
scope network.ConnectionManagementScope

localPeer peer.ID
Expand All @@ -31,6 +30,7 @@ type conn struct {
var _ tpt.CapableConn = &conn{}

func (c *conn) Close() error {
defer c.scope.Done()
return c.sess.CloseWithError(0, "")
}

Expand All @@ -41,28 +41,14 @@ func (c *conn) IsClosed() bool {

// OpenStream creates a new stream.
func (c *conn) OpenStream(ctx context.Context) (mux.MuxedStream, error) {
scope, err := c.rcmgr.OpenStream(c.remotePeerID, network.DirOutbound)
if err != nil {
return nil, err
}
qstr, err := c.sess.OpenStreamSync(ctx)
if err != nil {
scope.Done()
return nil, err
}
return &stream{Stream: qstr}, err
}

// AcceptStream accepts a stream opened by the other side.
func (c *conn) AcceptStream() (mux.MuxedStream, error) {
qstr, err := c.sess.AcceptStream(context.Background())
if err != nil {
return nil, err
}
if _, err := c.rcmgr.OpenStream(c.remotePeerID, network.DirInbound); err != nil {
return nil, err
}
return &stream{Stream: qstr}, nil
return &stream{Stream: qstr}, err
}

// LocalPeer returns our peer ID
Expand Down
1 change: 0 additions & 1 deletion listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func (l *listener) setupConn(sess quic.Session) (*conn, error) {
return &conn{
sess: sess,
transport: l.transport,
rcmgr: l.rcmgr,
scope: connScope,
localPeer: l.localPeer,
localMultiaddr: l.localMultiaddr,
Expand Down
1 change: 0 additions & 1 deletion transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ func (t *transport) Dial(ctx context.Context, raddr ma.Multiaddr, p peer.ID) (tp
conn := &conn{
sess: sess,
transport: t,
rcmgr: t.rcmgr,
scope: scope,
privKey: t.privKey,
localPeer: t.localPeer,
Expand Down

0 comments on commit 5e8e177

Please sign in to comment.