mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
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.
This commit is contained in:
parent
ce21b32d38
commit
cae309fa26
1 changed files with 5 additions and 0 deletions
|
@ -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)
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in a new issue