Commit a5528c4a authored by hannahhoward's avatar hannahhoward

Force processing of context cancellation first

parent fa995d36
...@@ -483,6 +483,15 @@ func makeAsyncTrieGetLinks(dagService ipld.DAGService, linkResults chan<- format ...@@ -483,6 +483,15 @@ func makeAsyncTrieGetLinks(dagService ipld.DAGService, linkResults chan<- format
} }
func emitResult(ctx context.Context, linkResults chan<- format.LinkResult, r format.LinkResult) { func emitResult(ctx context.Context, linkResults chan<- format.LinkResult, r format.LinkResult) {
// make sure that context cancel is processed first
// the reason is due to the concurrency of EnumerateChildrenAsync
// it's possible for EnumLinksAsync to complete and close the linkResults
// channel before this code runs
select {
case <-ctx.Done():
return
default:
}
select { select {
case linkResults <- r: case linkResults <- r:
case <-ctx.Done(): case <-ctx.Done():
......
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