add signal handlers for clean shutdown of BTS via OML on shutdown of program
This commit is contained in:
parent
e872cb1221
commit
d125250ae2
|
@ -26,6 +26,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
@ -348,7 +349,35 @@ static void bootstrap_om(struct gsm_bts *bts)
|
||||||
abis_nm_event_reports(bts, 1);
|
abis_nm_event_reports(bts, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int shutdown_om(struct gsm_bts *bts)
|
||||||
|
{
|
||||||
|
/* stop sending event reports */
|
||||||
|
abis_nm_event_reports(bts, 0);
|
||||||
|
|
||||||
|
/* begin DB transmission */
|
||||||
|
abis_nm_db_transmission(bts, 1);
|
||||||
|
|
||||||
|
/* end DB transmission */
|
||||||
|
abis_nm_db_transmission(bts, 0);
|
||||||
|
|
||||||
|
/* Reset BTS Site manager resource */
|
||||||
|
abis_nm_reset_resource(bts);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int shutdown_net(struct gsm_network *net)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < net->num_bts; i++) {
|
||||||
|
int rc;
|
||||||
|
rc = shutdown_om(&net->bts[i]);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct bcch_info {
|
struct bcch_info {
|
||||||
u_int8_t type;
|
u_int8_t type;
|
||||||
|
@ -918,6 +947,20 @@ static void bsc_hack_call_state_changed(struct gsm_lchan *lchan,
|
||||||
pag_timer_cb(0);
|
pag_timer_cb(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void signal_handler(int signal)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "signal %u received\n", signal);
|
||||||
|
|
||||||
|
switch (signal) {
|
||||||
|
case SIGHUP:
|
||||||
|
case SIGABRT:
|
||||||
|
shutdown_net(gsmnet);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* parse options */
|
/* parse options */
|
||||||
|
@ -937,6 +980,9 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
bootstrap_network();
|
bootstrap_network();
|
||||||
|
|
||||||
|
signal(SIGHUP, &signal_handler);
|
||||||
|
signal(SIGABRT, &signal_handler);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
bsc_select_main();
|
bsc_select_main();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue