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
How do you make sure the concurrent issue? #25
Comments
Hello, I believe the map usage is always run in the same goroutine, which uses channels to receive actions from the http goroutintes. This is the subscription manager's run() function running in it's own goroutine. See: Line 282 in 72ba13b
Where the run function has: Line 531 in 72ba13b
Then, when other goroutines handling HTTP need to tell the subscription manager about a new client, a new event, or a disconnect, they send data to the manager via channels which are concurrent-safe. for example: Line 444 in 72ba13b
client disconnect: Line 474 in 72ba13b
event publish: Line 90 in 72ba13b
Conversely, the manager's goroutine will send data back to clients via channels: Line 619 in 72ba13b
If you see any code that is accessing maps across multiple goroutines, or if you have encountered any errors, please point them out and I will try to fix them. But I think all map access is limited to the manager's run() goroutine and the functions called by run() which are still within the same goroutine. All cross-go-routine sharing of data is done via channels. |
Thanks for so rich reply, get it 💯 |
golongpoll/longpoll.go
Line 652 in 033d1fa
I see there is no lock when remove and add item from map, this will case crash.
The text was updated successfully, but these errors were encountered: