diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-06-15 12:53:08 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-06-15 12:53:08 +0800 |
commit | ecd99338261a102c2513fc57808157f9de65b633 (patch) | |
tree | ec0fee0e17a3a09379b82a37d55ab47dcb437e4e /openbsc/src/gsm_04_11.c | |
parent | cea722bc51441d3f40fde3ed834f592e6073cf8e (diff) |
gsm_04_11: Place subscr_put_channel whenever being done with SMS.
Diffstat (limited to 'openbsc/src/gsm_04_11.c')
-rw-r--r-- | openbsc/src/gsm_04_11.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c index 3d7f7e165..8a85933d8 100644 --- a/openbsc/src/gsm_04_11.c +++ b/openbsc/src/gsm_04_11.c @@ -117,6 +117,19 @@ void sms_free(struct gsm_sms *sms) talloc_free(sms); } +/* + * This should be called whenever all SMS to a given subscriber + * on a given connection has been sent. This will inform the higher + * layers that a channel can be given up. + */ +static void gsm411_release_conn(struct gsm_subscriber_connection *conn) +{ + if (!conn->lchan) + return; + + subscr_put_channel(conn->lchan); +} + struct msgb *gsm411_msgb_alloc(void) { return msgb_alloc_headroom(GSM411_ALLOC_SIZE, GSM411_ALLOC_HEADROOM, @@ -750,6 +763,8 @@ static int gsm411_rx_rp_ack(struct msgb *msg, struct gsm_trans *trans, sms = db_sms_get_unsent_for_subscr(trans->subscr); if (sms) gsm411_send_sms_lchan(trans->conn, sms); + else + gsm411_release_conn(trans->conn); /* free the transaction here */ trans_free(trans); @@ -824,6 +839,8 @@ static int gsm411_rx_rp_smma(struct msgb *msg, struct gsm_trans *trans, sms = db_sms_get_unsent_for_subscr(trans->subscr); if (sms) gsm411_send_sms_lchan(trans->conn, sms); + else + gsm411_release_conn(trans->conn); return rc; } @@ -1107,6 +1124,7 @@ static int paging_cb_send_sms(unsigned int hooknum, unsigned int event, switch (event) { case GSM_PAGING_SUCCEEDED: + use_subscr_con(&lchan->conn); gsm411_send_sms_lchan(&lchan->conn, sms); break; case GSM_PAGING_EXPIRED: @@ -1130,8 +1148,10 @@ int gsm411_send_sms_subscr(struct gsm_subscriber *subscr, /* check if we already have an open lchan to the subscriber. * if yes, send the SMS this way */ lchan = lchan_for_subscr(subscr); - if (lchan) + if (lchan) { + use_subscr_con(&lchan->conn); gsm411_send_sms_lchan(&lchan->conn, sms); + } /* if not, we have to start paging */ subscr_get_channel(subscr, RSL_CHANNEED_SDCCH, paging_cb_send_sms, sms); @@ -1156,6 +1176,7 @@ static int subscr_sig_cb(unsigned int subsys, unsigned int signal, sms = db_sms_get_unsent_for_subscr(subscr); if (!sms) break; + use_subscr_con(&lchan->conn); gsm411_send_sms_lchan(&lchan->conn, sms); break; default: @@ -1191,6 +1212,8 @@ void gsm411_sapi_n_reject(struct gsm_subscriber_connection *conn) trans->sms.sms = NULL; trans_free(trans); } + + gsm411_release_conn(conn); } static __attribute__((constructor)) void on_dso_load_sms(void) |