Fix incorrect dead queue clear logic (#20624)
We were incorrectly returning from the method without resetting the pointer. Fixes https://github.com/mattermost/mattermost-server/issues/20622 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ba9f82e010
Коммит
1d2cb7c805
@@ -580,7 +580,7 @@ func (wc *WebConn) isInDeadQueue(seq int64) (bool, int) {
|
|||||||
func (wc *WebConn) clearDeadQueue() {
|
func (wc *WebConn) clearDeadQueue() {
|
||||||
for i := 0; i < deadQueueSize; i++ {
|
for i := 0; i < deadQueueSize; i++ {
|
||||||
if wc.deadQueue[i] == nil {
|
if wc.deadQueue[i] == nil {
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
wc.deadQueue[i] = nil
|
wc.deadQueue[i] = nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,6 +276,26 @@ func TestWebConnIsInDeadQueue(t *testing.T) {
|
|||||||
assert.False(t, wc.hasMsgLoss())
|
assert.False(t, wc.hasMsgLoss())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWebConnClearDeadQueue(t *testing.T) {
|
||||||
|
th := Setup(t)
|
||||||
|
defer th.TearDown()
|
||||||
|
|
||||||
|
wc := th.App.NewWebConn(&WebConnConfig{
|
||||||
|
WebSocket: &websocket.Conn{},
|
||||||
|
})
|
||||||
|
|
||||||
|
var i int
|
||||||
|
for ; i < 2; i++ {
|
||||||
|
msg := &model.WebSocketEvent{}
|
||||||
|
msg = msg.SetSequence(int64(i))
|
||||||
|
wc.addToDeadQueue(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
wc.clearDeadQueue()
|
||||||
|
|
||||||
|
assert.Equal(t, 0, wc.deadQueuePointer)
|
||||||
|
}
|
||||||
|
|
||||||
func TestWebConnDrainDeadQueue(t *testing.T) {
|
func TestWebConnDrainDeadQueue(t *testing.T) {
|
||||||
th := Setup(t)
|
th := Setup(t)
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user