Skip to content

Commit

Permalink
[MQTT] clearly set null when closing connection
Browse files Browse the repository at this point in the history
Clearly set connection state and handle when closing MQTT connection.

Signed-off-by: Jaeyun Jung <[email protected]>
  • Loading branch information
jaeyun-jung authored and myungjoo committed Feb 23, 2024
1 parent 7fd2385 commit 0085b9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/libnnstreamer-edge/nnstreamer-edge-mqtt-mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ nns_edge_mqtt_connect (const char *id, const char *topic, const char *host,
}

if (!broker_h) {
nns_edge_loge ("Invalid param, mqtt_h should not be null.");
nns_edge_loge ("Invalid param, broker_h should not be null.");
return NNS_EDGE_ERROR_INVALID_PARAMETER;
}

Expand Down Expand Up @@ -304,6 +304,9 @@ nns_edge_mqtt_close (nns_edge_broker_h broker_h)
mosquitto_lib_cleanup ();
}

bh->mqtt_h = NULL;
bh->connected = false;

nns_edge_queue_destroy (bh->message_queue);
bh->message_queue = NULL;
nns_edge_lock_destroy (bh);
Expand Down
4 changes: 3 additions & 1 deletion src/libnnstreamer-edge/nnstreamer-edge-mqtt-paho.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ nns_edge_mqtt_connect (const char *id, const char *topic, const char *host,
}

if (!broker_h) {
nns_edge_loge ("Invalid param, mqtt_h should not be null.");
nns_edge_loge ("Invalid param, broker_h should not be null.");
return NNS_EDGE_ERROR_INVALID_PARAMETER;
}

Expand Down Expand Up @@ -258,6 +258,8 @@ nns_edge_mqtt_close (nns_edge_broker_h broker_h)
MQTTAsync_destroy (&handle);
}

bh->mqtt_h = NULL;

nns_edge_queue_destroy (bh->message_queue);
bh->message_queue = NULL;

Expand Down

0 comments on commit 0085b9d

Please sign in to comment.