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",
|
"host": ":3125",
|
||||||
"thumbnailjoblimit": "5",
|
"thumbnailjoblimit": 5,
|
||||||
"servedirs": {
|
"servedirs": {
|
||||||
"leech": "/home/ontake/Dev/go/leech"
|
"leech": "/home/ontake/Dev/go/leech"
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/png"
|
"image/png"
|
||||||
|
"leech/config"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
@ -27,7 +28,6 @@ var thumbnailSize = 24
|
|||||||
|
|
||||||
var thumbnailCache = map[string][]byte{}
|
var thumbnailCache = map[string][]byte{}
|
||||||
var thumbnailCacheMutex = &sync.RWMutex{}
|
var thumbnailCacheMutex = &sync.RWMutex{}
|
||||||
var jobLimit = 5
|
|
||||||
var memLimiterMutex = &sync.RWMutex{}
|
var memLimiterMutex = &sync.RWMutex{}
|
||||||
var jobCounter = 0
|
var jobCounter = 0
|
||||||
var checkAgain = make(chan bool, 5)
|
var checkAgain = make(chan bool, 5)
|
||||||
@ -39,7 +39,7 @@ func IsSupportedFileType(completePath string) bool {
|
|||||||
|
|
||||||
func WaitForAvailable() {
|
func WaitForAvailable() {
|
||||||
memLimiterMutex.RLock()
|
memLimiterMutex.RLock()
|
||||||
for jobLimit == jobCounter {
|
for config.Config.ThumbnailJobLimit == jobCounter {
|
||||||
memLimiterMutex.RUnlock()
|
memLimiterMutex.RUnlock()
|
||||||
<-checkAgain
|
<-checkAgain
|
||||||
memLimiterMutex.RLock()
|
memLimiterMutex.RLock()
|
||||||
|
Loading…
Reference in New Issue
Block a user