diff --git a/thumb.go b/thumb.go index b1bd24c..a6d0beb 100644 --- a/thumb.go +++ b/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 - <-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{}{} }() if ctx.Err() != nil {