Skip to content

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