sms_queue: Make deletion of messages from DB VTY-configurable

This introduces some VTY settings that determine if delivered
or expired messages should be removed from he SQL database or not.

Change-Id: Id6174875d5c01c40d987077651b27ae1acbcaa93
changes/35/28135/3
Harald Welte 5 months ago committed by laforge
parent 03e8583a43
commit 53e2e5fe70
  1. 4
      include/osmocom/msc/sms_queue.h
  2. 8
      src/libmsc/sms_queue.c
  3. 27
      src/libmsc/smsc_vty.c
  4. 2
      tests/test_nodes.vty

@ -1,6 +1,8 @@
#ifndef SMS_QUEUE_H
#define SMS_QUEUE_H
#include <stdbool.h>
struct gsm_network;
struct gsm_sms_queue;
struct vty;
@ -9,6 +11,8 @@ struct sms_queue_config {
char *db_file_path; /* SMS database file path */
int max_fail; /* maximum number of delivery failures */
int max_pending; /* maximum number of gsm_sms_pending in RAM */
bool delete_delivered; /* delete delivered SMS from DB? */
bool delete_expired; /* delete expired SMS from DB? */
};
struct sms_queue_config *sms_queue_cfg_alloc(void *ctx);

@ -472,6 +472,8 @@ struct sms_queue_config *sms_queue_cfg_alloc(void *ctx)
sqcfg->max_pending = 20;
sqcfg->max_fail = 1;
sqcfg->delete_delivered = true;
sqcfg->delete_expired = true;
sqcfg->db_file_path = talloc_strdup(ctx, SMS_DEFAULT_DB_FILE_PATH);
return sqcfg;
@ -615,7 +617,8 @@ static int sms_sms_cb(unsigned int subsys, unsigned int signal,
/* Remember the subscriber and clear the pending entry */
vsub = pending->vsub;
vlr_subscr_get(vsub, __func__);
db_sms_delete_sent_message_by_id(pending->sms_id);
if (smq->cfg->delete_delivered)
db_sms_delete_sent_message_by_id(pending->sms_id);
sms_pending_free(smq, pending);
/* Attempt to send another SMS to this subscriber */
sms_send_next(vsub);
@ -653,7 +656,8 @@ static int sms_sms_cb(unsigned int subsys, unsigned int signal,
}
/* While here, attempt to remove an expired SMS from the DB. */
db_sms_delete_oldest_expired_message();
if (smq->cfg->delete_expired)
db_sms_delete_oldest_expired_message();
return 0;
}

@ -76,6 +76,28 @@ DEFUN(cfg_sms_queue_fail, cfg_sms_queue_fail_cmd,
return CMD_SUCCESS;
}
#define DB_STR "SMS Database Configuration\n"
DEFUN(cfg_sms_db_del_delivered, cfg_sms_db_del_delivered_cmd,
"database delete-delivered (0|1)",
DB_STR "Configure if delivered SMS are deleted from DB\n"
"Do not delete SMS after delivery\n"
"Delete SMS after delivery\n")
{
smqcfg->delete_delivered = atoi(argv[0]);
return CMD_SUCCESS;
}
DEFUN(cfg_sms_db_del_expired, cfg_sms_db_del_expired_cmd,
"database delete-expired (0|1)",
DB_STR "Configure if expired SMS are deleted from DB\n"
"Do not delete SMS after expiration of validity period\n"
"Delete SMS after expiration of validity period\n")
{
smqcfg->delete_expired = atoi(argv[0]);
return CMD_SUCCESS;
}
/***********************************************************************
* View / Enable Node
***********************************************************************/
@ -141,6 +163,9 @@ static int config_write_smsc(struct vty *vty)
vty_out(vty, " queue max-pending %u%s", smqcfg->max_pending, VTY_NEWLINE);
vty_out(vty, " queue max-failure %u%s", smqcfg->max_fail, VTY_NEWLINE);
vty_out(vty, " database delete-delivered %u%s", smqcfg->delete_delivered, VTY_NEWLINE);
vty_out(vty, " database delete-expired %u%s", smqcfg->delete_expired, VTY_NEWLINE);
return 0;
}
@ -156,6 +181,8 @@ void smsc_vty_init(struct gsm_network *msc_network)
install_element(SMSC_NODE, &cfg_sms_database_cmd);
install_element(SMSC_NODE, &cfg_sms_queue_max_cmd);
install_element(SMSC_NODE, &cfg_sms_queue_fail_cmd);
install_element(SMSC_NODE, &cfg_sms_db_del_delivered_cmd);
install_element(SMSC_NODE, &cfg_sms_db_del_expired_cmd);
/* enable node */
install_element(ENABLE_NODE, &smsqueue_trigger_cmd);

@ -181,6 +181,8 @@ sgs
smsc
queue max-pending 20
queue max-failure 1
database delete-delivered 1
database delete-expired 1
end
OsmoMSC# configure terminal

Loading…
Cancel
Save