Skip to content

Commit 2dfca72

Browse files
committed
fix concurrent sem issue
1 parent e2b79ec commit 2dfca72

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

thumberd/thumberd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,15 @@ func thumbServer(w http.ResponseWriter, r *http.Request, sem chan int) {
495495
// sem is the semaphore to restrict concurrent ImageMagick workers to the number of CPU core
496496
sem <- 1
497497
err = thumbnail.MakeThumbnailMagick(srcReader.Body, w, params)
498+
<-sem
499+
498500
if err != nil {
499501
message := "Magick failed: " + err.Error()
500502
glog.Error(message, http.StatusInternalServerError)
501503
http.Error(w, message, http.StatusInternalServerError)
502504
atomic.AddInt64(&http_stats.thumb_error, 1)
503505
return
504506
}
505-
<-sem
506507

507508
atomic.AddInt64(&http_stats.ok, 1)
508509
}

0 commit comments

Comments
 (0)