Commit 2a7f53f7 authored by rht's avatar rht
Browse files

Use WithContextAndTeardown whenever possible



License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent 316ba886
...@@ -158,9 +158,8 @@ func Listen(ctx context.Context, addr ma.Multiaddr, local peer.ID, sk ic.PrivKey ...@@ -158,9 +158,8 @@ func Listen(ctx context.Context, addr ma.Multiaddr, local peer.ID, sk ic.PrivKey
Listener: ml, Listener: ml,
local: local, local: local,
privk: sk, privk: sk,
proc: goprocessctx.WithContext(ctx),
} }
l.proc.SetTeardown(l.teardown) l.proc = goprocessctx.WithContextAndTeardown(ctx, l.teardown)
log.Debugf("Conn Listener on %s", l.Multiaddr()) log.Debugf("Conn Listener on %s", l.Multiaddr())
log.Event(ctx, "swarmListen", l) log.Event(ctx, "swarmListen", l)
......
...@@ -58,7 +58,6 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey, ...@@ -58,7 +58,6 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey,
mocknet: m, mocknet: m,
peer: p, peer: p,
ps: ps, ps: ps,
proc: goprocessctx.WithContext(ctx),
connsByPeer: map[peer.ID]map[*conn]struct{}{}, connsByPeer: map[peer.ID]map[*conn]struct{}{},
connsByLink: map[*link]map[*conn]struct{}{}, connsByLink: map[*link]map[*conn]struct{}{},
...@@ -66,7 +65,7 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey, ...@@ -66,7 +65,7 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey,
notifs: make(map[inet.Notifiee]struct{}), notifs: make(map[inet.Notifiee]struct{}),
} }
n.proc.SetTeardown(n.teardown) n.proc = goprocessctx.WithContextAndTeardown(ctx, n.teardown)
return n, nil return n, nil
} }
......
...@@ -82,7 +82,6 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr, ...@@ -82,7 +82,6 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
swarm: ps.NewSwarm(PSTransport), swarm: ps.NewSwarm(PSTransport),
local: local, local: local,
peers: peers, peers: peers,
proc: goprocessctx.WithContext(ctx),
ctx: ctx, ctx: ctx,
dialT: DialTimeout, dialT: DialTimeout,
notifs: make(map[inet.Notifiee]ps.Notifiee), notifs: make(map[inet.Notifiee]ps.Notifiee),
...@@ -91,7 +90,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr, ...@@ -91,7 +90,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
} }
// configure Swarm // configure Swarm
s.proc.SetTeardown(s.teardown) s.proc = goprocessctx.WithContextAndTeardown(ctx, s.teardown)
s.SetConnHandler(nil) // make sure to setup our own conn handler. s.SetConnHandler(nil) // make sure to setup our own conn handler.
// setup swarm metrics // setup swarm metrics
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment