aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc/sms_queue.c
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-01-22 17:05:37 +0100
committerHarald Welte <laforge@gnumonks.org>2018-01-25 16:16:15 +0000
commit87cba1f10599e9be8ea3350522a43df091448485 (patch)
tree065fe460fa644a078c900a27a97b43bda6f4995e /src/libmsc/sms_queue.c
parent703f2ec6f40af2c2d46d10b5896b9dc74b65c3c0 (diff)
Add a VTY command which deletes all expired SMS.
We already delete SMS which have been sent successfully. However, there are plans to accept SMS for any subscriber in order to fix the problem described in https://osmocom.org/issues/2354 ("SMSC: Store&Forward not working for subscribed but unregistered MS"). This means we may end up storing SMS which never get sent, e.g. because the B subscriber doesn't actually exist. This could lead to a higher degree of SMS database growth over time, and therefore we need a way to keep database size under control. As a first step, introduce a DB function which removes an expired SMS, and add a VTY command which removes all expired SMS from the DB. Later commits will build upon this to remove expired SMS automatically. The SMS expiry time period is currently hard-coded to 2 weeks. We could make this configurable in the future if desired. Change-Id: Icd6093b7b5d8db84b19a0aa47c68182566113ee2 Related: OS#2354
Diffstat (limited to 'src/libmsc/sms_queue.c')
-rw-r--r--src/libmsc/sms_queue.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libmsc/sms_queue.c b/src/libmsc/sms_queue.c
index 3d39a0edc..193d0230f 100644
--- a/src/libmsc/sms_queue.c
+++ b/src/libmsc/sms_queue.c
@@ -72,21 +72,21 @@ static int sms_subscr_cb(unsigned int, unsigned int, void *, void *);
static int sms_sms_cb(unsigned int, unsigned int, void *, void *);
static struct gsm_sms_pending *sms_find_pending(struct gsm_sms_queue *smsq,
- struct gsm_sms *sms)
+ unsigned long long sms_id)
{
struct gsm_sms_pending *pending;
llist_for_each_entry(pending, &smsq->pending_sms, entry) {
- if (pending->sms_id == sms->id)
+ if (pending->sms_id == sms_id)
return pending;
}
return NULL;
}
-static int sms_is_in_pending(struct gsm_sms_queue *smsq, struct gsm_sms *sms)
+int sms_queue_sms_is_pending(struct gsm_sms_queue *smsq, unsigned long long sms_id)
{
- return sms_find_pending(smsq, sms) != NULL;
+ return sms_find_pending(smsq, sms_id) != NULL;
}
static struct gsm_sms_pending *sms_subscriber_find_pending(
@@ -286,7 +286,7 @@ static void sms_submit_pending(void *_data)
}
/* no need to send a pending sms */
- if (sms_is_in_pending(smsq, sms)) {
+ if (sms_queue_sms_is_pending(smsq, sms->id)) {
LOGP(DLSMS, LOGL_DEBUG,
"SMSqueue with pending sms: %llu. Skipping\n", sms->id);
sms_free(sms);
@@ -337,7 +337,7 @@ static void sms_send_next(struct vlr_subscr *vsub)
goto no_pending_sms;
/* The sms should not be scheduled right now */
- OSMO_ASSERT(!sms_is_in_pending(smsq, sms));
+ OSMO_ASSERT(!sms_queue_sms_is_pending(smsq, sms->id));
/* Remember that we deliver this SMS and send it */
pending = sms_pending_from(smsq, sms);
@@ -472,7 +472,7 @@ static int sms_sms_cb(unsigned int subsys, unsigned int signal,
* sms that are not in our control as we just have a channel
* open anyway.
*/
- pending = sms_find_pending(network->sms_queue, sig_sms->sms);
+ pending = sms_find_pending(network->sms_queue, sig_sms->sms->id);
if (!pending)
return 0;