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

fix a bug that could cause "Helium.dispatch" to panic #552

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

DuodenumL
Copy link
Contributor

sync.Map里的Range方法有个小坑:如果range的过程中有store / delete发生,range里不保证读到的是最终的状态。(这一点其实官方文档里也有说明)

calcium调用Helium.Unsubscribe之后直接就关闭了chan,此时dispatch仍然可能会读到这个chan,导致panic: send on closed channel

有两种办法可以避免这个问题,并且都不会对功能产生影响:1. 加个recover 2. 用RWMutex。这里采用了改动较小的第一种办法。

@DuodenumL DuodenumL force-pushed the fix/helium branch 2 times, most recently from b00987c to 34bdfd0 Compare February 25, 2022 03:49
@DuodenumL
Copy link
Contributor Author

还是把RWMutex也给加上了,不然会有race。

@CMGS CMGS merged commit 2263dcf into projecteru2:master Feb 25, 2022
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.

2 participants