hlr.c: move deinitialization code from SIGINT handler
There were a few lines of dead code below the osmo_select_main()
loop, while the actual deinitialization code was a part of SIGINT
handler. Let's reanimate this dead zone by moving the code there
and introducing a global 'loop-breaker' variable.
Change-Id: I0e2d673b420193e2bdc1a92377aca542f3a19229
diff --git a/src/hlr.c b/src/hlr.c
index 643dfff..7fdb27e 100644
--- a/src/hlr.c
+++ b/src/hlr.c
@@ -44,6 +44,7 @@
#include "hlr_vty.h"
static struct hlr *g_hlr;
+static int quit = 0;
/* Trigger 'Insert Subscriber Data' messages to all connected GSUP clients.
*
@@ -523,11 +524,7 @@
switch (signal) {
case SIGINT:
LOGP(DMAIN, LOGL_NOTICE, "Terminating due to SIGINT\n");
- osmo_gsup_server_destroy(g_hlr->gs);
- db_close(g_hlr->dbc);
- log_fini();
- talloc_report_full(hlr_ctx, stderr);
- exit(0);
+ quit++;
break;
case SIGUSR1:
LOGP(DMAIN, LOGL_DEBUG, "Talloc Report due to SIGUSR1\n");
@@ -621,13 +618,14 @@
}
}
- while (1) {
+ while (!quit)
osmo_select_main(0);
- }
+ osmo_gsup_server_destroy(g_hlr->gs);
db_close(g_hlr->dbc);
-
log_fini();
- exit(0);
+ talloc_report_full(hlr_ctx, stderr);
+
+ return 0;
}