From 7cda17646611138e4cd92f931361daa5fdbd5657 Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Sun, 8 Mar 2026 17:00:40 +0800 Subject: [PATCH 1/2] chore: bump version to 1.8.3 --- consts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consts.go b/consts.go index 3ab7f03..292602a 100644 --- a/consts.go +++ b/consts.go @@ -3,7 +3,7 @@ package dotweb // Global define const ( // Version current version - Version = "1.8.1" + Version = "1.8.3" ) // Log define From 76aab21c06de7ccfe23502826947fe076abefc4e Mon Sep 17 00:00:00 2001 From: devfeel Date: Sun, 8 Mar 2026 18:19:38 +0800 Subject: [PATCH 2/2] fix: use defer Unlock in Incr/Decr to prevent lock leak (#311) - Add defer ca.Unlock() in Incr() and Decr() functions - Fix potential deadlock when error occurs in type switch - Pass race detection test Co-authored-by: AI Assistant --- cache/runtime/cache_runtime.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cache/runtime/cache_runtime.go b/cache/runtime/cache_runtime.go index 839cc66..c7c07da 100644 --- a/cache/runtime/cache_runtime.go +++ b/cache/runtime/cache_runtime.go @@ -122,6 +122,7 @@ func (ca *RuntimeCache) initValue(key string, value interface{}, ttl int64) erro // Incr increase int64 counter in runtime cache. func (ca *RuntimeCache) Incr(key string) (int64, error) { ca.Lock() + defer ca.Unlock() itemObj, ok := ca.items.Load(key) if !ok { // if not exists, auto set new with 0 @@ -148,8 +149,6 @@ func (ca *RuntimeCache) Incr(key string) (int64, error) { return 0, errors.New("item val is not (u)int (u)int32 (u)int64") } - ca.Unlock() - val, _ := strconv.ParseInt(fmt.Sprint(item.value), 10, 64) return val, nil } @@ -157,6 +156,7 @@ func (ca *RuntimeCache) Incr(key string) (int64, error) { // Decr decrease counter in runtime cache. func (ca *RuntimeCache) Decr(key string) (int64, error) { ca.Lock() + defer ca.Unlock() itemObj, ok := ca.items.Load(key) if !ok { // if not exists, auto set new with 0 @@ -194,7 +194,6 @@ func (ca *RuntimeCache) Decr(key string) (int64, error) { default: return 0, errors.New("item val is not int int64 int32") } - ca.Unlock() val, _ := strconv.ParseInt(fmt.Sprint(item.value), 10, 64) return val, nil