Skip to content

Commit

Permalink
fix(pubsub): Fix mqtt reader group shutdown
Browse files Browse the repository at this point in the history
Fix open62541#6130 with a correct pubsub reader group status when the pubsub
connection is disabled.
Using the current connection state leads to multiple calls of
UA_ReaderGroup_disconnect which also adds multiple deleteTopicConnection
(eventloop_mqtt.c) as delayed callbacks. This ends with the second call
of UA_free(tc).
This is actually a double free error which is now displayed
as invalid read on later memory access by valgrind test.
Changing state to readerGroup->state (in this case
UA_PUBSUBSTATE_PREOPERATIONAL -> UA_PUBSUBSTATE_PREOPERATIONAL)
avoids the earlier call of UA_ReaderGroup_disconnect and deleteTopicConnection
is called only once.
The new pattern is similar with writerGroup->state for publisher a few
lines later.

Signed-off-by: Vasilij Strassheim <[email protected]>
  • Loading branch information
V-Strassheim authored and jpfr committed Nov 17, 2023
1 parent 18e85b9 commit 08d2cbe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pubsub/ua_pubsub_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ UA_PubSubConnection_setPubSubState(UA_Server *server, UA_PubSubConnection *c,

/* Disable Reader and WriterGroups */
LIST_FOREACH(readerGroup, &c->readerGroups, listEntry) {
UA_ReaderGroup_setPubSubState(server, readerGroup, state);
UA_ReaderGroup_setPubSubState(server, readerGroup, readerGroup->state);
}
LIST_FOREACH(writerGroup, &c->writerGroups, listEntry) {
UA_WriterGroup_setPubSubState(server, writerGroup, writerGroup->state);
Expand Down

0 comments on commit 08d2cbe

Please sign in to comment.