From 3781b1920aca2ce173b45a33ee79a41bac54c58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 2 Oct 2023 08:18:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/storage_memory.go | 2 +- internal/caches/writer_memory.go | 2 +- internal/iplibrary/ip_list.go | 2 -- internal/utils/system_1.19.go | 3 ++- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/caches/storage_memory.go b/internal/caches/storage_memory.go index 4d3c1e3..bdff1d8 100644 --- a/internal/caches/storage_memory.go +++ b/internal/caches/storage_memory.go @@ -223,7 +223,7 @@ func (this *MemoryStorage) openWriter(key string, expiresAt int64, status int, h delete(this.writingKeyMap, key) this.locker.Unlock() - if valueItem != nil && valueItem.IsDone { + if valueItem != nil { valueItem.TotalSize = int64(len(valueItem.HeaderValue) + len(valueItem.BodyValue) + len(key) + 256 /** meta size **/) atomic.AddInt64(&this.usedSize, valueItem.TotalSize) diff --git a/internal/caches/writer_memory.go b/internal/caches/writer_memory.go index 21d2d8d..63d4e82 100644 --- a/internal/caches/writer_memory.go +++ b/internal/caches/writer_memory.go @@ -138,7 +138,7 @@ func (this *MemoryWriter) Close() error { func (this *MemoryWriter) Discard() error { // 需要在Locker之外 defer this.once.Do(func() { - this.endFunc(nil) + this.endFunc(this.item) }) this.storage.locker.Lock() diff --git a/internal/iplibrary/ip_list.go b/internal/iplibrary/ip_list.go index 7ed1516..96a0aba 100644 --- a/internal/iplibrary/ip_list.go +++ b/internal/iplibrary/ip_list.go @@ -4,7 +4,6 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/expires" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" - "github.com/iwind/TeaGo/logs" "sort" "sync" ) @@ -150,7 +149,6 @@ func (this *IPList) ContainsIPStrings(ipStrings []string) (item *IPItem, found b func (this *IPList) SetDeleted() { this.isDeleted = true - logs.Println("set deleted:", this.isDeleted) // TODO } func (this *IPList) addItem(item *IPItem, sortable bool) { diff --git a/internal/utils/system_1.19.go b/internal/utils/system_1.19.go index af30500..3cc06ab 100644 --- a/internal/utils/system_1.19.go +++ b/internal/utils/system_1.19.go @@ -12,6 +12,7 @@ func setMaxMemory(memoryGB int) { if memoryGB <= 0 { memoryGB = 1 } - var maxMemoryBytes = (int64(memoryGB) << 30) * 80 / 100 // 默认 80% + + var maxMemoryBytes = (int64(memoryGB) << 30) * 75 / 100 // 默认 75% debug.SetMemoryLimit(maxMemoryBytes) }