This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/13631 Change subject: libmsc/db.c: get rid of hard-coded SMS expiry threshold ...................................................................... libmsc/db.c: get rid of hard-coded SMS expiry threshold Change-Id: I0ce6b1ab50986dc69a2be4ea62b6a24c7f3f8f0a --- M src/libmsc/db.c M tests/db_sms/db_sms_test.err 2 files changed, 12 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/31/13631/1 diff --git a/src/libmsc/db.c b/src/libmsc/db.c index 3f9a9bd..b4150fb 100644 --- a/src/libmsc/db.c +++ b/src/libmsc/db.c @@ -1001,20 +1001,15 @@ } -static int delete_expired_sms(unsigned long long sms_id, time_t created, time_t validity_timestamp) +static int delete_expired_sms(unsigned long long sms_id, time_t validity_timestamp) { dbi_result result; - time_t now, min_created; + time_t now; now = time(NULL); - if (validity_timestamp > now) - return -1; - /* Our SMS expiry threshold is hard-coded to roughly 2 weeks at the moment. */ - min_created = now - (time_t)(60 * 60 * 24 * 7 * 2); - if (min_created < 0) /* bogus system clock? */ - return -1; - if (created >= min_created) /* not yet expired */ + /* Net yet expired */ + if (validity_timestamp > now) return -1; result = dbi_conn_queryf(conn, "DELETE FROM SMS WHERE id = %llu", sms_id); @@ -1029,9 +1024,9 @@ int db_sms_delete_expired_message_by_id(unsigned long long sms_id) { dbi_result result; - time_t created, validity_timestamp; + time_t validity_timestamp; - result = dbi_conn_queryf(conn, "SELECT created,valid_until FROM SMS WHERE id = %llu", sms_id); + result = dbi_conn_queryf(conn, "SELECT valid_until FROM SMS WHERE id = %llu", sms_id); if (!result) return -1; if (!next_row(result)) { @@ -1039,29 +1034,28 @@ return -1; } - created = dbi_result_get_datetime(result, "created"); validity_timestamp = dbi_result_get_datetime(result, "valid_until"); dbi_result_free(result); - return delete_expired_sms(sms_id, created, validity_timestamp); + return delete_expired_sms(sms_id, validity_timestamp); } void db_sms_delete_oldest_expired_message(void) { dbi_result result; - result = dbi_conn_queryf(conn, "SELECT id,created,valid_until FROM SMS ORDER BY created LIMIT 1"); + result = dbi_conn_queryf(conn, "SELECT id,valid_until FROM SMS " + "ORDER BY valid_until LIMIT 1"); if (!result) return; if (next_row(result)) { unsigned long long sms_id; - time_t created, validity_timestamp; + time_t validity_timestamp; sms_id = dbi_result_get_ulonglong(result, "id"); - created = dbi_result_get_datetime(result, "created"); validity_timestamp = dbi_result_get_datetime(result, "valid_until"); - delete_expired_sms(sms_id, created, validity_timestamp); + delete_expired_sms(sms_id, validity_timestamp); } dbi_result_free(result); diff --git a/tests/db_sms/db_sms_test.err b/tests/db_sms/db_sms_test.err index e0a329d..958294f 100644 --- a/tests/db_sms/db_sms_test.err +++ b/tests/db_sms/db_sms_test.err @@ -68,8 +68,7 @@ DDB NOTICE verify_sms('Truncated TP-UD (255 octets, 8-bit encoding)'): TP-User-Data mismatch (diff=-16896/256) DDB NOTICE test_db_sms_get('Same MSISDN #1'): failure, as expected DDB NOTICE test_db_sms_get('Same MSISDN #2'): failure, as expected -DDB NOTICE test_db_sms_get('Expired SMS'): unexpected result -DDB NOTICE verify_sms('Expired SMS'): match +DDB NOTICE test_db_sms_get('Expired SMS'): failure, as expected DDB NOTICE test_db_sms_get('Empty TP-UD'): success, as expected DDB NOTICE verify_sms('Empty TP-UD'): match full talloc report on 'null_context' (total 0 bytes in 1 blocks) -- To view, visit https://gerrit.osmocom.org/13631 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I0ce6b1ab50986dc69a2be4ea62b6a24c7f3f8f0a Gerrit-Change-Number: 13631 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190414/fcd13be3/attachment.htm>