From fea0aebd368d1b0a661170ec985f6a91d5ad4723 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 13 Jun 2010 14:15:39 +0800 Subject: bsc_msc_ip: Attempt to plug an lchan leak... If we end up with a channel that has refcount of zero, has no msc_data attached and the handler has not returned 1 we will just close it. --- openbsc/src/bsc_msc_ip.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c index c133ef58c..558c0345e 100644 --- a/openbsc/src/bsc_msc_ip.c +++ b/openbsc/src/bsc_msc_ip.c @@ -289,8 +289,6 @@ static int open_sccp_connection(struct msgb *layer3) /* When not connected to a MSC. We will simply close things down. */ if (!bsc_gsmnet->msc_con->is_authenticated) { LOGP(DMSC, LOGL_ERROR, "Not connected to a MSC. Not forwarding data.\n"); - use_subscr_con(&layer3->lchan->conn); - put_subscr_con(&layer3->lchan->conn, 0); return -1; } @@ -611,6 +609,12 @@ int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id) } bsc_queue_connection_write(lchan_get_sccp(msg->lchan), dtap); + } else if (rc <= 0 && !msg->lchan->msc_data && msg->lchan->conn.use_count == 0) { + if (msg->lchan->state == LCHAN_S_ACTIVE) { + LOGP(DMSC, LOGL_NOTICE, "Closing unowned channel.\n"); + use_subscr_con(&msg->lchan->conn); + put_subscr_con(&msg->lchan->conn, 0); + } } return rc; -- cgit v1.2.3