Skip to content

Commit

Permalink
refactor send queued
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrosKyriakakis committed Jan 31, 2024
1 parent 21384e6 commit 9693665
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,23 +351,14 @@ func (s *session) persist(seqNum int, msgBytes []byte) error {
}

func (s *session) sendQueued() {
var (
sent bool
indexBlocked int
)

for i, msgBytes := range s.toSend {
sent = s.sendBytes(msgBytes)
if !sent {
indexBlocked = i
break
if !s.sendBytes(msgBytes) {
s.toSend = s.toSend[i:]
s.notifyMessageOut()
return
}
}
if !sent {
s.toSend = s.toSend[indexBlocked:]
s.notifyMessageOut()
return
}

s.dropQueued()
}

Expand Down

0 comments on commit 9693665

Please sign in to comment.