b/f: db_reg_agent: also shutdown cleanly on rapid shutdown (e.g. signal 15)

otherwise the processing thread continues to run, and the process crashes
on shutdown
sayer/1.4-spce2.6
Stefan Sayer 14 years ago
parent 31c9662d5c
commit b397d727dc

@ -240,6 +240,19 @@ int DBRegAgent::onLoad()
}
void DBRegAgent::onUnload() {
if (running) {
running = false;
DBG("unclean shutdown. Waiting for processing thread to stop.\n");
for (int i=0;i<20;i++) {
if (shutdown_finished)
break;
usleep(2000); // 2ms
}
if (!shutdown_finished) {
WARN("processing thread could not be stopped, process will probably crash\n");
}
}
DBG("closing main DB connection\n");
MainDBConnection.disconnect();
DBG("closing auxiliary DB connection\n");
@ -878,6 +891,7 @@ void DBRegAgent::run() {
registration_processor.start();
}
shutdown_finished = false;
DBG("running DBRegAgent thread...\n");
while (running) {
processEvents();
@ -899,6 +913,7 @@ void DBRegAgent::run() {
mysqlpp::Connection::thread_end();
DBG("DBRegAgent thread stopped.\n");
shutdown_finished = true;
}
void DBRegAgent::on_stop() {

@ -230,8 +230,12 @@ class DBRegAgent
unsigned int expires;
/** processing thread running? */
bool running;
/** processing thread shutdown finished? */
bool shutdown_finished;
AmDynInvoke* uac_auth_i;
void DIcreateRegistration(int subscriber_id, const string& user,

Loading…
Cancel
Save