printfd(__FILE__, "SMUX::Stop() - Before\n");
running = false;
-ResetNotifiers();
-
if (!stopped)
{
//5 seconds to thread stops itself
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);
void SMUX::Run()
{
-SendOpenPDU(sock);
-SendRReqPDU(sock);
+stopped = true;
+if (!SendOpenPDU(sock))
+ return;
+if (!SendRReqPDU(sock))
+ return;
running = true;
stopped = false;