Commit 5ec47677 authored by Steven Allen's avatar Steven Allen

fix: set teardown after storing the context.

Otherwise, we can modify the context after/while the process is shutting down.

fixes #189
parent 3d87dde1
...@@ -112,9 +112,13 @@ func NewSwarm(ctx context.Context, local peer.ID, peers peerstore.Peerstore, bwc ...@@ -112,9 +112,13 @@ func NewSwarm(ctx context.Context, local peer.ID, peers peerstore.Peerstore, bwc
s.dsync = NewDialSync(s.doDial) s.dsync = NewDialSync(s.doDial)
s.limiter = newDialLimiter(s.dialAddr) s.limiter = newDialLimiter(s.dialAddr)
s.proc = goprocessctx.WithContextAndTeardown(ctx, s.teardown) s.proc = goprocessctx.WithContext(ctx)
s.ctx = goprocessctx.OnClosingContext(s.proc) s.ctx = goprocessctx.OnClosingContext(s.proc)
// Set teardown after setting the context/process so we don't start the
// teardown process early.
s.proc.SetTeardown(s.teardown)
return s return s
} }
......
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