From 7c831ecd191bab20ab5330d16da147e9a12bbba8 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 12 Nov 2012 18:36:00 +0100 Subject: 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. --- openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c') 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); } -- cgit v1.2.3