From 83ea8920c547a725dfe921a3286452d1592f4c61 Mon Sep 17 00:00:00 2001 From: wanghaemq Date: Tue, 21 Mar 2023 15:26:11 +0800 Subject: [PATCH] * FIX [mqtt_quic] Fix the heapOverflow in logs. MultiStream is supported (passed the test). --- demo/quic/client.c | 1 + src/mqtt/protocol/mqtt/mqtt_quic.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/demo/quic/client.c b/demo/quic/client.c index 29f41862..5035accd 100644 --- a/demo/quic/client.c +++ b/demo/quic/client.c @@ -65,6 +65,7 @@ mqtt_msg_compose(int type, int qos, char *topic, char *payload) nng_mqtt_msg_set_connect_keep_alive(msg, 30); nng_mqtt_msg_set_connect_clean_session(msg, false); + nng_mqtt_msg_set_connect_client_id(msg, "nanosdk-quic-client"); } else if (type == 2) { nng_mqtt_msg_set_packet_type(msg, NNG_MQTT_SUBSCRIBE); diff --git a/src/mqtt/protocol/mqtt/mqtt_quic.c b/src/mqtt/protocol/mqtt/mqtt_quic.c index 980c516c..9e094106 100644 --- a/src/mqtt/protocol/mqtt/mqtt_quic.c +++ b/src/mqtt/protocol/mqtt/mqtt_quic.c @@ -57,22 +57,22 @@ static void *mqtt_quic_sock_get_sqlite_option(mqtt_sock_t *s); #define log_info(fmt, ...) \ do { \ - printf("[%s]: " fmt "", __FUNCTION__, ##__VA_ARGS__); \ + printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ } while (0) #define log_warn(fmt, ...) \ do { \ - printf("[%s]: " fmt "", __FUNCTION__, ##__VA_ARGS__); \ + printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ } while (0) #define log_debug(fmt, ...) \ do { \ - printf("[%s]: " fmt "", __FUNCTION__, ##__VA_ARGS__); \ + printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ } while (0) #define log_error(fmt, ...) \ do { \ - printf("[%s]: " fmt "", __FUNCTION__, ##__VA_ARGS__); \ + printf("[%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__); \ } while (0) typedef struct conf_tls conf_tls; @@ -278,7 +278,7 @@ nng_mqtt_quic_open_topic_stream(mqtt_sock_t *mqtt_sock, const char *topic, uint3 hash = DJBHashn((char *) topic, len); nni_id_set(mqtt_sock->streams, hash, new_pipe); new_pipe->stream_id = hash; - log_debug("create new pipe %p for topic %s", new_pipe, topic); + log_debug("create new pipe %p for topic %.*s", new_pipe, len, topic); new_pipe->ready = true; nni_atomic_set_bool(&new_pipe->closed, false);