gochat icon indicating copy to clipboard operation
gochat copied to clipboard

又是一个比较严重的bug, 房间socket反复断开,可能会把bucket里面的新的chn删除,导致无法收到消息

Open zuoganggit opened this issue 1 month ago • 1 comments

server.go里面readPump 方法如下代码: s.Bucket(ch.userId).DeleteChannel(ch)

会执行到bucket里面的如下代码: if ch, ok = b.chs[ch.userId]; ok { room = b.chs[ch.userId].Room //delete from bucket delete(b.chs, ch.userId) }

当旧的连接关闭的时间比新的连接慢(bucket.go put方法里面是直接覆盖chn,如下代码: b.chs[userId] = ch),delete(b.chs, ch.userId)就会把新的chn误删,应该要在s.Bucket(ch.userId).DeleteChannel(ch)前加判断逻辑,s.Bucket(ch.userId)里面是否已经有新的chn

zuoganggit avatar Dec 04 '25 02:12 zuoganggit