pespin submitted this change.
xua_rkm: Fix dynamic AS destroyed when multiple ASPs are associated
If more than 1 ASP was assigned to a dynamic ASP, when one of the ASP
would go down it would incorrectly tear down the associated dynamic AS.
This is wrong and should only happen when the last of the ASPs
associated to the AS is destroyed.
Change-Id: I986044944282cea9a13ed59424f2220fee6fe567
---
M src/osmo_ss7_as.c
M src/ss7_as.h
M src/xua_rkm.c
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/osmo_ss7_as.c b/src/osmo_ss7_as.c
index eb655ca..076cc35 100644
--- a/src/osmo_ss7_as.c
+++ b/src/osmo_ss7_as.c
@@ -199,6 +199,21 @@
return false;
}
+/*! Determine amount of ASPs associated to an AS.
+ * \param[in] as Application Server.
+ * \returns number of ASPs associated to as */
+unsigned int osmo_ss7_as_count_asp(const struct osmo_ss7_as *as)
+{
+ unsigned int i;
+ unsigned int cnt = 0;
+
+ for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
+ if (as->cfg.asps[i])
+ cnt++;
+ }
+ return cnt;
+}
+
/*! Determine if given AS is in the active state.
* \param[in] as Application Server.
* \returns true in case as is active; false otherwise. */
diff --git a/src/ss7_as.h b/src/ss7_as.h
index 504818c..9f4be25 100644
--- a/src/ss7_as.h
+++ b/src/ss7_as.h
@@ -67,5 +67,7 @@
} cfg;
};
+unsigned int osmo_ss7_as_count_asp(const struct osmo_ss7_as *as);
+
#define LOGPAS(as, subsys, level, fmt, args ...) \
_LOGSS7((as)->inst, subsys, level, "as-%s: " fmt, (as)->cfg.name, ## args)
diff --git a/src/xua_rkm.c b/src/xua_rkm.c
index 9a3918e..dd07db2 100644
--- a/src/xua_rkm.c
+++ b/src/xua_rkm.c
@@ -601,10 +601,11 @@
llist_for_each_entry_safe(as, as2, &inst->as_list, list) {
if (!osmo_ss7_as_has_asp(as, asp))
continue;
- /* FIXME: check if there are no other ASPs! */
if (!as->rkm_dyn_allocated)
continue;
- osmo_ss7_as_destroy(as);
+ /* If there are no other ASPs, destroy the AS: */
+ if (osmo_ss7_as_count_asp(as) == 1)
+ osmo_ss7_as_destroy(as);
}
}
To view, visit change 39630. To unsubscribe, or for help writing mail filters, visit settings.