Skip to content

Commit

Permalink
Fixed a crash in MQTT outgoing PUBREL (#4646)
Browse files Browse the repository at this point in the history
This really was a cut/paste/typo error, the `else` should not have been
there. Came up in my testing.

The effect was that when there was a pending `PUBREL` in JetStream, and
a matching client connects - we would sometimes attempt to deliver the
PUBREL immediately once connected. `cpending` was already initialized,
but the pubrel map was not (yet).
  • Loading branch information
derekcollison committed Oct 11, 2023
2 parents 6a5304c + de1282c commit 9a55118
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/mqtt.go
Expand Up @@ -2891,10 +2891,11 @@ func (sess *mqttSession) trackAsPubRel(pi uint16, jsAckSubject string) {

sseq, _, _ := ackReplyInfo(jsAckSubject)

var sseqToPi map[uint64]uint16
if sess.cpending == nil {
sess.cpending = make(map[string]map[uint64]uint16)
} else if sseqToPi = sess.cpending[jsDur]; sseqToPi == nil {
}
sseqToPi := sess.cpending[jsDur]
if sseqToPi == nil {
sseqToPi = make(map[uint64]uint16)
sess.cpending[jsDur] = sseqToPi
}
Expand Down

0 comments on commit 9a55118

Please sign in to comment.