diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-06-28 17:09:29 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-06-28 18:01:47 +0800 |
commit | 4049455d744455dd48fa359a220822303fc3a5be (patch) | |
tree | 262a428bb44471ee7d7ddbdf89421633ba409392 /openbsc/src/chan_alloc.c | |
parent | 2412a07965ace5fc425b401438d21ff86ceeb2df (diff) |
bsc_msc: Remove use_count from the subscriber connection
A channel will be released in case of
* Errors via the clear_request callback...
* no more transactions and operations are going on.
This means that if we do something without a transaction
the channel might be closed down right away. The bug fix
will be to create a transaction/operation.
Diffstat (limited to 'openbsc/src/chan_alloc.c')
-rw-r--r-- | openbsc/src/chan_alloc.c | 51 |
1 files changed, 11 insertions, 40 deletions
diff --git a/openbsc/src/chan_alloc.c b/openbsc/src/chan_alloc.c index f5c4ec65e..62d476ad9 100644 --- a/openbsc/src/chan_alloc.c +++ b/openbsc/src/chan_alloc.c @@ -35,8 +35,6 @@ #include <osmocore/talloc.h> -static void auto_release_channel(void *_lchan); - static int ts_is_usable(struct gsm_bts_trx_ts *ts) { /* FIXME: How does this behave for BS-11 ? */ @@ -296,18 +294,8 @@ void lchan_free(struct gsm_lchan *lchan) if (lchan->conn) { - if (lchan->conn->subscr) { - subscr_put(lchan->conn->subscr); - lchan->conn->subscr = NULL; - } - /* We might kill an active channel... */ - if (lchan->conn->use_count != 0) { - dispatch_signal(SS_LCHAN, S_LCHAN_UNEXPECTED_RELEASE, lchan); - lchan->conn->use_count = 0; - } - /* stop the timer */ - bsc_del_timer(&lchan->conn->release_timer); + dispatch_signal(SS_LCHAN, S_LCHAN_UNEXPECTED_RELEASE, lchan); } @@ -334,6 +322,7 @@ void lchan_free(struct gsm_lchan *lchan) dispatch_signal(SS_CHALLOC, S_CHALLOC_FREED, &sig); if (lchan->conn) { + LOGP(DRLL, LOGL_ERROR, "the subscriber connection should be gone.\n"); subscr_con_free(lchan->conn); lchan->conn = NULL; } @@ -364,40 +353,19 @@ void lchan_reset(struct gsm_lchan *lchan) /* Consider releasing the channel now */ -int lchan_auto_release(struct gsm_lchan *lchan) +int lchan_release(struct gsm_lchan *lchan, int sach_deact, int reason) { - if (!lchan->conn) - return 0; - - if (lchan->conn->use_count > 0) { - return 0; - } - /* Assume we have GSM04.08 running and send a release */ - if (lchan->conn->subscr) { + if (sach_deact) { gsm48_send_rr_release(lchan); } - /* spoofed? message */ - if (lchan->conn->use_count < 0) - LOGP(DRLL, LOGL_ERROR, "Channel count is negative: %d\n", - lchan->conn->use_count); - DEBUGP(DRLL, "%s Recycling Channel\n", gsm_lchan_name(lchan)); rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ); rsl_release_request(lchan, 0, 0); return 1; } -/* Auto release the channel when the use count is zero */ -static void auto_release_channel(void *_lchan) -{ - struct gsm_lchan *lchan = _lchan; - - if (!lchan_auto_release(lchan)) - bsc_schedule_timer(&lchan->conn->release_timer, LCHAN_RELEASE_TIMEOUT); -} - static struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) { struct gsm_bts_trx *trx; int ts_no, lchan_no; @@ -490,10 +458,6 @@ struct gsm_subscriber_connection *subscr_con_allocate(struct gsm_lchan *lchan) /* Configure the time and start it so it will be closed */ conn->lchan = lchan; conn->bts = lchan->ts->trx->bts; - conn->release_timer.cb = auto_release_channel; - conn->release_timer.data = lchan; - bsc_schedule_timer(&conn->release_timer, LCHAN_RELEASE_TIMEOUT); - lchan->conn = conn; return conn; } @@ -507,6 +471,13 @@ void subscr_con_free(struct gsm_subscriber_connection *conn) if (!conn) return; + + if (conn->subscr) { + subscr_put(conn->subscr); + conn->subscr = NULL; + } + + lchan = conn->lchan; talloc_free(conn); |