-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Server端OnlineProcessor中putUser和removeUser存在的并发问题 #29
Labels
Comments
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
|
fuhaodev
changed the title
OnlineProcessor中putUser和removeUser存在的并发问题
服务端OnlineProcessor中putUser和removeUser存在的并发问题
Oct 21, 2023
fuhaodev
changed the title
服务端OnlineProcessor中putUser和removeUser存在的并发问题
Server端OnlineProcessor中putUser和removeUser存在的并发问题
Oct 21, 2023
我回头来仔细读一读你写的内容 |
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
putUser
源码里实现是先查询再判断,这里应该是有问题的,如果多个终端同时登录同一个账号,可能会存在丢失Channel导致资源泄露的问题。多个线程同时进到putUser,onlineSessions.get(user_id)结果都为空,就会执行到else里onlineSessions.put(user_id, newSession);这样就后一个就会把前一个Channel覆盖掉,导致Channel泄露,前一个Channel资源不能及时得到释放,也就不会kick掉。
removeUser
这里完全没有必要上锁,直接加synchronized也太暴力了,把所有用户的remove都阻塞了。
贴一段我这块的实现代码吧,可能也存在问题,一起来交流下
The text was updated successfully, but these errors were encountered: