diff options
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index 75d9d3940..f18b11cb1 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -28,6 +28,8 @@ | |||
28 | 28 | ||
29 | #include "gnunet-service-reclaim_tickets.h" | 29 | #include "gnunet-service-reclaim_tickets.h" |
30 | 30 | ||
31 | #define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS | ||
32 | |||
31 | struct ParallelLookup; | 33 | struct ParallelLookup; |
32 | 34 | ||
33 | 35 | ||
@@ -291,6 +293,10 @@ struct RECLAIM_TICKETS_RevokeHandle | |||
291 | struct TicketRecordsEntry *tickets_to_update_tail; | 293 | struct TicketRecordsEntry *tickets_to_update_tail; |
292 | }; | 294 | }; |
293 | 295 | ||
296 | /** | ||
297 | * Ticket expiration interval | ||
298 | */ | ||
299 | static struct GNUNET_TIME_Relative ticket_refresh_interval; | ||
294 | 300 | ||
295 | /* Namestore handle */ | 301 | /* Namestore handle */ |
296 | static struct GNUNET_NAMESTORE_Handle *nsh; | 302 | static struct GNUNET_NAMESTORE_Handle *nsh; |
@@ -660,17 +666,17 @@ static void | |||
660 | cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) | 666 | cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) |
661 | { | 667 | { |
662 | struct ParallelLookup *lu; | 668 | struct ParallelLookup *lu; |
663 | struct ParallelLookup *tmp; | ||
664 | if (NULL != cth->lookup_request) | 669 | if (NULL != cth->lookup_request) |
665 | GNUNET_GNS_lookup_cancel (cth->lookup_request); | 670 | GNUNET_GNS_lookup_cancel (cth->lookup_request); |
666 | for (lu = cth->parallel_lookups_head; NULL != lu;) { | 671 | if (NULL != cth->kill_task) |
667 | GNUNET_GNS_lookup_cancel (lu->lookup_request); | 672 | GNUNET_SCHEDULER_cancel (cth->kill_task); |
668 | GNUNET_free (lu->label); | 673 | while (NULL != (lu = cth->parallel_lookups_head)) { |
669 | tmp = lu->next; | 674 | if (NULL != lu->lookup_request) |
675 | GNUNET_GNS_lookup_cancel (lu->lookup_request); | ||
676 | GNUNET_free_non_null (lu->label); | ||
670 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 677 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, |
671 | cth->parallel_lookups_tail, lu); | 678 | cth->parallel_lookups_tail, lu); |
672 | GNUNET_free (lu); | 679 | GNUNET_free (lu); |
673 | lu = tmp; | ||
674 | } | 680 | } |
675 | 681 | ||
676 | if (NULL != cth->attrs) | 682 | if (NULL != cth->attrs) |
@@ -715,7 +721,6 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count, | |||
715 | return; // Wait for more | 721 | return; // Wait for more |
716 | /* Else we are done */ | 722 | /* Else we are done */ |
717 | 723 | ||
718 | GNUNET_SCHEDULER_cancel (cth->kill_task); | ||
719 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); | 724 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); |
720 | cleanup_cth (cth); | 725 | cleanup_cth (cth); |
721 | } | 726 | } |
@@ -872,14 +877,15 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
872 | for (le = ih->attrs->list_head; NULL != le; le = le->next) { | 877 | for (le = ih->attrs->list_head; NULL != le; le = le->next) { |
873 | attrs_record[i].data = &le->claim->id; | 878 | attrs_record[i].data = &le->claim->id; |
874 | attrs_record[i].data_size = sizeof (le->claim->id); | 879 | attrs_record[i].data_size = sizeof (le->claim->id); |
875 | attrs_record[i].expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us; | 880 | //FIXME: Should this be the attribute expiration time or ticket refresh intv |
881 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; | ||
876 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; | 882 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF; |
877 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 883 | attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
878 | i++; | 884 | i++; |
879 | } | 885 | } |
880 | attrs_record[i].data = &ih->ticket; | 886 | attrs_record[i].data = &ih->ticket; |
881 | attrs_record[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket); | 887 | attrs_record[i].data_size = sizeof (struct GNUNET_RECLAIM_Ticket); |
882 | attrs_record[i].expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us; | 888 | attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; |
883 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; | 889 | attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; |
884 | attrs_record[i].flags = | 890 | attrs_record[i].flags = |
885 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; | 891 | GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; |
@@ -999,6 +1005,20 @@ RECLAIM_TICKETS_iteration_start ( | |||
999 | int | 1005 | int |
1000 | RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) | 1006 | RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) |
1001 | { | 1007 | { |
1008 | // Get ticket expiration time (relative) from config | ||
1009 | if (GNUNET_OK | ||
1010 | == GNUNET_CONFIGURATION_get_value_time (c, | ||
1011 | "reclaim", | ||
1012 | "TICKET_REFRESH_INTERVAL", | ||
1013 | &ticket_refresh_interval)) { | ||
1014 | GNUNET_log ( | ||
1015 | GNUNET_ERROR_TYPE_DEBUG, | ||
1016 | "Configured refresh interval for tickets: %s\n", | ||
1017 | GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, | ||
1018 | GNUNET_YES)); | ||
1019 | } else { | ||
1020 | ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; | ||
1021 | } | ||
1002 | // Connect to identity and namestore services | 1022 | // Connect to identity and namestore services |
1003 | nsh = GNUNET_NAMESTORE_connect (c); | 1023 | nsh = GNUNET_NAMESTORE_connect (c); |
1004 | if (NULL == nsh) { | 1024 | if (NULL == nsh) { |