aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/chan_alloc.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2009-11-17 20:42:09 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2009-11-20 17:40:28 +0100
commit80fb260a604fe49517d968ae1e9c0cc78a18b5de (patch)
tree8199744f03a992eb549b66cb8d6aa78e366aeb7c /openbsc/src/chan_alloc.c
parent55a0716da7d06860addfba1812c309eac6d82f1a (diff)
[lchan] Release the channel ones its' usecount drops to zero
Remove the timer handling from the LCHAN and release the channel ones the use count is dropping to zero. Change code that was sending/using the lchan after the release and change the send data method to warn in case the lchan is used after it has been freed.
Diffstat (limited to 'openbsc/src/chan_alloc.c')
-rw-r--r--openbsc/src/chan_alloc.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/openbsc/src/chan_alloc.c b/openbsc/src/chan_alloc.c
index 0b9d4199d..b4f080585 100644
--- a/openbsc/src/chan_alloc.c
+++ b/openbsc/src/chan_alloc.c
@@ -33,8 +33,6 @@
#include <openbsc/debug.h>
#include <openbsc/signal.h>
-static void auto_release_channel(void *_lchan);
-
struct gsm_bts_trx_ts *ts_c0_alloc(struct gsm_bts *bts,
enum gsm_phys_chan_config pchan)
{
@@ -221,10 +219,6 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type)
/* clear any msc reference */
lchan->msc_data = NULL;
- /* Configure the time and start it so it will be closed */
- lchan->release_timer.cb = auto_release_channel;
- lchan->release_timer.data = lchan;
- bsc_schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT);
}
return lchan;
@@ -245,44 +239,35 @@ void lchan_free(struct gsm_lchan *lchan)
lchan->use_count = 0;
}
- /* stop the timer */
- bsc_del_timer(&lchan->release_timer);
-
/* FIXME: ts_free() the timeslot, if we're the last logical
* channel using it */
}
/* Consider releasing the channel now */
-int lchan_auto_release(struct gsm_lchan *lchan)
+int _lchan_release(struct gsm_lchan *lchan)
{
if (lchan->use_count > 0) {
+ DEBUGP(DRLL, "BUG: _lchan_release called without zero use_count.\n");
return 0;
}
/* Assume we have GSM04.08 running and send a release */
if (lchan->subscr) {
+ ++lchan->use_count;
gsm48_send_rr_release(lchan);
+ --lchan->use_count;
}
/* spoofed? message */
if (lchan->use_count < 0) {
- DEBUGP(DRLL, "Channel count is negative: %d\n", lchan->use_count);
+ DEBUGP(DRLL, "BUG: channel count is negative: %d\n", lchan->use_count);
}
- DEBUGP(DRLL, "Recycling the channel with: %d (%x)\n", lchan->nr, lchan->nr);
+ DEBUGP(DRLL, "Releasing the channel with: %d (%x)\n", lchan->nr, lchan->nr);
rsl_release_request(lchan, 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->release_timer, LCHAN_RELEASE_TIMEOUT);
-}
-
struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) {
struct gsm_bts_trx *trx;
int ts_no, lchan_no;