Skip to content

Commit

Permalink
* FIX [mqtt/transport] support transfer qos0 V4 msg to V5 client
Browse files Browse the repository at this point in the history
 * FIX [mqtt/transport] fix PINGRESP
  • Loading branch information
JaylinYu authored and wanghaEMQ committed Feb 21, 2022
1 parent 4ecaa6d commit 2a3beee
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/sp/transport/mqtt/broker_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct tcptran_pipe {
uint8_t txlen[NANO_MIN_PACKET_LEN];
uint8_t rxlen[NNI_NANO_MAX_HEADER_SIZE];
uint8_t * conn_buf;
uint8_t * qos_buf;
uint8_t * qos_buf; // msg trunk for qos & V4/V5 conversion
nni_aio * txaio;
nni_aio * rxaio;
nni_aio * qsaio;
Expand Down Expand Up @@ -556,7 +556,7 @@ tcptran_pipe_recv_cb(void *arg)
iov.iov_len = 2;
iov.iov_buf = &p->txlen;
// send CMD_PINGRESP down...
nni_aio_set_iov(p->qsaio, 1, &iov);
nni_aio_set_iov(p->rpaio, 1, &iov);
nng_stream_send(p->conn, p->rpaio);
goto notify;
}
Expand Down Expand Up @@ -864,7 +864,7 @@ tcptran_pipe_send_start(tcptran_pipe *p)
NNI_GET16(body, tlen);

qos_pac = nni_msg_get_pub_qos(msg);
if (qos_pac == 0) {
if (qos_pac == 0 && prover == 0) {
// save time & space for QoS 0 publish
goto send;
}
Expand Down Expand Up @@ -931,8 +931,6 @@ tcptran_pipe_send_start(tcptran_pipe *p)
NNI_PUT16(var_extra, pid);
qlength += 2;
}
// V4 - V5

// use qos_buf to keep zero-copy
if (qlength > 16 + NNI_NANO_MAX_PACKET_SIZE) {
nng_free(p->qos_buf, 16 + NNI_NANO_MAX_PACKET_SIZE);
Expand Down

0 comments on commit 2a3beee

Please sign in to comment.