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
```
Этот коммит содержится в:
Agniva De Sarker
2022-07-11 23:26:47 +05:30
коммит произвёл GitHub
родитель ba9f82e010
Коммит 1d2cb7c805
2 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@@ -580,7 +580,7 @@ func (wc *WebConn) isInDeadQueue(seq int64) (bool, int) {
func (wc *WebConn) clearDeadQueue() {
for i := 0; i < deadQueueSize; i++ {
if wc.deadQueue[i] == nil {
return
break
}
wc.deadQueue[i] = nil
}

Просмотреть файл

@@ -276,6 +276,26 @@ func TestWebConnIsInDeadQueue(t *testing.T) {
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) {
th := Setup(t)
defer th.TearDown()