thumbnail: if the request is cancelled, don't wait for the semaphore
This commit is contained in:
parent
ad56309cb0
commit
156e2ab540
7
thumb.go
7
thumb.go
@ -62,7 +62,12 @@ func (this *Server) handleThumb(w http.ResponseWriter, r *http.Request, thumbnai
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only a limited number of thumbnails can be generated concurrently
|
// Only a limited number of thumbnails can be generated concurrently
|
||||||
<-this.thumbnailSem
|
select {
|
||||||
|
case <-this.thumbnailSem:
|
||||||
|
case <-r.Context().Done():
|
||||||
|
http.Error(w, r.Context().Err().Error(), 400) // probably won't be delivered anyway
|
||||||
|
return
|
||||||
|
}
|
||||||
defer func() { this.thumbnailSem <- struct{}{} }()
|
defer func() { this.thumbnailSem <- struct{}{} }()
|
||||||
|
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user