Commit d89a4b69 authored by Steven Allen's avatar Steven Allen

fix concurrent SetError in add command

I believe this also fixes a potential go routine leak (on race).

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent 65489c17
......@@ -342,6 +342,8 @@ You can now check what blocks have been created by:
},
PostRun: map[cmds.EncodingType]func(cmds.Request, cmds.ResponseEmitter) cmds.ResponseEmitter{
cmds.CLI: func(req cmds.Request, re cmds.ResponseEmitter) cmds.ResponseEmitter {
ctx := req.Context()
reNext, res := cmds.NewChanResponsePair(req)
outChan := make(chan interface{})
......@@ -429,9 +431,6 @@ You can now check what blocks have been created by:
bar.ShowBar = true
bar.ShowTimeLeft = true
}
case <-req.Context().Done():
re.SetError(req.Context().Err(), cmdkit.ErrNormal)
return
}
}
}
......@@ -469,7 +468,12 @@ You can now check what blocks have been created by:
return
}
outChan <- v
select {
case outChan <- v:
case <-ctx.Done():
re.SetError(ctx.Err(), cmdkit.ErrNormal)
return
}
}
}()
......
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