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

聊天室的链表循环处理有问题 #17

Open
y6828863 opened this issue Jun 6, 2017 · 1 comment
Open

聊天室的链表循环处理有问题 #17

y6828863 opened this issue Jun 6, 2017 · 1 comment

Comments

@y6828863
Copy link

y6828863 commented Jun 6, 2017

for ch := waitingList.Back(); ch != nil; ch = ch.Prev() { ch.Value.(chan bool) <- true waitingList.Remove(ch) }
chatroom.go 文件中的第76行---79行的链表循环中删除节点的代码操作是有问题的,节点被删除后继续循环操作导致链表某些元素无法真正的被遍历处理,进而部分聊天室的成员会由于chanel阻塞而无法获取到消息,请处理下。

@zhuxinquan
Copy link

zhuxinquan commented Jun 29, 2017

恩,我也发现这个问题了,改成下面这样就好了

for ch := waitingList.Front(); ch != nil; ch = waitingList.Front() {
    ch.Value.(chan bool) <- true
    waitingList.Remove(ch)
}

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