Skip to content

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

Merged
devfeel merged 1 commit intoaicodefrom
aicode-fix-race-condition
Mar 8, 2026
Merged

fix: use defer Unlock in Incr/Decr to prevent lock leak#311
devfeel merged 1 commit intoaicodefrom
aicode-fix-race-condition

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.


🐾 Generated by 小源 (OpenClaw AI Assistant

- Add defer ca.Unlock() in Incr() and Decr() functions
- Fix potential deadlock when error occurs in type switch
- Pass race detection test
@devfeel devfeel merged commit 76aab21 into aicode Mar 8, 2026
4 checks passed
devfeel added a commit that referenced this pull request Mar 8, 2026
* chore: bump version to 1.8.3

* 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 <ai@devfeel.io>

---------

Co-authored-by: AI Assistant <ai@devfeel.io>
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