sysmobts: Initialize the NM signal handler only once in a mixed network
Make sure that the bts_ipa_nm_sig_cb is only installed once. In
a nanoBTS + sysmoBTS network the _start method will be called
for each mode leading to the handler being registered twice.
Make sure that there is only one handler registered by unregistering
a previously installed handler. The osmo_signal_unregister_handler
will remove 0 or 1 handlers per invocation and we only add one
handler in this file so it is always balanced.
diff --git a/openbsc/src/libbsc/bts_ipaccess_nanobts.c b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
index cebb7ae..ebbd88d 100644
--- a/openbsc/src/libbsc/bts_ipaccess_nanobts.c
+++ b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
@@ -439,7 +439,7 @@
}
/* Callback function to be called every time we receive a signal from NM */
-int bts_ipa_nm_sig_cb(unsigned int subsys, unsigned int signal,
+static int bts_ipa_nm_sig_cb(unsigned int subsys, unsigned int signal,
void *handler_data, void *signal_data)
{
if (subsys != SS_NM)
@@ -461,6 +461,7 @@
static int bts_model_nanobts_start(struct gsm_network *net)
{
+ osmo_signal_unregister_handler(SS_NM, bts_ipa_nm_sig_cb, NULL);
osmo_signal_register_handler(SS_NM, bts_ipa_nm_sig_cb, NULL);
ipaccess_gsmnet = net;
return 0;