Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于.Unlock 提个问题,想了解一下实现 #35

Open
seifeHu opened this issue Apr 16, 2022 · 1 comment
Open

关于.Unlock 提个问题,想了解一下实现 #35

seifeHu opened this issue Apr 16, 2022 · 1 comment

Comments

@seifeHu
Copy link

seifeHu commented Apr 16, 2022

Put(conn interface{}) 这方法里

c.mu.Lock()后为什么不直接
defer c.mu.Unlock()

而是各个select 分支上再 c.mu.Unlock()
有什么特殊的考虑吗?

@silenceper
Copy link
Owner

因为c.Close里面也有lock,如果这里直接defer会造成死锁

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

No branches or pull requests

2 participants