fix: add job limits for thumbnails to prevent out of memory errors (2)
This commit is contained in:
parent
76f1dcf83e
commit
ccaa514080
@ -1,6 +1,6 @@
|
||||
{
|
||||
"host": ":3125",
|
||||
"thumbnailjoblimit": "5",
|
||||
"thumbnailjoblimit": 5,
|
||||
"servedirs": {
|
||||
"leech": "/home/ontake/Dev/go/leech"
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
"leech/config"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
@ -27,7 +28,6 @@ var thumbnailSize = 24
|
||||
|
||||
var thumbnailCache = map[string][]byte{}
|
||||
var thumbnailCacheMutex = &sync.RWMutex{}
|
||||
var jobLimit = 5
|
||||
var memLimiterMutex = &sync.RWMutex{}
|
||||
var jobCounter = 0
|
||||
var checkAgain = make(chan bool, 5)
|
||||
@ -39,7 +39,7 @@ func IsSupportedFileType(completePath string) bool {
|
||||
|
||||
func WaitForAvailable() {
|
||||
memLimiterMutex.RLock()
|
||||
for jobLimit == jobCounter {
|
||||
for config.Config.ThumbnailJobLimit == jobCounter {
|
||||
memLimiterMutex.RUnlock()
|
||||
<-checkAgain
|
||||
memLimiterMutex.RLock()
|
||||
|
Loading…
Reference in New Issue
Block a user