From c6c93706e12eeaa56f8f52c42bf8737424458c38 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 5 Jul 2012 07:58:57 +0000 Subject: [PATCH] -LRN: Correct time == 0 handling: With logging in namespace comparison it is now clear to me that deletion fails due to expiration times not being equal. And sure enough, gnunet-namespace sets expiration to 0 when submitting a template for seek-and-destroy. This patch: 1) Changes gnunet-namespace to fail if the time is not absolute or unspecified. If it's absolute, it's used as-is (hoping that the user got the exact expiration time somewhere - probably from -D). If it's unspecified, it is set to zero (as it was before). 2) Comparison ignores expiration time if either of the arguments has expiration time set to zero (i'm assuming that real records will never have expiration time of zero. If it's absolute, zero is in the past. If it's relative, zero makes no sense). Also, i'm not sure it makes sense to have two records that have different expiration times, but are otherwise identical (i.e. both are public or private, same data, size etc). Lookups will find (and will be satisfied) by either, so there's no sense in keeping both (unless you're doing some wizardry with expirations, but i'm not sure it's worth the compexity). --- src/namestore/gnunet-namestore.c | 11 +++++++++++ src/namestore/namestore_common.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 5cac2e133..ad263e7d0 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c @@ -457,6 +457,15 @@ run (void *cls, char *const *args, const char *cfgfile, ret = 1; return; } + if (etime_is_rel && del) + { + fprintf (stderr, + _("Deletion requires either absolute time, or no time at all. Got relative time `%s' instead.\n"), + expirationstring); + GNUNET_SCHEDULER_shutdown (); + ret = 1; + return; + } } else if (add) { @@ -524,6 +533,8 @@ run (void *cls, char *const *args, const char *cfgfile, rd.data_size = data_size; rd.record_type = type; rd.expiration_time = 0; + if (!etime_is_rel) + rd.expiration_time = etime_abs.abs_value; rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; del_qe = GNUNET_NAMESTORE_record_remove (ns, zone_pkey, diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c index d67628767..8b095eb26 100644 --- a/src/namestore/namestore_common.c +++ b/src/namestore/namestore_common.c @@ -178,7 +178,8 @@ GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, "Record type %lu != %lu\n", a->record_type, b->record_type); return GNUNET_NO; } - if (a->expiration_time != b->expiration_time) + if ((a->expiration_time != b->expiration_time) && + ((a->expiration_time != 0) && (b->expiration_time != 0))) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expiration time %llu != %llu\n", a->expiration_time, b->expiration_time); -- 2.25.1