diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-12-25 17:45:23 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-12-26 09:40:48 +0100 |
commit | f7e2389eb680b6459a20fb5ad6357d3d676705b2 (patch) | |
tree | c17ca32850193015ca1e3134bbbbb854a5530504 /openbsc | |
parent | a37e3bc39a8292deb401c6b81c320e56ae679525 (diff) |
sms: Move the finding of the next SMS to handle to a new method
Prepare changing the loop to fill all the available slots. Set
the last subscriber based on the SMS query.
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/src/sms_queue.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/openbsc/src/sms_queue.c b/openbsc/src/sms_queue.c index 41b9ecc25..e8e65846f 100644 --- a/openbsc/src/sms_queue.c +++ b/openbsc/src/sms_queue.c @@ -190,6 +190,25 @@ static void sms_resend_pending(void *_data) } } +static struct gsm_sms *take_next_sms(struct gsm_sms_queue *smsq) +{ + struct gsm_sms *sms; + + sms = db_sms_get_unsent_by_subscr(smsq->network, smsq->last_subscr_id, 10); + if (sms) { + smsq->last_subscr_id = sms->receiver->id + 1; + return sms; + } + + /* need to wrap around */ + smsq->last_subscr_id = 0; + sms = db_sms_get_unsent_by_subscr(smsq->network, + smsq->last_subscr_id, 10); + if (sms) + smsq->last_subscr_id = sms->receiver->id + 1; + return sms; +} + /** * I will submit up to max_pending - pending SMS to the * subsystem. @@ -206,15 +225,8 @@ static void sms_submit_pending(void *_data) struct gsm_sms_pending *pending; struct gsm_sms *sms; - sms = db_sms_get_unsent_by_subscr(smsq->network, smsq->last_subscr_id, 10); - - /* handle wrapping around */ - if (!sms) { - smsq->last_subscr_id = 0; - sms = db_sms_get_unsent_by_subscr(smsq->network, - smsq->last_subscr_id, 10); - } + sms = take_next_sms(smsq); if (!sms) break; @@ -242,7 +254,6 @@ static void sms_submit_pending(void *_data) continue; } - smsq->last_subscr_id = sms->receiver->id + 1; smsq->pending += 1; llist_add(&pending->entry, &smsq->pending_sms); gsm411_send_sms_subscr(sms->receiver, sms); |