From b0e2c6c751e514fb34460de2ab5d30e18e0f972d Mon Sep 17 00:00:00 2001 From: jaylin Date: Wed, 30 Oct 2024 15:50:11 +0800 Subject: [PATCH 1/3] * MDF [mqtt_quic_client] move aio_finish out from sock lock Signed-off-by: jaylin --- src/mqtt/protocol/mqtt/mqtt_quic_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mqtt/protocol/mqtt/mqtt_quic_client.c b/src/mqtt/protocol/mqtt/mqtt_quic_client.c index b5b837ad7..27849762f 100644 --- a/src/mqtt/protocol/mqtt/mqtt_quic_client.c +++ b/src/mqtt/protocol/mqtt/mqtt_quic_client.c @@ -726,11 +726,10 @@ mqtt_quic_recv_cb(void *arg) nni_pipe_close(p->qpipe); return; } + nni_mtx_unlock(&s->mtx); if (user_aio) { nni_aio_finish(user_aio, 0, 0); } - nni_mtx_unlock(&s->mtx); - // Trigger connect cb first in case connack being freed if (packet_type == NNG_MQTT_CONNACK) if (s->cb.connect_cb) { @@ -740,6 +739,7 @@ mqtt_quic_recv_cb(void *arg) if (packet_type == NNG_MQTT_PUBLISH) if (s->cb.msg_recv_cb) // Trigger cb s->cb.msg_recv_cb(msg, s->cb.recvarg); + return; } // Timer callback, we use it for retransmition. From 60059da8ba64737d2047aab27e189b2c2ba8e653 Mon Sep 17 00:00:00 2001 From: jaylin Date: Wed, 30 Oct 2024 18:58:56 +0800 Subject: [PATCH 2/3] * FIX [mqtt_quic_client] qos priority is not compatible with Cancel timeout Signed-off-by: jaylin --- src/mqtt/protocol/mqtt/mqtt_quic_client.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mqtt/protocol/mqtt/mqtt_quic_client.c b/src/mqtt/protocol/mqtt/mqtt_quic_client.c index 27849762f..8241da0c8 100644 --- a/src/mqtt/protocol/mqtt/mqtt_quic_client.c +++ b/src/mqtt/protocol/mqtt/mqtt_quic_client.c @@ -129,7 +129,7 @@ struct mqtt_pipe_s { #endif }; - +// QUIC is still retrying, Although we abort sending in protocol layer. static void mqtt_quic_cancel_send(nni_aio *aio, void *arg, int rv) { @@ -290,7 +290,8 @@ mqtt_quic_send_msg(nni_aio *aio, mqtt_sock_t *s) nni_msg_free(msg); nni_aio_finish_error(aio, NNG_ECANCELED); return NNG_ECANCELED; - } else { + } else if (!s->qos_first) { + // Cancel Timeout is simply not compatible with QoS first logic int rv; if ((rv = nni_aio_schedule(aio, mqtt_quic_cancel_send, s)) != 0) { log_warn("Cancel_Func scheduling failed, send abort!"); @@ -319,7 +320,7 @@ mqtt_quic_send_msg(nni_aio *aio, mqtt_sock_t *s) // this make cancel_send impossible nni_aio_set_prov_data(aio, &prior_flags); nni_pipe_send(p->qpipe, aio); - log_debug("sending highpriority QoS msg in parallel"); + log_debug("sending high priority QoS msg in parallel"); nni_mtx_unlock(&s->mtx); return 0; } @@ -726,10 +727,11 @@ mqtt_quic_recv_cb(void *arg) nni_pipe_close(p->qpipe); return; } - nni_mtx_unlock(&s->mtx); if (user_aio) { nni_aio_finish(user_aio, 0, 0); } + nni_mtx_unlock(&s->mtx); + // Trigger connect cb first in case connack being freed if (packet_type == NNG_MQTT_CONNACK) if (s->cb.connect_cb) { From 0d54996f31a1d0cc1ccd036513ca1c56c55b225c Mon Sep 17 00:00:00 2001 From: jaylin Date: Wed, 30 Oct 2024 18:59:37 +0800 Subject: [PATCH 3/3] * MDF [msquic_dial] remove some comments Signed-off-by: jaylin --- src/supplemental/quic/msquic_dial.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/supplemental/quic/msquic_dial.c b/src/supplemental/quic/msquic_dial.c index fc22b7497..4572cb412 100644 --- a/src/supplemental/quic/msquic_dial.c +++ b/src/supplemental/quic/msquic_dial.c @@ -1008,8 +1008,7 @@ quic_stream_dowrite(nni_quic_conn *c) naiov, QUIC_SEND_FLAG_NONE, NULL))) { log_error("[sid%d] Failed in StreamSend, 0x%x!", c->id, rv); free(buf); - // nni_aio_list_remove(aio); - // nni_aio_finish_error(aio, NNG_ECLOSED); + // Verify: send_complete cb triggered later? return; } @@ -1335,15 +1334,9 @@ msquic_strm_cb(_In_ HQUIC stream, _In_opt_ void *Context, nni_aio_set_input(aio, 0, NULL); free(buf); nni_msg *msg = nni_aio_get_msg(aio); - // free SUBSCRIBE/UNSUBSCRIBE QoS 1/2 PUBLISH msg here - // nni_mqtt_packet_type t = nni_mqtt_msg_get_packet_type(msg); nni_msg_free(msg); // Do not set nni_aio_set_msg(aio, NULL) here! leave it to cancel! - if (canceled) - nni_aio_finish_error(aio, NNG_ECANCELED); - // XXX Protocol will finish aio when received ack. - //else - // nni_aio_finish(aio, 0, nni_aio_count(aio)); + // Do not finish user aio here! break; } // Ordinary sending