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

Unit test for rule & codec & disconnect tcp & broker_tcp v5 #628

Merged
merged 19 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions include/nng/mqtt/mqtt_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ NNG_DECL void nng_mqtt_msg_set_unsubscribe_property(nng_msg *, property *);
NNG_DECL void nng_mqtt_msg_set_unsuback_return_codes(
nng_msg *, uint8_t *, uint32_t);
NNG_DECL uint8_t *nng_mqtt_msg_get_unsuback_return_codes(nng_msg *, uint32_t *);
NNG_DECL property *nng_mqtt_msg_get_unsuback_property(nng_msg *);
NNG_DECL void nng_mqtt_msg_set_unsuback_property(nng_msg *, property *);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


NNG_DECL property *nng_mqtt_msg_get_disconnect_property(nng_msg *);
NNG_DECL void nng_mqtt_msg_set_disconnect_property(nng_msg *, property *);
Expand Down
3 changes: 2 additions & 1 deletion src/supplemental/mqtt/mqtt_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ dup_unsubscribe(nni_mqtt_proto_data *dest, nni_mqtt_proto_data *src)
for (size_t i = 0; i < src->payload.unsubscribe.topic_count; i++) {
nni_mqtt_topic_array_set(dest->payload.unsubscribe.topic_arr,
i,
(const char *) src->payload.unsubscribe.topic_arr[i].buf);
(const char *) src->payload.unsubscribe.topic_arr[i].buf,
src->payload.unsubscribe.topic_arr[i].length);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/supplemental/mqtt/mqtt_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ nni_mqtt_msg_proto_data_alloc(nni_msg *msg)
if ((proto_data = NNI_ALLOC_STRUCT(proto_data)) == NULL) {
return NNG_ENOMEM;
}
nni_proto_data_init(proto_data);
proto_data->initialized = false;
nni_msg_set_proto_data(msg, &proto_msg_ops, proto_data);

Expand Down Expand Up @@ -508,7 +509,7 @@ nni_mqtt_msg_set_unsubscribe_topics(
for (size_t i = 0; i < topic_count; i++) {
nni_mqtt_topic_array_set(
proto_data->payload.unsubscribe.topic_arr, i,
(const char *) topics[i].buf);
(const char *) topics[i].buf, topics[i].length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous bug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. Length is an unused arg in unsub before, now it is fixed and works just like sub.

}
}

Expand Down Expand Up @@ -845,10 +846,10 @@ nni_mqtt_topic_array_create(size_t n)

void
nni_mqtt_topic_array_set(
nni_mqtt_topic *topic, size_t index, const char *topic_name)
nni_mqtt_topic *topic, size_t index, const char *topic_name, uint32_t len)
{
topic[index].buf = (uint8_t *) nni_strdup(topic_name);
topic[index].length = (uint32_t) strlen(topic_name);
topic[index].length = len;
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/supplemental/mqtt/mqtt_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ NNG_DECL void nni_mqtt_msg_set_disconnect_property(nng_msg *msg, property *prop)
NNG_DECL void nni_mqtt_msg_dump(nni_msg *, uint8_t *, uint32_t, bool);
// mqtt topic create/free
NNG_DECL nni_mqtt_topic *nni_mqtt_topic_array_create(size_t n);
NNG_DECL void nni_mqtt_topic_array_set(nni_mqtt_topic *, size_t, const char *);
NNG_DECL void nni_mqtt_topic_array_set(nni_mqtt_topic *, size_t, const char *, uint32_t);
NNG_DECL void nni_mqtt_topic_array_free(nni_mqtt_topic *, size_t);

// mqtt topic_qos create/free/set
Expand Down
2 changes: 1 addition & 1 deletion src/supplemental/mqtt/mqtt_public.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ void
nng_mqtt_topic_array_set(
nng_mqtt_topic *topic, size_t n, const char *topic_name)
{
nni_mqtt_topic_array_set(topic, n, topic_name);
nni_mqtt_topic_array_set(topic, n, topic_name, strlen(topic));
}

void
Expand Down
Loading
Loading