提交 cae309fa 编写于 作者: R Robert Swain

mediaapi/writers/download: Handle panic to ensure waking of goroutines

If the active request were to panic, we need to ensure all the waiting
goroutines get woken up.
上级 ce21b32d
......@@ -229,6 +229,11 @@ func (r *downloadRequest) getRemoteFile(cfg *config.MediaAPI, db *storage.Databa
// Note: broadcastMediaMetadata uses mutexes and conditions from activeRemoteRequests
defer func() {
// Note: errorResponse is the named return variable so we wrap this in a closure to re-evaluate the arguments at defer-time
if err := recover(); err != nil {
resErr := jsonerror.InternalServerError()
r.broadcastMediaMetadata(activeRemoteRequests, &resErr)
panic(err)
}
r.broadcastMediaMetadata(activeRemoteRequests, errorResponse)
}()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册