1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 18:13:54 +08:00

fix concurrent SetError in add command

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

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
Steven Allen
2017-11-20 19:44:51 -08:00
parent 65489c1744
commit d89a4b6960

View File

@ -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
}
}
}()