Skip to content

Commit

Permalink
wrap muQueue inside rq.RLock
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdata committed Apr 29, 2024
1 parent dc813b2 commit a53d9d0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,6 @@ func (rq *Request) sendQueue(outboundMsgCh chan<- wsMsg) {
validJids[elem.Jid()] = struct{}{}
}
}
rq.mu.RUnlock()

rq.muQueue.Lock()
if len(rq.wsQueue) > 0 {
for i := range rq.wsQueue {
Expand All @@ -665,6 +663,7 @@ func (rq *Request) sendQueue(outboundMsgCh chan<- wsMsg) {
rq.wsQueue = rq.wsQueue[:0]
}
rq.muQueue.Unlock()
rq.mu.RUnlock()

slices.SortStableFunc(toSend, func(a, b wsMsg) int { return int(a.Jid - b.Jid) })

Expand Down

0 comments on commit a53d9d0

Please sign in to comment.