b/f: db_reg_agent: also stop RegistrationTimer thread on unclean shutdown

sayer/1.4-spce2.6
Stefan Sayer 14 years ago
parent 93df92a489
commit 08c13de634

@ -242,13 +242,15 @@ int DBRegAgent::onLoad()
void DBRegAgent::onUnload() {
if (running) {
running = false;
registration_scheduler._timer_thread_running = false;
DBG("unclean shutdown. Waiting for processing thread to stop.\n");
for (int i=0;i<20;i++) {
if (shutdown_finished)
for (int i=0;i<400;i++) {
if (shutdown_finished && registration_scheduler._shutdown_finished)
break;
usleep(2000); // 2ms
}
if (!shutdown_finished) {
if (!shutdown_finished || !registration_scheduler._shutdown_finished) {
WARN("processing thread could not be stopped, process will probably crash\n");
}
}
@ -879,7 +881,7 @@ void DBRegAgent::onSipReplyEvent(AmSipReplyEvent* ev) {
}
void DBRegAgent::run() {
running = true;
running = shutdown_finished = true;
DBG("DBRegAgent thread: waiting 2 sec for server startup ...\n");
sleep(2);
@ -891,8 +893,8 @@ void DBRegAgent::run() {
registration_processor.start();
}
shutdown_finished = false;
DBG("running DBRegAgent thread...\n");
shutdown_finished = false;
while (running) {
processEvents();

@ -196,6 +196,7 @@ void RegistrationTimer::run_timers() {
void RegistrationTimer::run()
{
struct timeval now,next_tick,diff,tick;
_shutdown_finished = false;
tick.tv_sec = 0;
tick.tv_usec = TIMER_RESOLUTION;
@ -227,6 +228,9 @@ void RegistrationTimer::run()
run_timers();
timeradd(&tick,&next_tick,&next_tick);
}
DBG("RegistrationTimer thread finishing.\n");
_shutdown_finished = true;
}
void RegistrationTimer::on_stop() {

@ -109,6 +109,7 @@ class RegistrationTimer
RegistrationTimer();
bool _timer_thread_running;
bool _shutdown_finished;
};
#endif

Loading…
Cancel
Save