Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some error in quic protocol layer. #704

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/mqtt/protocol/mqtt/mqtt_quic_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,10 @@ quic_mqtt_pipe_close(void *arg)
nni_id_map_foreach(&p->recv_unack, mqtt_close_unack_msg_cb);
p->ready = false;

if (p->idmsg == NULL) {
nni_mtx_unlock(&s->mtx);
return;
}
if (nni_mqtt_msg_get_packet_type(p->idmsg) == NNG_MQTT_SUBSCRIBE) {
// packet id is already encoded
nni_mqtt_topic_qos *topics;
Expand All @@ -1568,15 +1572,15 @@ quic_mqtt_pipe_close(void *arg)
DJBHashn((char *) topics[i].topic.buf,
topics[i].topic.length));
}
nni_msg_free(p->idmsg);
} else if (nni_mqtt_msg_get_packet_type(p->idmsg) ==
NNG_MQTT_PUBLISH) {
uint32_t topic_len;
char *topic = (char *) nni_mqtt_msg_get_publish_topic(
p->idmsg, &topic_len);
nni_id_remove(s->sub_streams, DJBHashn(topic, topic_len));
nni_msg_free(p->idmsg);
}
nni_msg_free(p->idmsg);
p->idmsg = NULL;
nni_mtx_unlock(&s->mtx);
}

Expand Down Expand Up @@ -1618,7 +1622,6 @@ mqtt_quic_ctx_send(void *arg, nni_aio *aio)

nni_mtx_lock(&s->mtx);
p = s->pipe;
npipe = p->qpipe;

msg = nni_aio_get_msg(aio);
if (msg == NULL) {
Expand Down Expand Up @@ -1710,6 +1713,7 @@ mqtt_quic_ctx_send(void *arg, nni_aio *aio)
return;
}
} else {
npipe = p->qpipe;
nni_mqtt_msg_set_aio(msg, aio);
if (nni_mqtt_msg_get_packet_type(msg) == NNG_MQTT_SUBSCRIBE) {
nni_lmq_put(s->topic_lmq, msg);
Expand All @@ -1728,7 +1732,7 @@ mqtt_quic_ctx_send(void *arg, nni_aio *aio)
mqtt_pipe_send_msg(aio, msg, pub_pipe, 0);
}
} else {
log_warn("invalid msg type");
log_warn("invalid msg type 0x%x", nni_mqtt_msg_get_packet_type(msg));
}
}
nni_mtx_unlock(&s->mtx);
Expand Down
Loading