diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-06-03 21:22:50 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-06-03 21:22:50 +0200 |
commit | a00a49bf58c502ab860adaa6b01541c0e7e3e645 (patch) | |
tree | e9ece2ebffd1d0df735763fe5ebdfb2d334a496f /src/reclaim/gnunet-service-reclaim_tickets.c | |
parent | 34c8bfb80b82a1a7f7d3db3c41e705b09a1fad7e (diff) | |
download | gnunet-a00a49bf58c502ab860adaa6b01541c0e7e3e645.tar.gz gnunet-a00a49bf58c502ab860adaa6b01541c0e7e3e645.zip |
RECLAIM: Various fixes (coverity)
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim_tickets.c | 343 |
1 files changed, 236 insertions, 107 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c index d20a4e3bf..9a595447d 100644 --- a/src/reclaim/gnunet-service-reclaim_tickets.c +++ b/src/reclaim/gnunet-service-reclaim_tickets.c | |||
@@ -312,7 +312,7 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rh); | |||
312 | static void | 312 | static void |
313 | move_attrs_cont (void *cls) | 313 | move_attrs_cont (void *cls) |
314 | { | 314 | { |
315 | move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *)cls); | 315 | move_attrs ((struct RECLAIM_TICKETS_RevokeHandle *) cls); |
316 | } | 316 | } |
317 | 317 | ||
318 | /** | 318 | /** |
@@ -329,13 +329,16 @@ cleanup_rvk (struct RECLAIM_TICKETS_RevokeHandle *rh) | |||
329 | GNUNET_NAMESTORE_cancel (rh->ns_qe); | 329 | GNUNET_NAMESTORE_cancel (rh->ns_qe); |
330 | if (NULL != rh->ns_it) | 330 | if (NULL != rh->ns_it) |
331 | GNUNET_NAMESTORE_zone_iteration_stop (rh->ns_it); | 331 | GNUNET_NAMESTORE_zone_iteration_stop (rh->ns_it); |
332 | while (NULL != (ae = rh->attrs_head)) { | 332 | while (NULL != (ae = rh->attrs_head)) |
333 | { | ||
333 | GNUNET_CONTAINER_DLL_remove (rh->attrs_head, rh->attrs_tail, ae); | 334 | GNUNET_CONTAINER_DLL_remove (rh->attrs_head, rh->attrs_tail, ae); |
334 | GNUNET_free (ae); | 335 | GNUNET_free (ae); |
335 | } | 336 | } |
336 | while (NULL != (le = rh->tickets_to_update_head)) { | 337 | while (NULL != (le = rh->tickets_to_update_head)) |
338 | { | ||
337 | GNUNET_CONTAINER_DLL_remove (rh->tickets_to_update_head, | 339 | GNUNET_CONTAINER_DLL_remove (rh->tickets_to_update_head, |
338 | rh->tickets_to_update_head, le); | 340 | rh->tickets_to_update_head, |
341 | le); | ||
339 | if (NULL != le->data) | 342 | if (NULL != le->data) |
340 | GNUNET_free (le->data); | 343 | GNUNET_free (le->data); |
341 | if (NULL != le->label) | 344 | if (NULL != le->label) |
@@ -350,8 +353,10 @@ del_attr_finished (void *cls, int32_t success, const char *emsg) | |||
350 | { | 353 | { |
351 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 354 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
352 | rvk->ns_qe = NULL; | 355 | rvk->ns_qe = NULL; |
353 | if (GNUNET_SYSERR == success) { | 356 | if (GNUNET_SYSERR == success) |
354 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error removing attribute: %s\n", | 357 | { |
358 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
359 | "Error removing attribute: %s\n", | ||
355 | emsg); | 360 | emsg); |
356 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 361 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); |
357 | cleanup_rvk (rvk); | 362 | cleanup_rvk (rvk); |
@@ -367,7 +372,8 @@ move_attr_finished (void *cls, int32_t success, const char *emsg) | |||
367 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 372 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
368 | char *label; | 373 | char *label; |
369 | rvk->ns_qe = NULL; | 374 | rvk->ns_qe = NULL; |
370 | if (GNUNET_SYSERR == success) { | 375 | if (GNUNET_SYSERR == success) |
376 | { | ||
371 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); | 377 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error moving attribute: %s\n", emsg); |
372 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 378 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); |
373 | cleanup_rvk (rvk); | 379 | cleanup_rvk (rvk); |
@@ -375,15 +381,24 @@ move_attr_finished (void *cls, int32_t success, const char *emsg) | |||
375 | } | 381 | } |
376 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, | 382 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, |
377 | sizeof (uint64_t)); | 383 | sizeof (uint64_t)); |
384 | GNUNET_assert (NULL != label); | ||
378 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); | 385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing attribute %s\n", label); |
379 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &rvk->identity, label, 0, | 386 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
380 | NULL, &del_attr_finished, rvk); | 387 | &rvk->identity, |
388 | label, | ||
389 | 0, | ||
390 | NULL, | ||
391 | &del_attr_finished, | ||
392 | rvk); | ||
393 | GNUNET_free (label); | ||
381 | } | 394 | } |
382 | 395 | ||
383 | 396 | ||
384 | static void | 397 | static void |
385 | rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 398 | rvk_move_attr_cb (void *cls, |
386 | const char *label, unsigned int rd_count, | 399 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
400 | const char *label, | ||
401 | unsigned int rd_count, | ||
387 | const struct GNUNET_GNSRECORD_Data *rd) | 402 | const struct GNUNET_GNSRECORD_Data *rd) |
388 | { | 403 | { |
389 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 404 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
@@ -393,9 +408,11 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
393 | char *new_label; | 408 | char *new_label; |
394 | char *attr_data; | 409 | char *attr_data; |
395 | rvk->ns_qe = NULL; | 410 | rvk->ns_qe = NULL; |
396 | if (0 == rd_count) { | 411 | if (0 == rd_count) |
412 | { | ||
397 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 413 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
398 | "The attribute %s no longer exists!\n", label); | 414 | "The attribute %s no longer exists!\n", |
415 | label); | ||
399 | le = rvk->move_attr; | 416 | le = rvk->move_attr; |
400 | rvk->move_attr = le->next; | 417 | rvk->move_attr = le->next; |
401 | GNUNET_CONTAINER_DLL_remove (rvk->attrs_head, rvk->attrs_tail, le); | 418 | GNUNET_CONTAINER_DLL_remove (rvk->attrs_head, rvk->attrs_tail, le); |
@@ -409,7 +426,8 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
409 | new_rd = *rd; | 426 | new_rd = *rd; |
410 | claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); | 427 | claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); |
411 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 428 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
412 | "Attribute to update: Name=%s, ID=%" PRIu64 "\n", claim->name, | 429 | "Attribute to update: Name=%s, ID=%" PRIu64 "\n", |
430 | claim->name, | ||
413 | claim->id); | 431 | claim->id); |
414 | claim->id = rvk->move_attr->new_id; | 432 | claim->id = rvk->move_attr->new_id; |
415 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); | 433 | new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim); |
@@ -419,8 +437,13 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
419 | new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, | 437 | new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, |
420 | sizeof (uint64_t)); | 438 | sizeof (uint64_t)); |
421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); | 439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); |
422 | rvk->ns_qe = GNUNET_NAMESTORE_records_store ( | 440 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
423 | nsh, &rvk->identity, new_label, 1, &new_rd, &move_attr_finished, rvk); | 441 | &rvk->identity, |
442 | new_label, | ||
443 | 1, | ||
444 | &new_rd, | ||
445 | &move_attr_finished, | ||
446 | rvk); | ||
424 | GNUNET_free (new_label); | 447 | GNUNET_free (new_label); |
425 | GNUNET_free (claim); | 448 | GNUNET_free (claim); |
426 | GNUNET_free (attr_data); | 449 | GNUNET_free (attr_data); |
@@ -428,8 +451,10 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
428 | 451 | ||
429 | 452 | ||
430 | static void | 453 | static void |
431 | rvk_ticket_update (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 454 | rvk_ticket_update (void *cls, |
432 | const char *label, unsigned int rd_count, | 455 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
456 | const char *label, | ||
457 | unsigned int rd_count, | ||
433 | const struct GNUNET_GNSRECORD_Data *rd) | 458 | const struct GNUNET_GNSRECORD_Data *rd) |
434 | { | 459 | { |
435 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 460 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
@@ -438,10 +463,12 @@ rvk_ticket_update (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
438 | int has_changed = GNUNET_NO; | 463 | int has_changed = GNUNET_NO; |
439 | 464 | ||
440 | /** Let everything point to the old record **/ | 465 | /** Let everything point to the old record **/ |
441 | for (int i = 0; i < rd_count; i++) { | 466 | for (int i = 0; i < rd_count; i++) |
467 | { | ||
442 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 468 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
443 | continue; | 469 | continue; |
444 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) { | 470 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) |
471 | { | ||
445 | if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t))) | 472 | if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t))) |
446 | continue; | 473 | continue; |
447 | has_changed = GNUNET_YES; | 474 | has_changed = GNUNET_YES; |
@@ -450,7 +477,8 @@ rvk_ticket_update (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
450 | if (GNUNET_YES == has_changed) | 477 | if (GNUNET_YES == has_changed) |
451 | break; | 478 | break; |
452 | } | 479 | } |
453 | if (GNUNET_YES == has_changed) { | 480 | if (GNUNET_YES == has_changed) |
481 | { | ||
454 | le = GNUNET_new (struct TicketRecordsEntry); | 482 | le = GNUNET_new (struct TicketRecordsEntry); |
455 | le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); | 483 | le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd); |
456 | le->data = GNUNET_malloc (le->data_size); | 484 | le->data = GNUNET_malloc (le->data_size); |
@@ -458,7 +486,8 @@ rvk_ticket_update (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
458 | le->label = GNUNET_strdup (label); | 486 | le->label = GNUNET_strdup (label); |
459 | GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data); | 487 | GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data); |
460 | GNUNET_CONTAINER_DLL_insert (rvk->tickets_to_update_head, | 488 | GNUNET_CONTAINER_DLL_insert (rvk->tickets_to_update_head, |
461 | rvk->tickets_to_update_tail, le); | 489 | rvk->tickets_to_update_tail, |
490 | le); | ||
462 | } | 491 | } |
463 | GNUNET_NAMESTORE_zone_iterator_next (rvk->ns_it, 1); | 492 | GNUNET_NAMESTORE_zone_iterator_next (rvk->ns_it, 1); |
464 | } | 493 | } |
@@ -482,7 +511,8 @@ process_tickets (void *cls) | |||
482 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 511 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
483 | struct TicketRecordsEntry *le; | 512 | struct TicketRecordsEntry *le; |
484 | struct RevokedAttributeEntry *ae; | 513 | struct RevokedAttributeEntry *ae; |
485 | if (NULL == rvk->tickets_to_update_head) { | 514 | if (NULL == rvk->tickets_to_update_head) |
515 | { | ||
486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
487 | "Finished updatding tickets, success\n"); | 517 | "Finished updatding tickets, success\n"); |
488 | rvk->cb (rvk->cb_cls, GNUNET_OK); | 518 | rvk->cb (rvk->cb_cls, GNUNET_OK); |
@@ -491,21 +521,38 @@ process_tickets (void *cls) | |||
491 | } | 521 | } |
492 | le = rvk->tickets_to_update_head; | 522 | le = rvk->tickets_to_update_head; |
493 | GNUNET_CONTAINER_DLL_remove (rvk->tickets_to_update_head, | 523 | GNUNET_CONTAINER_DLL_remove (rvk->tickets_to_update_head, |
494 | rvk->tickets_to_update_tail, le); | 524 | rvk->tickets_to_update_tail, |
525 | le); | ||
495 | struct GNUNET_GNSRECORD_Data rd[le->rd_count]; | 526 | struct GNUNET_GNSRECORD_Data rd[le->rd_count]; |
496 | GNUNET_GNSRECORD_records_deserialize (le->data_size, le->data, le->rd_count, | 527 | if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (le->data_size, |
497 | rd); | 528 | le->data, |
498 | for (int i = 0; i < le->rd_count; i++) { | 529 | le->rd_count, |
530 | rd)) | ||
531 | { | ||
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
533 | "Unable to deserialize ticket record(s)\n"); | ||
534 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | ||
535 | cleanup_rvk (rvk); | ||
536 | return; | ||
537 | } | ||
538 | for (int i = 0; i < le->rd_count; i++) | ||
539 | { | ||
499 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 540 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
500 | continue; | 541 | continue; |
501 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) { | 542 | for (ae = rvk->attrs_head; NULL != ae; ae = ae->next) |
543 | { | ||
502 | if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t))) | 544 | if (0 != memcmp (rd[i].data, &ae->old_id, sizeof (uint64_t))) |
503 | continue; | 545 | continue; |
504 | rd[i].data = &ae->new_id; | 546 | rd[i].data = &ae->new_id; |
505 | } | 547 | } |
506 | } | 548 | } |
507 | rvk->ns_qe = GNUNET_NAMESTORE_records_store ( | 549 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
508 | nsh, &rvk->identity, le->label, le->rd_count, rd, &ticket_processed, rvk); | 550 | &rvk->identity, |
551 | le->label, | ||
552 | le->rd_count, | ||
553 | rd, | ||
554 | &ticket_processed, | ||
555 | rvk); | ||
509 | GNUNET_free (le->label); | 556 | GNUNET_free (le->label); |
510 | GNUNET_free (le->data); | 557 | GNUNET_free (le->data); |
511 | GNUNET_free (le); | 558 | GNUNET_free (le); |
@@ -551,19 +598,31 @@ move_attrs (struct RECLAIM_TICKETS_RevokeHandle *rvk) | |||
551 | { | 598 | { |
552 | char *label; | 599 | char *label; |
553 | 600 | ||
554 | if (NULL == rvk->move_attr) { | 601 | if (NULL == rvk->move_attr) |
602 | { | ||
555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); | 603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished moving attributes\n"); |
556 | rvk->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( | 604 | rvk->ns_it = |
557 | nsh, &rvk->identity, &rvk_ns_iter_err, rvk, &rvk_ticket_update, rvk, | 605 | GNUNET_NAMESTORE_zone_iteration_start (nsh, |
558 | &rvk_ticket_update_finished, rvk); | 606 | &rvk->identity, |
607 | &rvk_ns_iter_err, | ||
608 | rvk, | ||
609 | &rvk_ticket_update, | ||
610 | rvk, | ||
611 | &rvk_ticket_update_finished, | ||
612 | rvk); | ||
559 | return; | 613 | return; |
560 | } | 614 | } |
561 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, | 615 | label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->old_id, |
562 | sizeof (uint64_t)); | 616 | sizeof (uint64_t)); |
563 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); | 617 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Moving attribute %s\n", label); |
564 | 618 | ||
565 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( | 619 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, |
566 | nsh, &rvk->identity, label, &rvk_ns_err, rvk, &rvk_move_attr_cb, rvk); | 620 | &rvk->identity, |
621 | label, | ||
622 | &rvk_ns_err, | ||
623 | rvk, | ||
624 | &rvk_move_attr_cb, | ||
625 | rvk); | ||
567 | GNUNET_free (label); | 626 | GNUNET_free (label); |
568 | } | 627 | } |
569 | 628 | ||
@@ -573,14 +632,16 @@ remove_ticket_cont (void *cls, int32_t success, const char *emsg) | |||
573 | { | 632 | { |
574 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 633 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
575 | rvk->ns_qe = NULL; | 634 | rvk->ns_qe = NULL; |
576 | if (GNUNET_SYSERR == success) { | 635 | if (GNUNET_SYSERR == success) |
636 | { | ||
577 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); | 637 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); |
578 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); | 638 | rvk->cb (rvk->cb_cls, GNUNET_SYSERR); |
579 | cleanup_rvk (rvk); | 639 | cleanup_rvk (rvk); |
580 | return; | 640 | return; |
581 | } | 641 | } |
582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); | 642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted ticket\n"); |
583 | if (0 == rvk->ticket_attrs) { | 643 | if (0 == rvk->ticket_attrs) |
644 | { | ||
584 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 645 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
585 | "No attributes to move... strange\n"); | 646 | "No attributes to move... strange\n"); |
586 | rvk->cb (rvk->cb_cls, GNUNET_OK); | 647 | rvk->cb (rvk->cb_cls, GNUNET_OK); |
@@ -593,26 +654,34 @@ remove_ticket_cont (void *cls, int32_t success, const char *emsg) | |||
593 | 654 | ||
594 | 655 | ||
595 | static void | 656 | static void |
596 | revoke_attrs_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 657 | revoke_attrs_cb (void *cls, |
597 | const char *label, unsigned int rd_count, | 658 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
659 | const char *label, | ||
660 | unsigned int rd_count, | ||
598 | const struct GNUNET_GNSRECORD_Data *rd) | 661 | const struct GNUNET_GNSRECORD_Data *rd) |
599 | 662 | ||
600 | { | 663 | { |
601 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; | 664 | struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; |
602 | struct RevokedAttributeEntry *le; | 665 | struct RevokedAttributeEntry *le; |
603 | rvk->ns_qe = NULL; | 666 | rvk->ns_qe = NULL; |
604 | for (int i = 0; i < rd_count; i++) { | 667 | for (int i = 0; i < rd_count; i++) |
668 | { | ||
605 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 669 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
606 | continue; | 670 | continue; |
607 | le = GNUNET_new (struct RevokedAttributeEntry); | 671 | le = GNUNET_new (struct RevokedAttributeEntry); |
608 | le->old_id = *((uint64_t *)rd[i].data); | 672 | le->old_id = *((uint64_t *) rd[i].data); |
609 | GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le); | 673 | GNUNET_CONTAINER_DLL_insert (rvk->attrs_head, rvk->attrs_tail, le); |
610 | rvk->ticket_attrs++; | 674 | rvk->ticket_attrs++; |
611 | } | 675 | } |
612 | 676 | ||
613 | /** Now, remove ticket **/ | 677 | /** Now, remove ticket **/ |
614 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &rvk->identity, label, 0, | 678 | rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
615 | NULL, &remove_ticket_cont, rvk); | 679 | &rvk->identity, |
680 | label, | ||
681 | 0, | ||
682 | NULL, | ||
683 | &remove_ticket_cont, | ||
684 | rvk); | ||
616 | } | 685 | } |
617 | 686 | ||
618 | 687 | ||
@@ -628,7 +697,8 @@ rvk_attrs_err_cb (void *cls) | |||
628 | struct RECLAIM_TICKETS_RevokeHandle * | 697 | struct RECLAIM_TICKETS_RevokeHandle * |
629 | RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, | 698 | RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, |
630 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 699 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
631 | RECLAIM_TICKETS_RevokeCallback cb, void *cb_cls) | 700 | RECLAIM_TICKETS_RevokeCallback cb, |
701 | void *cb_cls) | ||
632 | { | 702 | { |
633 | struct RECLAIM_TICKETS_RevokeHandle *rvk; | 703 | struct RECLAIM_TICKETS_RevokeHandle *rvk; |
634 | char *label; | 704 | char *label; |
@@ -641,9 +711,14 @@ RECLAIM_TICKETS_revoke (const struct GNUNET_RECLAIM_Ticket *ticket, | |||
641 | GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity); | 711 | GNUNET_CRYPTO_ecdsa_key_get_public (&rvk->identity, &rvk->ticket.identity); |
642 | /** Get shared attributes **/ | 712 | /** Get shared attributes **/ |
643 | label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); | 713 | label = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof (uint64_t)); |
644 | 714 | GNUNET_assert (NULL != label); | |
645 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup ( | 715 | rvk->ns_qe = GNUNET_NAMESTORE_records_lookup (nsh, |
646 | nsh, identity, label, &rvk_attrs_err_cb, rvk, &revoke_attrs_cb, rvk); | 716 | identity, |
717 | label, | ||
718 | &rvk_attrs_err_cb, | ||
719 | rvk, | ||
720 | &revoke_attrs_cb, | ||
721 | rvk); | ||
647 | return rvk; | 722 | return rvk; |
648 | } | 723 | } |
649 | 724 | ||
@@ -669,12 +744,14 @@ cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) | |||
669 | GNUNET_GNS_lookup_cancel (cth->lookup_request); | 744 | GNUNET_GNS_lookup_cancel (cth->lookup_request); |
670 | if (NULL != cth->kill_task) | 745 | if (NULL != cth->kill_task) |
671 | GNUNET_SCHEDULER_cancel (cth->kill_task); | 746 | GNUNET_SCHEDULER_cancel (cth->kill_task); |
672 | while (NULL != (lu = cth->parallel_lookups_head)) { | 747 | while (NULL != (lu = cth->parallel_lookups_head)) |
748 | { | ||
673 | if (NULL != lu->lookup_request) | 749 | if (NULL != lu->lookup_request) |
674 | GNUNET_GNS_lookup_cancel (lu->lookup_request); | 750 | GNUNET_GNS_lookup_cancel (lu->lookup_request); |
675 | GNUNET_free_non_null (lu->label); | 751 | GNUNET_free_non_null (lu->label); |
676 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 752 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, |
677 | cth->parallel_lookups_tail, lu); | 753 | cth->parallel_lookups_tail, |
754 | lu); | ||
678 | GNUNET_free (lu); | 755 | GNUNET_free (lu); |
679 | } | 756 | } |
680 | 757 | ||
@@ -685,23 +762,27 @@ cleanup_cth (struct RECLAIM_TICKETS_ConsumeHandle *cth) | |||
685 | 762 | ||
686 | 763 | ||
687 | static void | 764 | static void |
688 | process_parallel_lookup_result (void *cls, uint32_t rd_count, | 765 | process_parallel_lookup_result (void *cls, |
766 | uint32_t rd_count, | ||
689 | const struct GNUNET_GNSRECORD_Data *rd) | 767 | const struct GNUNET_GNSRECORD_Data *rd) |
690 | { | 768 | { |
691 | struct ParallelLookup *parallel_lookup = cls; | 769 | struct ParallelLookup *parallel_lookup = cls; |
692 | struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; | 770 | struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; |
693 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; | 771 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; |
694 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parallel lookup finished (count=%u)\n", | 772 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
773 | "Parallel lookup finished (count=%u)\n", | ||
695 | rd_count); | 774 | rd_count); |
696 | 775 | ||
697 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 776 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, |
698 | cth->parallel_lookups_tail, parallel_lookup); | 777 | cth->parallel_lookups_tail, |
778 | parallel_lookup); | ||
699 | GNUNET_free (parallel_lookup->label); | 779 | GNUNET_free (parallel_lookup->label); |
700 | 780 | ||
701 | GNUNET_STATISTICS_update ( | 781 | GNUNET_STATISTICS_update (stats, |
702 | stats, "attribute_lookup_time_total", | 782 | "attribute_lookup_time_total", |
703 | GNUNET_TIME_absolute_get_duration (parallel_lookup->lookup_start_time) | 783 | GNUNET_TIME_absolute_get_duration ( |
704 | .rel_value_us, | 784 | parallel_lookup->lookup_start_time) |
785 | .rel_value_us, | ||
705 | GNUNET_YES); | 786 | GNUNET_YES); |
706 | GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES); | 787 | GNUNET_STATISTICS_update (stats, "attribute_lookups_count", 1, GNUNET_YES); |
707 | 788 | ||
@@ -709,11 +790,13 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count, | |||
709 | GNUNET_free (parallel_lookup); | 790 | GNUNET_free (parallel_lookup); |
710 | if (1 != rd_count) | 791 | if (1 != rd_count) |
711 | GNUNET_break (0); // TODO | 792 | GNUNET_break (0); // TODO |
712 | if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) { | 793 | if (rd->record_type == GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR) |
794 | { | ||
713 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); | 795 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
714 | attr_le->claim = | 796 | attr_le->claim = |
715 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); | 797 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size); |
716 | GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, cth->attrs->list_tail, | 798 | GNUNET_CONTAINER_DLL_insert (cth->attrs->list_head, |
799 | cth->attrs->list_tail, | ||
717 | attr_le); | 800 | attr_le); |
718 | } | 801 | } |
719 | if (NULL != cth->parallel_lookups_head) | 802 | if (NULL != cth->parallel_lookups_head) |
@@ -733,12 +816,14 @@ abort_parallel_lookups (void *cls) | |||
733 | struct ParallelLookup *tmp; | 816 | struct ParallelLookup *tmp; |
734 | 817 | ||
735 | cth->kill_task = NULL; | 818 | cth->kill_task = NULL; |
736 | for (lu = cth->parallel_lookups_head; NULL != lu;) { | 819 | for (lu = cth->parallel_lookups_head; NULL != lu;) |
820 | { | ||
737 | GNUNET_GNS_lookup_cancel (lu->lookup_request); | 821 | GNUNET_GNS_lookup_cancel (lu->lookup_request); |
738 | GNUNET_free (lu->label); | 822 | GNUNET_free (lu->label); |
739 | tmp = lu->next; | 823 | tmp = lu->next; |
740 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, | 824 | GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, |
741 | cth->parallel_lookups_tail, lu); | 825 | cth->parallel_lookups_tail, |
826 | lu); | ||
742 | GNUNET_free (lu); | 827 | GNUNET_free (lu); |
743 | lu = tmp; | 828 | lu = tmp; |
744 | } | 829 | } |
@@ -747,7 +832,8 @@ abort_parallel_lookups (void *cls) | |||
747 | 832 | ||
748 | 833 | ||
749 | static void | 834 | static void |
750 | lookup_authz_cb (void *cls, uint32_t rd_count, | 835 | lookup_authz_cb (void *cls, |
836 | uint32_t rd_count, | ||
751 | const struct GNUNET_GNSRECORD_Data *rd) | 837 | const struct GNUNET_GNSRECORD_Data *rd) |
752 | { | 838 | { |
753 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; | 839 | struct RECLAIM_TICKETS_ConsumeHandle *cth = cls; |
@@ -756,14 +842,19 @@ lookup_authz_cb (void *cls, uint32_t rd_count, | |||
756 | 842 | ||
757 | cth->lookup_request = NULL; | 843 | cth->lookup_request = NULL; |
758 | 844 | ||
759 | GNUNET_STATISTICS_update ( | 845 | GNUNET_STATISTICS_update (stats, |
760 | stats, "reclaim_authz_lookup_time_total", | 846 | "reclaim_authz_lookup_time_total", |
761 | GNUNET_TIME_absolute_get_duration (cth->lookup_start_time).rel_value_us, | 847 | GNUNET_TIME_absolute_get_duration ( |
848 | cth->lookup_start_time) | ||
849 | .rel_value_us, | ||
762 | GNUNET_YES); | 850 | GNUNET_YES); |
763 | GNUNET_STATISTICS_update (stats, "reclaim_authz_lookups_count", 1, | 851 | GNUNET_STATISTICS_update (stats, |
852 | "reclaim_authz_lookups_count", | ||
853 | 1, | ||
764 | GNUNET_YES); | 854 | GNUNET_YES); |
765 | 855 | ||
766 | for (int i = 0; i < rd_count; i++) { | 856 | for (int i = 0; i < rd_count; i++) |
857 | { | ||
767 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 858 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) |
768 | continue; | 859 | continue; |
769 | lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); | 860 | lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); |
@@ -772,17 +863,24 @@ lookup_authz_cb (void *cls, uint32_t rd_count, | |||
772 | parallel_lookup->handle = cth; | 863 | parallel_lookup->handle = cth; |
773 | parallel_lookup->label = lbl; | 864 | parallel_lookup->label = lbl; |
774 | parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); | 865 | parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get (); |
775 | parallel_lookup->lookup_request = GNUNET_GNS_lookup ( | 866 | parallel_lookup->lookup_request = |
776 | gns, lbl, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, | 867 | GNUNET_GNS_lookup (gns, |
777 | GNUNET_GNS_LO_DEFAULT, &process_parallel_lookup_result, | 868 | lbl, |
778 | parallel_lookup); | 869 | &cth->ticket.identity, |
870 | GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, | ||
871 | GNUNET_GNS_LO_DEFAULT, | ||
872 | &process_parallel_lookup_result, | ||
873 | parallel_lookup); | ||
779 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, | 874 | GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, |
780 | cth->parallel_lookups_tail, parallel_lookup); | 875 | cth->parallel_lookups_tail, |
876 | parallel_lookup); | ||
781 | } | 877 | } |
782 | if (NULL != cth->parallel_lookups_head) { | 878 | if (NULL != cth->parallel_lookups_head) |
879 | { | ||
783 | cth->kill_task = GNUNET_SCHEDULER_add_delayed ( | 880 | cth->kill_task = GNUNET_SCHEDULER_add_delayed ( |
784 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), | 881 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), |
785 | &abort_parallel_lookups, cth); | 882 | &abort_parallel_lookups, |
883 | cth); | ||
786 | return; | 884 | return; |
787 | } | 885 | } |
788 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); | 886 | cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); |
@@ -793,7 +891,8 @@ lookup_authz_cb (void *cls, uint32_t rd_count, | |||
793 | struct RECLAIM_TICKETS_ConsumeHandle * | 891 | struct RECLAIM_TICKETS_ConsumeHandle * |
794 | RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | 892 | RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, |
795 | const struct GNUNET_RECLAIM_Ticket *ticket, | 893 | const struct GNUNET_RECLAIM_Ticket *ticket, |
796 | RECLAIM_TICKETS_ConsumeCallback cb, void *cb_cls) | 894 | RECLAIM_TICKETS_ConsumeCallback cb, |
895 | void *cb_cls) | ||
797 | { | 896 | { |
798 | struct RECLAIM_TICKETS_ConsumeHandle *cth; | 897 | struct RECLAIM_TICKETS_ConsumeHandle *cth; |
799 | char *label; | 898 | char *label; |
@@ -807,12 +906,18 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id, | |||
807 | cth->cb_cls = cb_cls; | 906 | cth->cb_cls = cb_cls; |
808 | label = | 907 | label = |
809 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); | 908 | GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); |
810 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for AuthZ info under %s\n", | 909 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
910 | "Looking for AuthZ info under %s\n", | ||
811 | label); | 911 | label); |
812 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); | 912 | cth->lookup_start_time = GNUNET_TIME_absolute_get (); |
813 | cth->lookup_request = GNUNET_GNS_lookup ( | 913 | cth->lookup_request = |
814 | gns, label, &cth->ticket.identity, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, | 914 | GNUNET_GNS_lookup (gns, |
815 | GNUNET_GNS_LO_DEFAULT, &lookup_authz_cb, cth); | 915 | label, |
916 | &cth->ticket.identity, | ||
917 | GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, | ||
918 | GNUNET_GNS_LO_DEFAULT, | ||
919 | &lookup_authz_cb, | ||
920 | cth); | ||
816 | GNUNET_free (label); | 921 | GNUNET_free (label); |
817 | return cth; | 922 | return cth; |
818 | } | 923 | } |
@@ -848,8 +953,11 @@ store_ticket_issue_cont (void *cls, int32_t success, const char *emsg) | |||
848 | struct TicketIssueHandle *handle = cls; | 953 | struct TicketIssueHandle *handle = cls; |
849 | 954 | ||
850 | handle->ns_qe = NULL; | 955 | handle->ns_qe = NULL; |
851 | if (GNUNET_SYSERR == success) { | 956 | if (GNUNET_SYSERR == success) |
852 | handle->cb (handle->cb_cls, &handle->ticket, GNUNET_SYSERR, | 957 | { |
958 | handle->cb (handle->cb_cls, | ||
959 | &handle->ticket, | ||
960 | GNUNET_SYSERR, | ||
853 | "Error storing AuthZ ticket in GNS"); | 961 | "Error storing AuthZ ticket in GNS"); |
854 | return; | 962 | return; |
855 | } | 963 | } |
@@ -873,7 +981,8 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
873 | attrs_record = | 981 | attrs_record = |
874 | GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data)); | 982 | GNUNET_malloc (list_len * sizeof (struct GNUNET_GNSRECORD_Data)); |
875 | i = 0; | 983 | i = 0; |
876 | for (le = ih->attrs->list_head; NULL != le; le = le->next) { | 984 | for (le = ih->attrs->list_head; NULL != le; le = le->next) |
985 | { | ||
877 | attrs_record[i].data = &le->claim->id; | 986 | attrs_record[i].data = &le->claim->id; |
878 | attrs_record[i].data_size = sizeof (le->claim->id); | 987 | attrs_record[i].data_size = sizeof (le->claim->id); |
879 | //FIXME: Should this be the attribute expiration time or ticket refresh intv | 988 | //FIXME: Should this be the attribute expiration time or ticket refresh intv |
@@ -892,9 +1001,13 @@ issue_ticket (struct TicketIssueHandle *ih) | |||
892 | label = | 1001 | label = |
893 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); | 1002 | GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, sizeof (uint64_t)); |
894 | // Publish record | 1003 | // Publish record |
895 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &ih->identity, label, | 1004 | ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, |
896 | list_len, attrs_record, | 1005 | &ih->identity, |
897 | &store_ticket_issue_cont, ih); | 1006 | label, |
1007 | list_len, | ||
1008 | attrs_record, | ||
1009 | &store_ticket_issue_cont, | ||
1010 | ih); | ||
898 | GNUNET_free (attrs_record); | 1011 | GNUNET_free (attrs_record); |
899 | GNUNET_free (label); | 1012 | GNUNET_free (label); |
900 | } | 1013 | } |
@@ -904,7 +1017,8 @@ void | |||
904 | RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1017 | RECLAIM_TICKETS_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
905 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | 1018 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
906 | const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | 1019 | const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, |
907 | RECLAIM_TICKETS_TicketResult cb, void *cb_cls) | 1020 | RECLAIM_TICKETS_TicketResult cb, |
1021 | void *cb_cls) | ||
908 | { | 1022 | { |
909 | struct TicketIssueHandle *tih; | 1023 | struct TicketIssueHandle *tih; |
910 | tih = GNUNET_new (struct TicketIssueHandle); | 1024 | tih = GNUNET_new (struct TicketIssueHandle); |
@@ -933,16 +1047,19 @@ cleanup_iter (struct RECLAIM_TICKETS_Iterator *iter) | |||
933 | 1047 | ||
934 | 1048 | ||
935 | static void | 1049 | static void |
936 | collect_tickets_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1050 | collect_tickets_cb (void *cls, |
937 | const char *label, unsigned int rd_count, | 1051 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
1052 | const char *label, | ||
1053 | unsigned int rd_count, | ||
938 | const struct GNUNET_GNSRECORD_Data *rd) | 1054 | const struct GNUNET_GNSRECORD_Data *rd) |
939 | { | 1055 | { |
940 | struct RECLAIM_TICKETS_Iterator *iter = cls; | 1056 | struct RECLAIM_TICKETS_Iterator *iter = cls; |
941 | 1057 | ||
942 | for (int i = 0; i < rd_count; i++) { | 1058 | for (int i = 0; i < rd_count; i++) |
1059 | { | ||
943 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) | 1060 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type) |
944 | continue; | 1061 | continue; |
945 | iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *)rd[i].data); | 1062 | iter->cb (iter->cb_cls, (struct GNUNET_RECLAIM_Ticket *) rd[i].data); |
946 | return; | 1063 | return; |
947 | } | 1064 | } |
948 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); | 1065 | GNUNET_NAMESTORE_zone_iterator_next (iter->ns_it, 1); |
@@ -986,17 +1103,24 @@ RECLAIM_TICKETS_iteration_stop (struct RECLAIM_TICKETS_Iterator *iter) | |||
986 | 1103 | ||
987 | struct RECLAIM_TICKETS_Iterator * | 1104 | struct RECLAIM_TICKETS_Iterator * |
988 | RECLAIM_TICKETS_iteration_start ( | 1105 | RECLAIM_TICKETS_iteration_start ( |
989 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1106 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
990 | RECLAIM_TICKETS_TicketIter cb, void *cb_cls) | 1107 | RECLAIM_TICKETS_TicketIter cb, |
1108 | void *cb_cls) | ||
991 | { | 1109 | { |
992 | struct RECLAIM_TICKETS_Iterator *iter; | 1110 | struct RECLAIM_TICKETS_Iterator *iter; |
993 | 1111 | ||
994 | iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator); | 1112 | iter = GNUNET_new (struct RECLAIM_TICKETS_Iterator); |
995 | iter->cb = cb; | 1113 | iter->cb = cb; |
996 | iter->cb_cls = cb_cls; | 1114 | iter->cb_cls = cb_cls; |
997 | iter->ns_it = GNUNET_NAMESTORE_zone_iteration_start ( | 1115 | iter->ns_it = |
998 | nsh, identity, &collect_tickets_error_cb, iter, &collect_tickets_cb, iter, | 1116 | GNUNET_NAMESTORE_zone_iteration_start (nsh, |
999 | &collect_tickets_finished_cb, iter); | 1117 | identity, |
1118 | &collect_tickets_error_cb, | ||
1119 | iter, | ||
1120 | &collect_tickets_cb, | ||
1121 | iter, | ||
1122 | &collect_tickets_finished_cb, | ||
1123 | iter); | ||
1000 | return iter; | 1124 | return iter; |
1001 | } | 1125 | } |
1002 | 1126 | ||
@@ -1005,28 +1129,32 @@ int | |||
1005 | RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) | 1129 | RECLAIM_TICKETS_init (const struct GNUNET_CONFIGURATION_Handle *c) |
1006 | { | 1130 | { |
1007 | // Get ticket expiration time (relative) from config | 1131 | // Get ticket expiration time (relative) from config |
1008 | if (GNUNET_OK | 1132 | if (GNUNET_OK == |
1009 | == GNUNET_CONFIGURATION_get_value_time (c, | 1133 | GNUNET_CONFIGURATION_get_value_time (c, |
1010 | "reclaim", | 1134 | "reclaim", |
1011 | "TICKET_REFRESH_INTERVAL", | 1135 | "TICKET_REFRESH_INTERVAL", |
1012 | &ticket_refresh_interval)) { | 1136 | &ticket_refresh_interval)) |
1013 | GNUNET_log ( | 1137 | { |
1014 | GNUNET_ERROR_TYPE_DEBUG, | 1138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1015 | "Configured refresh interval for tickets: %s\n", | 1139 | "Configured refresh interval for tickets: %s\n", |
1016 | GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, | 1140 | GNUNET_STRINGS_relative_time_to_string (ticket_refresh_interval, |
1017 | GNUNET_YES)); | 1141 | GNUNET_YES)); |
1018 | } else { | 1142 | } |
1143 | else | ||
1144 | { | ||
1019 | ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; | 1145 | ticket_refresh_interval = DEFAULT_TICKET_REFRESH_INTERVAL; |
1020 | } | 1146 | } |
1021 | // Connect to identity and namestore services | 1147 | // Connect to identity and namestore services |
1022 | nsh = GNUNET_NAMESTORE_connect (c); | 1148 | nsh = GNUNET_NAMESTORE_connect (c); |
1023 | if (NULL == nsh) { | 1149 | if (NULL == nsh) |
1150 | { | ||
1024 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | 1151 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
1025 | "error connecting to namestore"); | 1152 | "error connecting to namestore"); |
1026 | return GNUNET_SYSERR; | 1153 | return GNUNET_SYSERR; |
1027 | } | 1154 | } |
1028 | gns = GNUNET_GNS_connect (c); | 1155 | gns = GNUNET_GNS_connect (c); |
1029 | if (NULL == gns) { | 1156 | if (NULL == gns) |
1157 | { | ||
1030 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); | 1158 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to gns"); |
1031 | return GNUNET_SYSERR; | 1159 | return GNUNET_SYSERR; |
1032 | } | 1160 | } |
@@ -1043,7 +1171,8 @@ RECLAIM_TICKETS_deinit (void) | |||
1043 | if (NULL != gns) | 1171 | if (NULL != gns) |
1044 | GNUNET_GNS_disconnect (gns); | 1172 | GNUNET_GNS_disconnect (gns); |
1045 | gns = NULL; | 1173 | gns = NULL; |
1046 | if (NULL != stats) { | 1174 | if (NULL != stats) |
1175 | { | ||
1047 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 1176 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
1048 | stats = NULL; | 1177 | stats = NULL; |
1049 | } | 1178 | } |