aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-11-12 18:36:00 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-04-16 09:17:21 +0200
commit7c831ecd191bab20ab5330d16da147e9a12bbba8 (patch)
treed2a9e13106dc58ac593ecada2094a5ce18f5521c /openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
parent931ad6ac33d8efaf7f32f49c253c0cc7bbf595fc (diff)
nat: Do not allow the amount of pending responses to grow infinitely
Limit the amount of pending DLCX responses to three times the amount of available endpoints. Currently all MGCP messages are sent and handled in sequence.
Diffstat (limited to 'openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index ba15618ec..411d500d9 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -347,6 +347,21 @@ static void remember_pending_dlcx(struct sccp_connections *con, uint32_t transac
stats->trans_id = transaction;
stats->msc_endpoint = con->msc_endp;
+ /*
+ * Too many pending requests.. let's remove the first two items.
+ */
+ if (!llist_empty(&bsc->pending_dlcx) &&
+ bsc->pending_dlcx_count >= bsc->cfg->max_endpoints * 3) {
+ struct bsc_nat_call_stats *tmp;
+ LOGP(DNAT, LOGL_ERROR,
+ "Too many(%d) pending DLCX responses on BSC: %d\n",
+ bsc->pending_dlcx_count, bsc->cfg->nr);
+ bsc->pending_dlcx_count -= 1;
+ tmp = (struct bsc_nat_call_stats *) bsc->pending_dlcx.next;
+ llist_del(&tmp->entry);
+ talloc_free(tmp);
+ }
+
bsc->pending_dlcx_count += 1;
llist_add_tail(&stats->entry, &bsc->pending_dlcx);
}