]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/smux/smux.cpp
Default constructor added in resetable structures
[stg.git] / projects / stargazer / plugins / other / smux / smux.cpp
index fc45fe04e2d15fc93558ba602f8e505e529b0240..fdcaaf0207639113da6c07798c0f7c3b8e2d8ab6 100644 (file)
@@ -209,8 +209,6 @@ int SMUX::Stop()
 printfd(__FILE__, "SMUX::Stop() - Before\n");
 running = false;
 
-ResetNotifiers();
-
 if (!stopped)
     {
     //5 seconds to thread stops itself
@@ -236,12 +234,37 @@ if (!stopped)
 
 pthread_join(thread, NULL);
 
+ResetNotifiers();
+
+    {
+    Tables::iterator it;
+    for (it = tables.begin(); it != tables.end(); ++it)
+        delete it->second;
+    }
+    {
+    Sensors::iterator it;
+    for (it = sensors.begin(); it != sensors.end(); ++it)
+        delete it->second;
+    }
+
+tables.erase(tables.begin(), tables.end());
+sensors.erase(sensors.begin(), sensors.end());
+
 close(sock);
 
 printfd(__FILE__, "SMUX::Stop() - After\n");
 return 0;
 }
 
+int SMUX::Reload()
+{
+if (Stop())
+    return -1;
+if (Start())
+    return -1;
+return 0;
+}
+
 void * SMUX::Runner(void * d)
 {
 SMUX * smux = static_cast<SMUX *>(d);
@@ -253,8 +276,11 @@ return NULL;
 
 void SMUX::Run()
 {
-SendOpenPDU(sock);
-SendRReqPDU(sock);
+stopped = true;
+if (!SendOpenPDU(sock))
+    return;
+if (!SendRReqPDU(sock))
+    return;
 running = true;
 stopped = false;