Do not call rsl_chan_release directly but use the use_count of the lchan

Call use_lchan early in allocate_loc_updating_req, do not directly call
rsl_chan_release but go through channel alloc to take the use_count into
account.
This commit is contained in:
Holger Freyther 2009-01-01 03:46:11 +00:00
parent 3eaa792b21
commit 67b4b9a017
5 changed files with 22 additions and 16 deletions

View File

@ -345,7 +345,6 @@ int rsl_chan_activate(struct gsm_bts *bts, u_int8_t chan_nr,
u_int8_t ta); u_int8_t ta);
int rsl_chan_activate_tch_f(struct gsm_bts_trx_ts *ts); int rsl_chan_activate_tch_f(struct gsm_bts_trx_ts *ts);
int rsl_chan_activate_sdcch(struct gsm_bts_trx_ts *ts); int rsl_chan_activate_sdcch(struct gsm_bts_trx_ts *ts);
int rsl_chan_release(struct gsm_lchan *lchan);
int rsl_paging_cmd(struct gsm_bts *bts, u_int8_t paging_group, u_int8_t len, int rsl_paging_cmd(struct gsm_bts *bts, u_int8_t paging_group, u_int8_t len,
u_int8_t *ms_ident, u_int8_t chan_needed); u_int8_t *ms_ident, u_int8_t chan_needed);
int rsl_paging_cmd_imsi(struct gsm_bts *bts, u_int8_t chan_needed, const char *imsi_str); int rsl_paging_cmd_imsi(struct gsm_bts *bts, u_int8_t chan_needed, const char *imsi_str);
@ -357,6 +356,7 @@ int abis_rsl_rcvmsg(struct msgb *msg);
/* to be provided by external code */ /* to be provided by external code */
int abis_rsl_sendmsg(struct msgb *msg); int abis_rsl_sendmsg(struct msgb *msg);
int rsl_chan_release(struct gsm_lchan *lchan);
#endif /* RSL_MT_H */ #endif /* RSL_MT_H */

View File

@ -19,4 +19,7 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type);
/* Free a logical channel (SDCCH, TCH, ...) */ /* Free a logical channel (SDCCH, TCH, ...) */
void lchan_free(struct gsm_lchan *lchan); void lchan_free(struct gsm_lchan *lchan);
/* Consider releasing the channel */
int lchan_auto_release(struct gsm_lchan *lchan);
#endif /* _CHAN_ALLOC_H */ #endif /* _CHAN_ALLOC_H */

View File

@ -29,6 +29,7 @@
#include <openbsc/gsm_data.h> #include <openbsc/gsm_data.h>
#include <openbsc/chan_alloc.h> #include <openbsc/chan_alloc.h>
#include <openbsc/abis_nm.h> #include <openbsc/abis_nm.h>
#include <openbsc/abis_rsl.h>
#include <openbsc/debug.h> #include <openbsc/debug.h>
static void auto_release_channel(void *_lchan); static void auto_release_channel(void *_lchan);
@ -196,28 +197,29 @@ void lchan_free(struct gsm_lchan *lchan)
* channel using it */ * channel using it */
} }
/* /* Consider releasing the channel now */
* Auto release the channel when the use count is zero int lchan_auto_release(struct gsm_lchan *lchan)
*/
static void auto_release_channel(void *_lchan)
{ {
struct gsm_lchan *lchan = _lchan;
/*
* Busy...
*/
if (lchan->use_count > 0) { if (lchan->use_count > 0) {
schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT); return 0;
return;
} }
/* /* spoofed? message */
* spoofed? message
*/
if (lchan->use_count < 0) { if (lchan->use_count < 0) {
DEBUGP(DRLL, "Channel count is negative: %d\n", lchan->use_count); DEBUGP(DRLL, "Channel count is negative: %d\n", lchan->use_count);
} }
DEBUGP(DRLL, "Recylcing the channel with: %d (%x)\n", lchan->nr, lchan->nr); DEBUGP(DRLL, "Recylcing the channel with: %d (%x)\n", lchan->nr, lchan->nr);
rsl_chan_release(lchan); rsl_chan_release(lchan);
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))
schedule_timer(&lchan->release_timer, LCHAN_RELEASE_TIMEOUT);
} }

View File

@ -98,12 +98,12 @@ static void release_loc_updating_req(struct gsm_lchan *lchan)
static void allocate_loc_updating_req(struct gsm_lchan *lchan) static void allocate_loc_updating_req(struct gsm_lchan *lchan)
{ {
use_lchan(lchan);
release_loc_updating_req(lchan); release_loc_updating_req(lchan);
lchan->loc_operation = (struct gsm_loc_updating_operation *) lchan->loc_operation = (struct gsm_loc_updating_operation *)
malloc(sizeof(*lchan->loc_operation)); malloc(sizeof(*lchan->loc_operation));
memset(lchan->loc_operation, 0, sizeof(*lchan->loc_operation)); memset(lchan->loc_operation, 0, sizeof(*lchan->loc_operation));
use_lchan(lchan);
} }
static void parse_lai(struct gsm_lai *lai, const struct gsm48_loc_area_id *lai48) static void parse_lai(struct gsm_lai *lai, const struct gsm48_loc_area_id *lai48)
@ -397,7 +397,7 @@ static void loc_upd_rej_cb(void *data)
release_loc_updating_req(lchan); release_loc_updating_req(lchan);
gsm0408_loc_upd_rej(lchan, reject_cause); gsm0408_loc_upd_rej(lchan, reject_cause);
rsl_chan_release(lchan); lchan_auto_release(lchan);
} }
static void schedule_reject(struct gsm_lchan *lchan) static void schedule_reject(struct gsm_lchan *lchan)

View File

@ -80,3 +80,4 @@ void db_create_subscriber(void) {}
void rsl_chan_release(void) {} void rsl_chan_release(void) {}
void msgb_alloc(void) {} void msgb_alloc(void) {}
void gsm0411_send_sms(void) {} void gsm0411_send_sms(void) {}
void lchan_auto_release(void) {}