Skip to content

Commit

Permalink
* FIX [broker_tcp] fix nanomq/nanomq#1861
Browse files Browse the repository at this point in the history
two bugs hidden under it. uncared proto_Data in retain msg
another one is still suspicous, remoing pipe from a lock protected sendq caused SEGV.

Signed-off-by: jaylin <jaylin@emqx.io>
  • Loading branch information
JaylinYu committed Aug 12, 2024
1 parent 3ea6b4b commit 1342b29
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions src/sp/transport/mqtt/broker_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ tcptran_pipe_fini(void *arg)
nni_lmq_fini(&p->rslmq);
nni_mtx_fini(&p->mtx);
NNI_FREE_STRUCT(p);
log_trace(" ************ tcptran_pipe_finit [%p] ************ ", p);
}

static void
Expand Down Expand Up @@ -1205,15 +1204,6 @@ nmq_pipe_send_start_v4(tcptran_pipe *p, nni_msg *msg, nni_aio *aio)
niov++;
}
}
if (niov == 0) {
// No content to send
nni_msg_free(msg);
nni_aio_set_prov_data(txaio, NULL);
nni_list_remove(&p->sendq, aio);
nni_aio_set_msg(aio, NULL);
nni_aio_finish(aio, 0, 0);
return;
}
send:
nni_aio_set_iov(txaio, niov, iov);
nng_stream_send(p->conn, txaio);
Expand Down Expand Up @@ -1471,8 +1461,7 @@ nmq_pipe_send_start_v5(tcptran_pipe *p, nni_msg *msg, nni_aio *aio)
} else {
// what should broker does when exceed
// max_recv? msg lost, make it look like a
// normal send. qos msg will be resend
// afterwards
// normal send. qos msg will be resend afterwards
nni_msg_free(msg);
nni_aio_set_prov_data(txaio, NULL);
nni_list_remove(&p->sendq, aio);
Expand All @@ -1481,15 +1470,6 @@ nmq_pipe_send_start_v5(tcptran_pipe *p, nni_msg *msg, nni_aio *aio)
return;
}
}
if (niov == 0) {
// No content to send
nni_msg_free(msg);
nni_aio_set_prov_data(txaio, NULL);
nni_list_remove(&p->sendq, aio);
nni_aio_set_msg(aio, NULL);
nni_aio_finish(aio, 0, 0);
return;
}
send:
nni_aio_set_iov(txaio, niov, iov);
nng_stream_send(p->conn, txaio);
Expand Down

0 comments on commit 1342b29

Please sign in to comment.