提交 4ef780a9 作者: Brian Tiger Chow 提交者: Jeromy

fix(bitswap) signal termination to async'ly spawned workers

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 5bd3b178
......@@ -163,7 +163,10 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) e
}
// TODO ensure only one active request per key
func (bs *bitswap) loop(ctx context.Context) {
func (bs *bitswap) loop(parent context.Context) {
ctx, cancel := context.WithCancel(parent)
defer cancel() // signal termination
// Every so often, we should resend out our current want list
rebroadcastTime := time.Second * 5
......@@ -190,7 +193,7 @@ func (bs *bitswap) loop(ctx context.Context) {
log.Errorf("error sending wantlist: %s", err)
}
}
case <-ctx.Done():
case <-parent.Done():
return
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论