Commit 1575e2d0 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Fix crash when stopping

parent 0538b79c
......@@ -192,6 +192,7 @@ void AlarmHandler::delete_device()
DEBUG_STREAM << __func__ << " starting="<<(int)starting << " shutting_down="<<(int)shutting_down<<" restarting="<<(int)restarting;
abortflag = true;
updateloop->signal();
DEBUG_STREAM << "AlarmHandler::delete_device(): after abortflag=true..." << endl;
try {
events->unsubscribe_events();
......@@ -210,10 +211,11 @@ void AlarmHandler::delete_device()
if(!shutting_down && !restarting)
alarms.del_rwlock(); //otherwise moved in alarm_table destructor
alarms.stop_cmdthread();
sleep(1); //wait for alarm_thread and log_thread to exit
delete events;
sleep(1); //wait for alarm_thread, update_thread and log_thread to exit
//delete almloop;
DEBUG_STREAM << "AlarmHandler::delete_device(): stopped alarm and log threads!" << endl;
//delete proxy for actions
for(alarm_container_t::iterator i = alarms.v_alarm.begin(); i!=alarms.v_alarm.end(); i++)
......@@ -314,7 +316,6 @@ void AlarmHandler::delete_device()
delete alarmedlock;
delete internallock;
delete dslock;
delete events;
instanceCounter--;
//Tango::leavefunc();
......
......@@ -26,7 +26,7 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.2 $";
/*
* alarm_thread::alarm_thread()
*/
update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p)
update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p),Tango::LogAdapter(p)
{
//cout << __FILE__rev << endl;
}
......@@ -36,6 +36,7 @@ update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p)
*/
update_thread::~update_thread()
{
DEBUG_STREAM << __func__ << "update_thread::run(): exiting!" << endl;
p_Alarm = NULL;
}
......@@ -52,14 +53,23 @@ void update_thread::run(void *)
while (!p_Alarm->abortflag) {
try
{
omni_thread::sleep(pausasec,pausanano);
p_Alarm->timer_update();
//omni_thread::sleep(pausasec,pausanano);
abort_sleep(pausasec+(double)pausanano/1000000000);
if(!p_Alarm->abortflag)
p_Alarm->timer_update();
//printf("update_thread::run(): TIMER!!\n");
}
catch(...)
{
printf("update_thread::run(): catched unknown exception!!\n");
INFO_STREAM << "update_thread::run(): catched unknown exception!!";
}
}
//cout << "update_thread::run(): exiting!" << endl;
DEBUG_STREAM << "update_thread::run(): exiting!" << endl;
} /* update_thread::run() */
void update_thread::abort_sleep(double time)
{
omni_mutex_lock sync(*this);
long time_millis = (long)(time*1000);
int res = wait(time_millis);
}
......@@ -24,13 +24,14 @@
#include <tango.h>
#include <AlarmHandler.h>
class update_thread : public omni_thread {
class update_thread : public omni_thread, public Tango::TangoMonitor, public Tango::LogAdapter {
public:
update_thread(AlarmHandler_ns::AlarmHandler *p);
~update_thread();
protected:
void run(void *);
private:
void abort_sleep(double time);
AlarmHandler_ns::AlarmHandler *p_Alarm;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment