Unverified Commit 0ec7d15c authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #207 from libp2p/fix/pstore-close-race

fix: avoid calling AddChild after the process may shutdown.
parents f52acccd fb4e5dbe
...@@ -73,7 +73,9 @@ func GenSwarm(t *testing.T, ctx context.Context, opts ...Option) *swarm.Swarm { ...@@ -73,7 +73,9 @@ func GenSwarm(t *testing.T, ctx context.Context, opts ...Option) *swarm.Swarm {
ps.AddPubKey(p.ID, p.PubKey) ps.AddPubKey(p.ID, p.PubKey)
ps.AddPrivKey(p.ID, p.PrivKey) ps.AddPrivKey(p.ID, p.PrivKey)
s := swarm.NewSwarm(ctx, p.ID, ps, metrics.NewBandwidthCounter()) s := swarm.NewSwarm(ctx, p.ID, ps, metrics.NewBandwidthCounter())
s.Process().AddChild(goprocess.WithTeardown(ps.Close)) // Call AddChildNoWait because we can't call AddChild after the process
// may have been closed (e.g., if the context was canceled).
s.Process().AddChildNoWait(goprocess.WithTeardown(ps.Close))
tcpTransport := tcp.NewTCPTransport(GenUpgrader(s)) tcpTransport := tcp.NewTCPTransport(GenUpgrader(s))
tcpTransport.DisableReuseport = cfg.disableReuseport tcpTransport.DisableReuseport = cfg.disableReuseport
......
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