Skip to content

Commit c36053f

Browse files
committed
update resizer lock position
1 parent 2ce9141 commit c36053f

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

main.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,7 @@ func main() {
8080

8181
init_resize(512 * 1024 * 1024)
8282

83-
sem := make(chan struct{}, 1)
84-
85-
e.GET("/image/*", func(c echo.Context) error {
86-
sem <- struct{}{}
87-
defer func() {
88-
<-sem
89-
}()
90-
91-
return ImageHandler(c)
92-
})
93-
83+
e.GET("/image/*", ImageHandler)
9484
e.GET("/summary", SummaryHandler)
9585

9686
var currentCacheSizeMetrics = prometheus.NewGauge(prometheus.GaugeOpts{

resize.go

+8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ func init_resize(memoryLimit int) {
1414
}
1515
}
1616

17+
var sem = make(chan struct{}, 1)
18+
1719
func resize(input, output string, width, height int) int {
1820

21+
// limit to one resize operation at a time
22+
sem <- struct{}{}
23+
defer func() {
24+
<-sem
25+
}()
26+
1927
cInput := C.CString(input)
2028
defer C.free(unsafe.Pointer(cInput))
2129

0 commit comments

Comments
 (0)