Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cs
ds
alarm-handler
Commits
1575e2d0
Commit
1575e2d0
authored
Jan 05, 2021
by
Graziano Scalamera
Browse files
Fix crash when stopping
parent
0538b79c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/AlarmHandler.cpp
View file @
1575e2d0
...
...
@@ -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();
...
...
src/update-thread.cpp
View file @
1575e2d0
...
...
@@ -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
);
}
src/update-thread.h
View file @
1575e2d0
...
...
@@ -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
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment