[MQTT] clearly set null when closing connection
authorJaeyun Jung <jy1210.jung@samsung.com>
Mon, 5 Feb 2024 09:43:06 +0000 (18:43 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 23 Feb 2024 06:35:22 +0000 (15:35 +0900)
Clearly set connection state and handle when closing MQTT connection.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
src/libnnstreamer-edge/nnstreamer-edge-mqtt-mosquitto.c
src/libnnstreamer-edge/nnstreamer-edge-mqtt-paho.c

index b06095fb6f685ea1e4dc478ef5208ba13ba200a6..2b8adce0359d51044a288632253cef3ac814b7f5 100644 (file)
@@ -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;
   }
 
@@ -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);
index fd1a5f5566930a1d8f03350c2c976d694d1ac4b7..72168854a4389420bcf92625525d556378d055da 100644 (file)
@@ -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;
   }
 
@@ -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;