Skip to content

fix: use defer Unlock in Incr/Decr to prevent lock leak#312

Merged
devfeel merged 2 commits intodevelopfrom
aicode
Mar 8, 2026
Merged

fix: use defer Unlock in Incr/Decr to prevent lock leak#312
devfeel merged 2 commits intodevelopfrom
aicode

Conversation

@devfeel
Copy link
Owner

@devfeel devfeel commented Mar 8, 2026

Summary

修复 Incr/Decr 函数中的锁泄漏问题,避免死锁。

Changes

  • In :
    • Incr(): 使用 defer Unlock 替代手动 Unlock
    • Decr(): 使用 defer Unlock 替代手动 Unlock
    • 修复错误路径时的锁泄漏

Test Results

Item Status
Build ✅ Pass
Race Test ✅ Pass

Files Changed

  • Modified: cache/runtime/cache_runtime.go (+2/-3)

Breaking Changes

None.

AI Assistant and others added 2 commits March 8, 2026 17:00
- 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 <ai@devfeel.io>
@devfeel devfeel merged commit 3b077e2 into develop Mar 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant