diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-07-05 07:58:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-07-05 07:58:57 +0000 |
commit | c6c93706e12eeaa56f8f52c42bf8737424458c38 (patch) | |
tree | b53e4d8713ebd7a290f8241bb4d053a8b0b6c9d8 /src/namestore | |
parent | 491bcd3a92a3585cbbe6a1aa59aae18bf141a7c5 (diff) | |
download | gnunet-c6c93706e12eeaa56f8f52c42bf8737424458c38.tar.gz gnunet-c6c93706e12eeaa56f8f52c42bf8737424458c38.zip |
-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).
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 11 | ||||
-rw-r--r-- | src/namestore/namestore_common.c | 3 |
2 files changed, 13 insertions, 1 deletions
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, | |||
457 | ret = 1; | 457 | ret = 1; |
458 | return; | 458 | return; |
459 | } | 459 | } |
460 | if (etime_is_rel && del) | ||
461 | { | ||
462 | fprintf (stderr, | ||
463 | _("Deletion requires either absolute time, or no time at all. Got relative time `%s' instead.\n"), | ||
464 | expirationstring); | ||
465 | GNUNET_SCHEDULER_shutdown (); | ||
466 | ret = 1; | ||
467 | return; | ||
468 | } | ||
460 | } | 469 | } |
461 | else if (add) | 470 | else if (add) |
462 | { | 471 | { |
@@ -524,6 +533,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
524 | rd.data_size = data_size; | 533 | rd.data_size = data_size; |
525 | rd.record_type = type; | 534 | rd.record_type = type; |
526 | rd.expiration_time = 0; | 535 | rd.expiration_time = 0; |
536 | if (!etime_is_rel) | ||
537 | rd.expiration_time = etime_abs.abs_value; | ||
527 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 538 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; |
528 | del_qe = GNUNET_NAMESTORE_record_remove (ns, | 539 | del_qe = GNUNET_NAMESTORE_record_remove (ns, |
529 | zone_pkey, | 540 | 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, | |||
178 | "Record type %lu != %lu\n", a->record_type, b->record_type); | 178 | "Record type %lu != %lu\n", a->record_type, b->record_type); |
179 | return GNUNET_NO; | 179 | return GNUNET_NO; |
180 | } | 180 | } |
181 | if (a->expiration_time != b->expiration_time) | 181 | if ((a->expiration_time != b->expiration_time) && |
182 | ((a->expiration_time != 0) && (b->expiration_time != 0))) | ||
182 | { | 183 | { |
183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
184 | "Expiration time %llu != %llu\n", a->expiration_time, b->expiration_time); | 185 | "Expiration time %llu != %llu\n", a->expiration_time, b->expiration_time); |