diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-08-20 16:35:26 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-08-20 16:35:26 +0200 |
commit | 1c987d24785f7e612925a9f36da05272a9099c90 (patch) | |
tree | 57876489b37819e6422910f6f19b6edc9f465961 /src/namestore/gnunet-service-namestore.c | |
parent | 9360690cf0e0a3be996323686a17008c77d07c9c (diff) | |
download | gnunet-1c987d24785f7e612925a9f36da05272a9099c90.tar.gz gnunet-1c987d24785f7e612925a9f36da05272a9099c90.zip |
fix ftbfs
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 820 |
1 files changed, 323 insertions, 497 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 4d23b91c6..3a925b952 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -35,7 +35,8 @@ | |||
35 | #include "gnunet_signatures.h" | 35 | #include "gnunet_signatures.h" |
36 | #include "namestore.h" | 36 | #include "namestore.h" |
37 | 37 | ||
38 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) | 38 | #define LOG_STRERROR_FILE(kind, syscall, filename) \ |
39 | GNUNET_log_from_strerror_file (kind, "util", syscall, filename) | ||
39 | 40 | ||
40 | /** | 41 | /** |
41 | * If a monitor takes more than 1 minute to process an event, print a warning. | 42 | * If a monitor takes more than 1 minute to process an event, print a warning. |
@@ -118,7 +119,6 @@ struct ZoneIteration | |||
118 | * message and free the data structure once @e cache_ops is zero. | 119 | * message and free the data structure once @e cache_ops is zero. |
119 | */ | 120 | */ |
120 | int send_end; | 121 | int send_end; |
121 | |||
122 | }; | 122 | }; |
123 | 123 | ||
124 | 124 | ||
@@ -227,7 +227,6 @@ struct ZoneMonitor | |||
227 | * that time, we clear the flag again. | 227 | * that time, we clear the flag again. |
228 | */ | 228 | */ |
229 | int sa_waiting; | 229 | int sa_waiting; |
230 | |||
231 | }; | 230 | }; |
232 | 231 | ||
233 | 232 | ||
@@ -306,7 +305,6 @@ struct StoreActivity | |||
306 | * Label nicely canonicalized (lower case). | 305 | * Label nicely canonicalized (lower case). |
307 | */ | 306 | */ |
308 | char *conv_name; | 307 | char *conv_name; |
309 | |||
310 | }; | 308 | }; |
311 | 309 | ||
312 | 310 | ||
@@ -426,16 +424,13 @@ cleanup_task (void *cls) | |||
426 | struct CacheOperation *cop; | 424 | struct CacheOperation *cop; |
427 | 425 | ||
428 | (void) cls; | 426 | (void) cls; |
429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n"); |
430 | "Stopping namestore service\n"); | ||
431 | while (NULL != (cop = cop_head)) | 428 | while (NULL != (cop = cop_head)) |
432 | { | 429 | { |
433 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 430 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
434 | "Aborting incomplete namecache operation\n"); | 431 | "Aborting incomplete namecache operation\n"); |
435 | GNUNET_NAMECACHE_cancel (cop->qe); | 432 | GNUNET_NAMECACHE_cancel (cop->qe); |
436 | GNUNET_CONTAINER_DLL_remove (cop_head, | 433 | GNUNET_CONTAINER_DLL_remove (cop_head, cop_tail, cop); |
437 | cop_tail, | ||
438 | cop); | ||
439 | GNUNET_free (cop); | 434 | GNUNET_free (cop); |
440 | } | 435 | } |
441 | if (NULL != namecache) | 436 | if (NULL != namecache) |
@@ -443,8 +438,7 @@ cleanup_task (void *cls) | |||
443 | GNUNET_NAMECACHE_disconnect (namecache); | 438 | GNUNET_NAMECACHE_disconnect (namecache); |
444 | namecache = NULL; | 439 | namecache = NULL; |
445 | } | 440 | } |
446 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, | 441 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, GSN_database)); |
447 | GSN_database)); | ||
448 | GNUNET_free (db_lib_name); | 442 | GNUNET_free (db_lib_name); |
449 | db_lib_name = NULL; | 443 | db_lib_name = NULL; |
450 | if (NULL != monitor_nc) | 444 | if (NULL != monitor_nc) |
@@ -454,8 +448,7 @@ cleanup_task (void *cls) | |||
454 | } | 448 | } |
455 | if (NULL != statistics) | 449 | if (NULL != statistics) |
456 | { | 450 | { |
457 | GNUNET_STATISTICS_destroy (statistics, | 451 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); |
458 | GNUNET_NO); | ||
459 | statistics = NULL; | 452 | statistics = NULL; |
460 | } | 453 | } |
461 | } | 454 | } |
@@ -469,9 +462,7 @@ cleanup_task (void *cls) | |||
469 | static void | 462 | static void |
470 | free_store_activity (struct StoreActivity *sa) | 463 | free_store_activity (struct StoreActivity *sa) |
471 | { | 464 | { |
472 | GNUNET_CONTAINER_DLL_remove (sa_head, | 465 | GNUNET_CONTAINER_DLL_remove (sa_head, sa_tail, sa); |
473 | sa_tail, | ||
474 | sa); | ||
475 | GNUNET_free (sa->conv_name); | 466 | GNUNET_free (sa->conv_name); |
476 | GNUNET_free (sa); | 467 | GNUNET_free (sa); |
477 | } | 468 | } |
@@ -491,7 +482,7 @@ free_store_activity (struct StoreActivity *sa) | |||
491 | */ | 482 | */ |
492 | static void | 483 | static void |
493 | lookup_nick_it (void *cls, | 484 | lookup_nick_it (void *cls, |
494 | uint64_t seq, | 485 | uint64_t seq, |
495 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 486 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
496 | const char *label, | 487 | const char *label, |
497 | unsigned int rd_count, | 488 | unsigned int rd_count, |
@@ -510,11 +501,10 @@ lookup_nick_it (void *cls, | |||
510 | { | 501 | { |
511 | if (GNUNET_GNSRECORD_TYPE_NICK == rd[c].record_type) | 502 | if (GNUNET_GNSRECORD_TYPE_NICK == rd[c].record_type) |
512 | { | 503 | { |
513 | (*res) = GNUNET_malloc (rd[c].data_size + sizeof (struct GNUNET_GNSRECORD_Data)); | 504 | (*res) = |
505 | GNUNET_malloc (rd[c].data_size + sizeof (struct GNUNET_GNSRECORD_Data)); | ||
514 | (*res)->data = &(*res)[1]; | 506 | (*res)->data = &(*res)[1]; |
515 | GNUNET_memcpy ((void *) (*res)->data, | 507 | GNUNET_memcpy ((void *) (*res)->data, rd[c].data, rd[c].data_size); |
516 | rd[c].data, | ||
517 | rd[c].data_size); | ||
518 | (*res)->data_size = rd[c].data_size; | 508 | (*res)->data_size = rd[c].data_size; |
519 | (*res)->expiration_time = rd[c].expiration_time; | 509 | (*res)->expiration_time = rd[c].expiration_time; |
520 | (*res)->flags = rd[c].flags; | 510 | (*res)->flags = rd[c].flags; |
@@ -534,21 +524,19 @@ lookup_nick_it (void *cls, | |||
534 | */ | 524 | */ |
535 | static void | 525 | static void |
536 | cache_nick (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 526 | cache_nick (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
537 | const struct GNUNET_GNSRECORD_Data *nick) | 527 | const struct GNUNET_GNSRECORD_Data *nick) |
538 | { | 528 | { |
539 | struct NickCache *oldest; | 529 | struct NickCache *oldest; |
540 | 530 | ||
541 | oldest = NULL; | 531 | oldest = NULL; |
542 | for (unsigned int i=0;i<NC_SIZE;i++) | 532 | for (unsigned int i = 0; i < NC_SIZE; i++) |
543 | { | 533 | { |
544 | struct NickCache *pos = &nick_cache[i]; | 534 | struct NickCache *pos = &nick_cache[i]; |
545 | 535 | ||
546 | if ( (NULL == oldest) || | 536 | if ((NULL == oldest) || |
547 | (oldest->last_used.abs_value_us > | 537 | (oldest->last_used.abs_value_us > pos->last_used.abs_value_us)) |
548 | pos->last_used.abs_value_us) ) | ||
549 | oldest = pos; | 538 | oldest = pos; |
550 | if (0 == GNUNET_memcmp (zone, | 539 | if (0 == GNUNET_memcmp (zone, &pos->zone)) |
551 | &pos->zone)) | ||
552 | { | 540 | { |
553 | oldest = pos; | 541 | oldest = pos; |
554 | break; | 542 | break; |
@@ -558,13 +546,10 @@ cache_nick (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | |||
558 | oldest->zone = *zone; | 546 | oldest->zone = *zone; |
559 | if (NULL != nick) | 547 | if (NULL != nick) |
560 | { | 548 | { |
561 | oldest->rd = GNUNET_malloc (sizeof (*nick) + | 549 | oldest->rd = GNUNET_malloc (sizeof (*nick) + nick->data_size); |
562 | nick->data_size); | ||
563 | *oldest->rd = *nick; | 550 | *oldest->rd = *nick; |
564 | oldest->rd->data = &oldest->rd[1]; | 551 | oldest->rd->data = &oldest->rd[1]; |
565 | memcpy (&oldest->rd[1], | 552 | memcpy (&oldest->rd[1], nick->data, nick->data_size); |
566 | nick->data, | ||
567 | nick->data_size); | ||
568 | } | 553 | } |
569 | else | 554 | else |
570 | { | 555 | { |
@@ -588,22 +573,17 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone) | |||
588 | int res; | 573 | int res; |
589 | 574 | ||
590 | /* check cache first */ | 575 | /* check cache first */ |
591 | for (unsigned int i=0;i<NC_SIZE;i++) | 576 | for (unsigned int i = 0; i < NC_SIZE; i++) |
592 | { | 577 | { |
593 | struct NickCache *pos = &nick_cache[i]; | 578 | struct NickCache *pos = &nick_cache[i]; |
594 | if ( (NULL != pos->rd) && | 579 | if ((NULL != pos->rd) && (0 == GNUNET_memcmp (zone, &pos->zone))) |
595 | (0 == GNUNET_memcmp (zone, | ||
596 | &pos->zone)) ) | ||
597 | { | 580 | { |
598 | if (NULL == pos->rd) | 581 | if (NULL == pos->rd) |
599 | return NULL; | 582 | return NULL; |
600 | nick = GNUNET_malloc (sizeof (*nick) + | 583 | nick = GNUNET_malloc (sizeof (*nick) + pos->rd->data_size); |
601 | pos->rd->data_size); | ||
602 | *nick = *pos->rd; | 584 | *nick = *pos->rd; |
603 | nick->data = &nick[1]; | 585 | nick->data = &nick[1]; |
604 | memcpy (&nick[1], | 586 | memcpy (&nick[1], pos->rd->data, pos->rd->data_size); |
605 | pos->rd->data, | ||
606 | pos->rd->data_size); | ||
607 | pos->last_used = GNUNET_TIME_absolute_get (); | 587 | pos->last_used = GNUNET_TIME_absolute_get (); |
608 | return nick; | 588 | return nick; |
609 | } | 589 | } |
@@ -611,38 +591,36 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone) | |||
611 | 591 | ||
612 | nick = NULL; | 592 | nick = NULL; |
613 | res = GSN_database->lookup_records (GSN_database->cls, | 593 | res = GSN_database->lookup_records (GSN_database->cls, |
614 | zone, | 594 | zone, |
615 | GNUNET_GNS_EMPTY_LABEL_AT, | 595 | GNUNET_GNS_EMPTY_LABEL_AT, |
616 | &lookup_nick_it, | 596 | &lookup_nick_it, |
617 | &nick); | 597 | &nick); |
618 | if ( (GNUNET_OK != res) || | 598 | if ((GNUNET_OK != res) || (NULL == nick)) |
619 | (NULL == nick) ) | ||
620 | { | 599 | { |
600 | #if ! defined(GNUNET_CULL_LOGGING) | ||
621 | static int do_log = GNUNET_LOG_CALL_STATUS; | 601 | static int do_log = GNUNET_LOG_CALL_STATUS; |
622 | 602 | ||
623 | if (0 == do_log) | 603 | if (0 == do_log) |
624 | do_log | 604 | do_log = GNUNET_get_log_call_status (GNUNET_ERROR_TYPE_DEBUG, |
625 | = GNUNET_get_log_call_status (GNUNET_ERROR_TYPE_DEBUG, | 605 | "namestore", |
626 | "namestore", | 606 | __FILE__, |
627 | __FILE__, | 607 | __FUNCTION__, |
628 | __FUNCTION__, | 608 | __LINE__); |
629 | __LINE__); | ||
630 | if (1 == do_log) | 609 | if (1 == do_log) |
631 | { | 610 | { |
632 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub); | 611 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub); |
633 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 612 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
634 | "No nick name set for zone `%s'\n", | 613 | "No nick name set for zone `%s'\n", |
635 | GNUNET_GNSRECORD_z2s (&pub)); | 614 | GNUNET_GNSRECORD_z2s (&pub)); |
636 | } | 615 | } |
616 | #endif | ||
637 | /* update cache */ | 617 | /* update cache */ |
638 | cache_nick (zone, | 618 | cache_nick (zone, NULL); |
639 | NULL); | ||
640 | return NULL; | 619 | return NULL; |
641 | } | 620 | } |
642 | 621 | ||
643 | /* update cache */ | 622 | /* update cache */ |
644 | cache_nick (zone, | 623 | cache_nick (zone, nick); |
645 | nick); | ||
646 | return nick; | 624 | return nick; |
647 | } | 625 | } |
648 | 626 | ||
@@ -683,7 +661,7 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd, | |||
683 | return; | 661 | return; |
684 | } | 662 | } |
685 | req = sizeof (struct GNUNET_GNSRECORD_Data) + nick_rd->data_size; | 663 | req = sizeof (struct GNUNET_GNSRECORD_Data) + nick_rd->data_size; |
686 | for (unsigned int i=0; i<rd2_length; i++) | 664 | for (unsigned int i = 0; i < rd2_length; i++) |
687 | { | 665 | { |
688 | const struct GNUNET_GNSRECORD_Data *orig = &rd2[i]; | 666 | const struct GNUNET_GNSRECORD_Data *orig = &rd2[i]; |
689 | 667 | ||
@@ -700,13 +678,13 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd, | |||
700 | data = (char *) &target[1 + rd2_length]; | 678 | data = (char *) &target[1 + rd2_length]; |
701 | data_offset = 0; | 679 | data_offset = 0; |
702 | latest_expiration = 0; | 680 | latest_expiration = 0; |
703 | for (unsigned int i=0;i<rd2_length;i++) | 681 | for (unsigned int i = 0; i < rd2_length; i++) |
704 | { | 682 | { |
705 | const struct GNUNET_GNSRECORD_Data *orig = &rd2[i]; | 683 | const struct GNUNET_GNSRECORD_Data *orig = &rd2[i]; |
706 | 684 | ||
707 | if (0 != (orig->flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | 685 | if (0 != (orig->flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) |
708 | { | 686 | { |
709 | if ((GNUNET_TIME_absolute_get().abs_value_us + orig->expiration_time) > | 687 | if ((GNUNET_TIME_absolute_get ().abs_value_us + orig->expiration_time) > |
710 | latest_expiration) | 688 | latest_expiration) |
711 | latest_expiration = orig->expiration_time; | 689 | latest_expiration = orig->expiration_time; |
712 | } | 690 | } |
@@ -714,21 +692,17 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd, | |||
714 | latest_expiration = orig->expiration_time; | 692 | latest_expiration = orig->expiration_time; |
715 | target[i] = *orig; | 693 | target[i] = *orig; |
716 | target[i].data = (void *) &data[data_offset]; | 694 | target[i].data = (void *) &data[data_offset]; |
717 | GNUNET_memcpy (&data[data_offset], | 695 | GNUNET_memcpy (&data[data_offset], orig->data, orig->data_size); |
718 | orig->data, | ||
719 | orig->data_size); | ||
720 | data_offset += orig->data_size; | 696 | data_offset += orig->data_size; |
721 | } | 697 | } |
722 | /* append nick */ | 698 | /* append nick */ |
723 | target[rd2_length] = *nick_rd; | 699 | target[rd2_length] = *nick_rd; |
724 | target[rd2_length].expiration_time = latest_expiration; | 700 | target[rd2_length].expiration_time = latest_expiration; |
725 | target[rd2_length].data = (void *) &data[data_offset]; | 701 | target[rd2_length].data = (void *) &data[data_offset]; |
726 | GNUNET_memcpy (&data[data_offset], | 702 | GNUNET_memcpy (&data[data_offset], nick_rd->data, nick_rd->data_size); |
727 | nick_rd->data, | ||
728 | nick_rd->data_size); | ||
729 | data_offset += nick_rd->data_size; | 703 | data_offset += nick_rd->data_size; |
730 | GNUNET_assert (req == | 704 | GNUNET_assert (req == (sizeof (struct GNUNET_GNSRECORD_Data)) * (*rdc_res) + |
731 | (sizeof (struct GNUNET_GNSRECORD_Data)) * (*rdc_res) + data_offset); | 705 | data_offset); |
732 | } | 706 | } |
733 | 707 | ||
734 | 708 | ||
@@ -745,11 +719,11 @@ merge_with_nick_records (const struct GNUNET_GNSRECORD_Data *nick_rd, | |||
745 | */ | 719 | */ |
746 | static void | 720 | static void |
747 | send_lookup_response (struct NamestoreClient *nc, | 721 | send_lookup_response (struct NamestoreClient *nc, |
748 | uint32_t request_id, | 722 | uint32_t request_id, |
749 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 723 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
750 | const char *name, | 724 | const char *name, |
751 | unsigned int rd_count, | 725 | unsigned int rd_count, |
752 | const struct GNUNET_GNSRECORD_Data *rd) | 726 | const struct GNUNET_GNSRECORD_Data *rd) |
753 | { | 727 | { |
754 | struct GNUNET_MQ_Envelope *env; | 728 | struct GNUNET_MQ_Envelope *env; |
755 | struct RecordResultMessage *zir_msg; | 729 | struct RecordResultMessage *zir_msg; |
@@ -762,20 +736,13 @@ send_lookup_response (struct NamestoreClient *nc, | |||
762 | char *rd_ser; | 736 | char *rd_ser; |
763 | 737 | ||
764 | nick = get_nick_record (zone_key); | 738 | nick = get_nick_record (zone_key); |
765 | GNUNET_assert (-1 != | 739 | GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (rd_count, rd)); |
766 | GNUNET_GNSRECORD_records_get_size (rd_count, | ||
767 | rd)); | ||
768 | 740 | ||
769 | if ( (NULL != nick) && | 741 | if ((NULL != nick) && (0 != strcmp (name, GNUNET_GNS_EMPTY_LABEL_AT))) |
770 | (0 != strcmp (name, | ||
771 | GNUNET_GNS_EMPTY_LABEL_AT))) | ||
772 | { | 742 | { |
773 | nick->flags = (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; | 743 | nick->flags = |
774 | merge_with_nick_records (nick, | 744 | (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; |
775 | rd_count, | 745 | merge_with_nick_records (nick, rd_count, rd, &res_count, &res); |
776 | rd, | ||
777 | &res_count, | ||
778 | &res); | ||
779 | GNUNET_free (nick); | 746 | GNUNET_free (nick); |
780 | } | 747 | } |
781 | else | 748 | else |
@@ -784,14 +751,11 @@ send_lookup_response (struct NamestoreClient *nc, | |||
784 | res = (struct GNUNET_GNSRECORD_Data *) rd; | 751 | res = (struct GNUNET_GNSRECORD_Data *) rd; |
785 | } | 752 | } |
786 | 753 | ||
787 | GNUNET_assert (-1 != | 754 | GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (res_count, res)); |
788 | GNUNET_GNSRECORD_records_get_size (res_count, | ||
789 | res)); | ||
790 | 755 | ||
791 | 756 | ||
792 | name_len = strlen (name) + 1; | 757 | name_len = strlen (name) + 1; |
793 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, | 758 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res); |
794 | res); | ||
795 | if (rd_ser_len < 0) | 759 | if (rd_ser_len < 0) |
796 | { | 760 | { |
797 | GNUNET_break (0); | 761 | GNUNET_break (0); |
@@ -805,32 +769,27 @@ send_lookup_response (struct NamestoreClient *nc, | |||
805 | return; | 769 | return; |
806 | } | 770 | } |
807 | env = GNUNET_MQ_msg_extra (zir_msg, | 771 | env = GNUNET_MQ_msg_extra (zir_msg, |
808 | name_len + rd_ser_len, | 772 | name_len + rd_ser_len, |
809 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT); | 773 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT); |
810 | zir_msg->gns_header.r_id = htonl (request_id); | 774 | zir_msg->gns_header.r_id = htonl (request_id); |
811 | zir_msg->name_len = htons (name_len); | 775 | zir_msg->name_len = htons (name_len); |
812 | zir_msg->rd_count = htons (res_count); | 776 | zir_msg->rd_count = htons (res_count); |
813 | zir_msg->rd_len = htons ((uint16_t) rd_ser_len); | 777 | zir_msg->rd_len = htons ((uint16_t) rd_ser_len); |
814 | zir_msg->private_key = *zone_key; | 778 | zir_msg->private_key = *zone_key; |
815 | name_tmp = (char *) &zir_msg[1]; | 779 | name_tmp = (char *) &zir_msg[1]; |
816 | GNUNET_memcpy (name_tmp, | 780 | GNUNET_memcpy (name_tmp, name, name_len); |
817 | name, | ||
818 | name_len); | ||
819 | rd_ser = &name_tmp[name_len]; | 781 | rd_ser = &name_tmp[name_len]; |
820 | GNUNET_assert (rd_ser_len == | 782 | GNUNET_assert ( |
821 | GNUNET_GNSRECORD_records_serialize (res_count, | 783 | rd_ser_len == |
822 | res, | 784 | GNUNET_GNSRECORD_records_serialize (res_count, res, rd_ser_len, rd_ser)); |
823 | rd_ser_len, | ||
824 | rd_ser)); | ||
825 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 785 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
826 | "Sending RECORD_RESULT message with %u records\n", | 786 | "Sending RECORD_RESULT message with %u records\n", |
827 | res_count); | 787 | res_count); |
828 | GNUNET_STATISTICS_update (statistics, | 788 | GNUNET_STATISTICS_update (statistics, |
829 | "Record sets sent to clients", | 789 | "Record sets sent to clients", |
830 | 1, | 790 | 1, |
831 | GNUNET_NO); | 791 | GNUNET_NO); |
832 | GNUNET_MQ_send (nc->mq, | 792 | GNUNET_MQ_send (nc->mq, env); |
833 | env); | ||
834 | if (rd != res) | 793 | if (rd != res) |
835 | GNUNET_free (res); | 794 | GNUNET_free (res); |
836 | } | 795 | } |
@@ -844,26 +803,23 @@ send_lookup_response (struct NamestoreClient *nc, | |||
844 | * @param rid client's request ID | 803 | * @param rid client's request ID |
845 | */ | 804 | */ |
846 | static void | 805 | static void |
847 | send_store_response (struct NamestoreClient *nc, | 806 | send_store_response (struct NamestoreClient *nc, int res, uint32_t rid) |
848 | int res, | ||
849 | uint32_t rid) | ||
850 | { | 807 | { |
851 | struct GNUNET_MQ_Envelope *env; | 808 | struct GNUNET_MQ_Envelope *env; |
852 | struct RecordStoreResponseMessage *rcr_msg; | 809 | struct RecordStoreResponseMessage *rcr_msg; |
853 | 810 | ||
854 | GNUNET_assert (NULL != nc); | 811 | GNUNET_assert (NULL != nc); |
855 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
856 | "Sending RECORD_STORE_RESPONSE message\n"); | 813 | "Sending RECORD_STORE_RESPONSE message\n"); |
857 | GNUNET_STATISTICS_update (statistics, | 814 | GNUNET_STATISTICS_update (statistics, |
858 | "Store requests completed", | 815 | "Store requests completed", |
859 | 1, | 816 | 1, |
860 | GNUNET_NO); | 817 | GNUNET_NO); |
861 | env = GNUNET_MQ_msg (rcr_msg, | 818 | env = GNUNET_MQ_msg (rcr_msg, |
862 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE); | 819 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE); |
863 | rcr_msg->gns_header.r_id = htonl (rid); | 820 | rcr_msg->gns_header.r_id = htonl (rid); |
864 | rcr_msg->op_result = htonl (res); | 821 | rcr_msg->op_result = htonl (res); |
865 | GNUNET_MQ_send (nc->mq, | 822 | GNUNET_MQ_send (nc->mq, env); |
866 | env); | ||
867 | } | 823 | } |
868 | 824 | ||
869 | 825 | ||
@@ -883,15 +839,11 @@ zone_iteration_done_client_continue (struct ZoneIteration *zi) | |||
883 | if (! zi->send_end) | 839 | if (! zi->send_end) |
884 | return; | 840 | return; |
885 | /* send empty response to indicate end of list */ | 841 | /* send empty response to indicate end of list */ |
886 | env = GNUNET_MQ_msg (em, | 842 | env = GNUNET_MQ_msg (em, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END); |
887 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END); | ||
888 | em->r_id = htonl (zi->request_id); | 843 | em->r_id = htonl (zi->request_id); |
889 | GNUNET_MQ_send (zi->nc->mq, | 844 | GNUNET_MQ_send (zi->nc->mq, env); |
890 | env); | ||
891 | 845 | ||
892 | GNUNET_CONTAINER_DLL_remove (zi->nc->op_head, | 846 | GNUNET_CONTAINER_DLL_remove (zi->nc->op_head, zi->nc->op_tail, zi); |
893 | zi->nc->op_tail, | ||
894 | zi); | ||
895 | GNUNET_free (zi); | 847 | GNUNET_free (zi); |
896 | } | 848 | } |
897 | 849 | ||
@@ -904,36 +856,29 @@ zone_iteration_done_client_continue (struct ZoneIteration *zi) | |||
904 | * @param emsg error messages | 856 | * @param emsg error messages |
905 | */ | 857 | */ |
906 | static void | 858 | static void |
907 | finish_cache_operation (void *cls, | 859 | finish_cache_operation (void *cls, int32_t success, const char *emsg) |
908 | int32_t success, | ||
909 | const char *emsg) | ||
910 | { | 860 | { |
911 | struct CacheOperation *cop = cls; | 861 | struct CacheOperation *cop = cls; |
912 | struct ZoneIteration *zi; | 862 | struct ZoneIteration *zi; |
913 | 863 | ||
914 | if (NULL != emsg) | 864 | if (NULL != emsg) |
915 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 865 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
916 | _("Failed to replicate block in namecache: %s\n"), | 866 | _ ("Failed to replicate block in namecache: %s\n"), |
917 | emsg); | 867 | emsg); |
918 | else | 868 | else |
919 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 869 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CACHE operation completed\n"); |
920 | "CACHE operation completed\n"); | 870 | GNUNET_CONTAINER_DLL_remove (cop_head, cop_tail, cop); |
921 | GNUNET_CONTAINER_DLL_remove (cop_head, | ||
922 | cop_tail, | ||
923 | cop); | ||
924 | if (NULL != cop->nc) | 871 | if (NULL != cop->nc) |
925 | send_store_response (cop->nc, | 872 | send_store_response (cop->nc, success, cop->rid); |
926 | success, | ||
927 | cop->rid); | ||
928 | if (NULL != (zi = cop->zi)) | 873 | if (NULL != (zi = cop->zi)) |
874 | { | ||
875 | zi->cache_ops--; | ||
876 | if (0 == zi->cache_ops) | ||
929 | { | 877 | { |
930 | zi->cache_ops--; | 878 | /* unchoke zone iteration, cache has caught up */ |
931 | if (0 == zi->cache_ops) | 879 | zone_iteration_done_client_continue (zi); |
932 | { | ||
933 | /* unchoke zone iteration, cache has caught up */ | ||
934 | zone_iteration_done_client_continue (zi); | ||
935 | } | ||
936 | } | 880 | } |
881 | } | ||
937 | GNUNET_free (cop); | 882 | GNUNET_free (cop); |
938 | } | 883 | } |
939 | 884 | ||
@@ -952,7 +897,7 @@ finish_cache_operation (void *cls, | |||
952 | */ | 897 | */ |
953 | static void | 898 | static void |
954 | refresh_block (struct NamestoreClient *nc, | 899 | refresh_block (struct NamestoreClient *nc, |
955 | struct ZoneIteration *zi, | 900 | struct ZoneIteration *zi, |
956 | uint32_t rid, | 901 | uint32_t rid, |
957 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 902 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
958 | const char *name, | 903 | const char *name, |
@@ -972,56 +917,43 @@ refresh_block (struct NamestoreClient *nc, | |||
972 | res = (struct GNUNET_GNSRECORD_Data *) rd; /* fixme: a bit unclean... */ | 917 | res = (struct GNUNET_GNSRECORD_Data *) rd; /* fixme: a bit unclean... */ |
973 | if (NULL != nick) | 918 | if (NULL != nick) |
974 | { | 919 | { |
975 | nick->flags = (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; | 920 | nick->flags = |
976 | merge_with_nick_records (nick, | 921 | (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; |
977 | rd_count,rd, | 922 | merge_with_nick_records (nick, rd_count, rd, &res_count, &res); |
978 | &res_count, | ||
979 | &res); | ||
980 | GNUNET_free (nick); | 923 | GNUNET_free (nick); |
981 | } | 924 | } |
982 | if (0 == res_count) | 925 | if (0 == res_count) |
983 | { | 926 | { |
984 | if (NULL != nc) | 927 | if (NULL != nc) |
985 | send_store_response (nc, | 928 | send_store_response (nc, GNUNET_OK, rid); |
986 | GNUNET_OK, | ||
987 | rid); | ||
988 | return; /* no data, no need to update cache */ | 929 | return; /* no data, no need to update cache */ |
989 | } | 930 | } |
990 | if (GNUNET_YES == disable_namecache) | 931 | if (GNUNET_YES == disable_namecache) |
991 | { | 932 | { |
992 | GNUNET_STATISTICS_update (statistics, | 933 | GNUNET_STATISTICS_update (statistics, |
993 | "Namecache updates skipped (NC disabled)", | 934 | "Namecache updates skipped (NC disabled)", |
994 | 1, | 935 | 1, |
995 | GNUNET_NO); | 936 | GNUNET_NO); |
996 | if (NULL != nc) | 937 | if (NULL != nc) |
997 | send_store_response (nc, | 938 | send_store_response (nc, GNUNET_OK, rid); |
998 | GNUNET_OK, | ||
999 | rid); | ||
1000 | return; | 939 | return; |
1001 | } | 940 | } |
1002 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, | 941 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res); |
1003 | res); | ||
1004 | if (cache_keys) | 942 | if (cache_keys) |
1005 | block = GNUNET_GNSRECORD_block_create2 (zone_key, | 943 | block = |
1006 | exp_time, | 944 | GNUNET_GNSRECORD_block_create2 (zone_key, exp_time, name, res, res_count); |
1007 | name, | ||
1008 | res, | ||
1009 | res_count); | ||
1010 | else | 945 | else |
1011 | block = GNUNET_GNSRECORD_block_create (zone_key, | 946 | block = |
1012 | exp_time, | 947 | GNUNET_GNSRECORD_block_create (zone_key, exp_time, name, res, res_count); |
1013 | name, | ||
1014 | res, | ||
1015 | res_count); | ||
1016 | GNUNET_assert (NULL != block); | 948 | GNUNET_assert (NULL != block); |
1017 | GNUNET_CRYPTO_ecdsa_key_get_public (zone_key, | 949 | GNUNET_CRYPTO_ecdsa_key_get_public (zone_key, &pkey); |
1018 | &pkey); | 950 | GNUNET_log ( |
1019 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 951 | GNUNET_ERROR_TYPE_DEBUG, |
1020 | "Caching block for label `%s' with %u records and expiration %s in zone `%s' in namecache\n", | 952 | "Caching block for label `%s' with %u records and expiration %s in zone `%s' in namecache\n", |
1021 | name, | 953 | name, |
1022 | res_count, | 954 | res_count, |
1023 | GNUNET_STRINGS_absolute_time_to_string (exp_time), | 955 | GNUNET_STRINGS_absolute_time_to_string (exp_time), |
1024 | GNUNET_GNSRECORD_z2s (&pkey)); | 956 | GNUNET_GNSRECORD_z2s (&pkey)); |
1025 | GNUNET_STATISTICS_update (statistics, | 957 | GNUNET_STATISTICS_update (statistics, |
1026 | "Namecache updates pushed", | 958 | "Namecache updates pushed", |
1027 | 1, | 959 | 1, |
@@ -1032,9 +964,7 @@ refresh_block (struct NamestoreClient *nc, | |||
1032 | if (NULL != zi) | 964 | if (NULL != zi) |
1033 | zi->cache_ops++; | 965 | zi->cache_ops++; |
1034 | cop->rid = rid; | 966 | cop->rid = rid; |
1035 | GNUNET_CONTAINER_DLL_insert (cop_head, | 967 | GNUNET_CONTAINER_DLL_insert (cop_head, cop_tail, cop); |
1036 | cop_tail, | ||
1037 | cop); | ||
1038 | cop->qe = GNUNET_NAMECACHE_block_cache (namecache, | 968 | cop->qe = GNUNET_NAMECACHE_block_cache (namecache, |
1039 | block, | 969 | block, |
1040 | &finish_cache_operation, | 970 | &finish_cache_operation, |
@@ -1085,36 +1015,31 @@ continue_store_activity (struct StoreActivity *sa) | |||
1085 | name_tmp = (const char *) &rp_msg[1]; | 1015 | name_tmp = (const char *) &rp_msg[1]; |
1086 | rd_ser = &name_tmp[name_len]; | 1016 | rd_ser = &name_tmp[name_len]; |
1087 | { | 1017 | { |
1088 | struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)]; | 1018 | struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL (rd_count)]; |
1089 | 1019 | ||
1090 | /* We did this before, must succeed again */ | 1020 | /* We did this before, must succeed again */ |
1091 | GNUNET_assert (GNUNET_OK == | 1021 | GNUNET_assert ( |
1092 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, | 1022 | GNUNET_OK == |
1093 | rd_ser, | 1023 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, rd_ser, rd_count, rd)); |
1094 | rd_count, | 1024 | |
1095 | rd)); | 1025 | for (struct ZoneMonitor *zm = sa->zm_pos; NULL != zm; zm = sa->zm_pos) |
1096 | |||
1097 | for (struct ZoneMonitor *zm = sa->zm_pos; | ||
1098 | NULL != zm; | ||
1099 | zm = sa->zm_pos) | ||
1100 | { | 1026 | { |
1101 | if ( (0 != GNUNET_memcmp (&rp_msg->private_key, | 1027 | if ((0 != GNUNET_memcmp (&rp_msg->private_key, &zm->zone)) && |
1102 | &zm->zone)) && | 1028 | (0 != GNUNET_memcmp (&zm->zone, &zero))) |
1103 | (0 != GNUNET_memcmp (&zm->zone, | 1029 | { |
1104 | &zero)) ) | 1030 | sa->zm_pos = zm->next; /* not interesting to this monitor */ |
1105 | { | 1031 | continue; |
1106 | sa->zm_pos = zm->next; /* not interesting to this monitor */ | 1032 | } |
1107 | continue; | ||
1108 | } | ||
1109 | if (zm->limit == zm->iteration_cnt) | 1033 | if (zm->limit == zm->iteration_cnt) |
1110 | { | 1034 | { |
1111 | zm->sa_waiting = GNUNET_YES; | 1035 | zm->sa_waiting = GNUNET_YES; |
1112 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); | 1036 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); |
1113 | if (NULL != zm->sa_wait_warning) | 1037 | if (NULL != zm->sa_wait_warning) |
1114 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | 1038 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); |
1115 | zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, | 1039 | zm->sa_wait_warning = |
1116 | &warn_monitor_slow, | 1040 | GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, |
1117 | zm); | 1041 | &warn_monitor_slow, |
1042 | zm); | ||
1118 | return; /* blocked on zone monitor */ | 1043 | return; /* blocked on zone monitor */ |
1119 | } | 1044 | } |
1120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1045 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1131,7 +1056,7 @@ continue_store_activity (struct StoreActivity *sa) | |||
1131 | } | 1056 | } |
1132 | /* great, done with the monitors, unpack (again) for refresh_block operation */ | 1057 | /* great, done with the monitors, unpack (again) for refresh_block operation */ |
1133 | refresh_block (sa->nc, | 1058 | refresh_block (sa->nc, |
1134 | NULL, | 1059 | NULL, |
1135 | rid, | 1060 | rid, |
1136 | &rp_msg->private_key, | 1061 | &rp_msg->private_key, |
1137 | sa->conv_name, | 1062 | sa->conv_name, |
@@ -1153,26 +1078,22 @@ continue_store_activity (struct StoreActivity *sa) | |||
1153 | */ | 1078 | */ |
1154 | static void | 1079 | static void |
1155 | client_disconnect_cb (void *cls, | 1080 | client_disconnect_cb (void *cls, |
1156 | struct GNUNET_SERVICE_Client *client, | 1081 | struct GNUNET_SERVICE_Client *client, |
1157 | void *app_ctx) | 1082 | void *app_ctx) |
1158 | { | 1083 | { |
1159 | struct NamestoreClient *nc = app_ctx; | 1084 | struct NamestoreClient *nc = app_ctx; |
1160 | struct ZoneIteration *no; | 1085 | struct ZoneIteration *no; |
1161 | struct CacheOperation *cop; | 1086 | struct CacheOperation *cop; |
1162 | 1087 | ||
1163 | (void) cls; | 1088 | (void) cls; |
1164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1089 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client); |
1165 | "Client %p disconnected\n", | ||
1166 | client); | ||
1167 | for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next) | 1090 | for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next) |
1168 | { | 1091 | { |
1169 | struct StoreActivity *san; | 1092 | struct StoreActivity *san; |
1170 | 1093 | ||
1171 | if (nc != zm->nc) | 1094 | if (nc != zm->nc) |
1172 | continue; | 1095 | continue; |
1173 | GNUNET_CONTAINER_DLL_remove (monitor_head, | 1096 | GNUNET_CONTAINER_DLL_remove (monitor_head, monitor_tail, zm); |
1174 | monitor_tail, | ||
1175 | zm); | ||
1176 | if (NULL != zm->task) | 1097 | if (NULL != zm->task) |
1177 | { | 1098 | { |
1178 | GNUNET_SCHEDULER_cancel (zm->task); | 1099 | GNUNET_SCHEDULER_cancel (zm->task); |
@@ -1207,9 +1128,7 @@ client_disconnect_cb (void *cls, | |||
1207 | } | 1128 | } |
1208 | while (NULL != (no = nc->op_head)) | 1129 | while (NULL != (no = nc->op_head)) |
1209 | { | 1130 | { |
1210 | GNUNET_CONTAINER_DLL_remove (nc->op_head, | 1131 | GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no); |
1211 | nc->op_tail, | ||
1212 | no); | ||
1213 | GNUNET_free (no); | 1132 | GNUNET_free (no); |
1214 | } | 1133 | } |
1215 | for (cop = cop_head; NULL != cop; cop = cop->next) | 1134 | for (cop = cop_head; NULL != cop; cop = cop->next) |
@@ -1229,15 +1148,13 @@ client_disconnect_cb (void *cls, | |||
1229 | */ | 1148 | */ |
1230 | static void * | 1149 | static void * |
1231 | client_connect_cb (void *cls, | 1150 | client_connect_cb (void *cls, |
1232 | struct GNUNET_SERVICE_Client *client, | 1151 | struct GNUNET_SERVICE_Client *client, |
1233 | struct GNUNET_MQ_Handle *mq) | 1152 | struct GNUNET_MQ_Handle *mq) |
1234 | { | 1153 | { |
1235 | struct NamestoreClient *nc; | 1154 | struct NamestoreClient *nc; |
1236 | 1155 | ||
1237 | (void) cls; | 1156 | (void) cls; |
1238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client); |
1239 | "Client %p connected\n", | ||
1240 | client); | ||
1241 | nc = GNUNET_new (struct NamestoreClient); | 1158 | nc = GNUNET_new (struct NamestoreClient); |
1242 | nc->client = client; | 1159 | nc->client = client; |
1243 | nc->mq = mq; | 1160 | nc->mq = mq; |
@@ -1297,7 +1214,7 @@ struct RecordLookupContext | |||
1297 | */ | 1214 | */ |
1298 | static void | 1215 | static void |
1299 | lookup_it (void *cls, | 1216 | lookup_it (void *cls, |
1300 | uint64_t seq, | 1217 | uint64_t seq, |
1301 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, | 1218 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, |
1302 | const char *label, | 1219 | const char *label, |
1303 | unsigned int rd_count, | 1220 | unsigned int rd_count, |
@@ -1307,8 +1224,7 @@ lookup_it (void *cls, | |||
1307 | 1224 | ||
1308 | (void) private_key; | 1225 | (void) private_key; |
1309 | GNUNET_assert (0 != seq); | 1226 | GNUNET_assert (0 != seq); |
1310 | if (0 != strcmp (label, | 1227 | if (0 != strcmp (label, rlc->label)) |
1311 | rlc->label)) | ||
1312 | return; | 1228 | return; |
1313 | rlc->found = GNUNET_YES; | 1229 | rlc->found = GNUNET_YES; |
1314 | if (0 == rd_count) | 1230 | if (0 == rd_count) |
@@ -1318,9 +1234,7 @@ lookup_it (void *cls, | |||
1318 | rlc->res_rd = NULL; | 1234 | rlc->res_rd = NULL; |
1319 | return; | 1235 | return; |
1320 | } | 1236 | } |
1321 | if ( (NULL != rlc->nick) && | 1237 | if ((NULL != rlc->nick) && (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT))) |
1322 | (0 != strcmp (label, | ||
1323 | GNUNET_GNS_EMPTY_LABEL_AT)) ) | ||
1324 | { | 1238 | { |
1325 | /* Merge */ | 1239 | /* Merge */ |
1326 | struct GNUNET_GNSRECORD_Data *rd_res; | 1240 | struct GNUNET_GNSRECORD_Data *rd_res; |
@@ -1328,36 +1242,31 @@ lookup_it (void *cls, | |||
1328 | 1242 | ||
1329 | rd_res = NULL; | 1243 | rd_res = NULL; |
1330 | rdc_res = 0; | 1244 | rdc_res = 0; |
1331 | rlc->nick->flags = (rlc->nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; | 1245 | rlc->nick->flags = (rlc->nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ |
1332 | merge_with_nick_records (rlc->nick, | 1246 | GNUNET_GNSRECORD_RF_PRIVATE; |
1333 | rd_count, | 1247 | merge_with_nick_records (rlc->nick, rd_count, rd, &rdc_res, &rd_res); |
1334 | rd, | 1248 | rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res, rd_res); |
1335 | &rdc_res, | ||
1336 | &rd_res); | ||
1337 | rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res, | ||
1338 | rd_res); | ||
1339 | if (rlc->rd_ser_len < 0) | 1249 | if (rlc->rd_ser_len < 0) |
1340 | { | 1250 | { |
1341 | GNUNET_break (0); | 1251 | GNUNET_break (0); |
1342 | GNUNET_free (rd_res); | 1252 | GNUNET_free (rd_res); |
1343 | rlc->found = GNUNET_NO; | 1253 | rlc->found = GNUNET_NO; |
1344 | rlc->rd_ser_len = 0; | 1254 | rlc->rd_ser_len = 0; |
1345 | return; | 1255 | return; |
1346 | } | 1256 | } |
1347 | rlc->res_rd_count = rdc_res; | 1257 | rlc->res_rd_count = rdc_res; |
1348 | rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len); | 1258 | rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len); |
1349 | if (rlc->rd_ser_len != | 1259 | if (rlc->rd_ser_len != GNUNET_GNSRECORD_records_serialize (rdc_res, |
1350 | GNUNET_GNSRECORD_records_serialize (rdc_res, | 1260 | rd_res, |
1351 | rd_res, | 1261 | rlc->rd_ser_len, |
1352 | rlc->rd_ser_len, | 1262 | rlc->res_rd)) |
1353 | rlc->res_rd)) | ||
1354 | { | 1263 | { |
1355 | GNUNET_break (0); | 1264 | GNUNET_break (0); |
1356 | GNUNET_free (rlc->res_rd); | 1265 | GNUNET_free (rlc->res_rd); |
1357 | rlc->res_rd = NULL; | 1266 | rlc->res_rd = NULL; |
1358 | rlc->res_rd_count = 0; | 1267 | rlc->res_rd_count = 0; |
1359 | rlc->rd_ser_len = 0; | 1268 | rlc->rd_ser_len = 0; |
1360 | GNUNET_free (rd_res); | 1269 | GNUNET_free (rd_res); |
1361 | rlc->found = GNUNET_NO; | 1270 | rlc->found = GNUNET_NO; |
1362 | return; | 1271 | return; |
1363 | } | 1272 | } |
@@ -1367,8 +1276,7 @@ lookup_it (void *cls, | |||
1367 | } | 1276 | } |
1368 | else | 1277 | else |
1369 | { | 1278 | { |
1370 | rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, | 1279 | rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd); |
1371 | rd); | ||
1372 | if (rlc->rd_ser_len < 0) | 1280 | if (rlc->rd_ser_len < 0) |
1373 | { | 1281 | { |
1374 | GNUNET_break (0); | 1282 | GNUNET_break (0); |
@@ -1378,14 +1286,13 @@ lookup_it (void *cls, | |||
1378 | } | 1286 | } |
1379 | rlc->res_rd_count = rd_count; | 1287 | rlc->res_rd_count = rd_count; |
1380 | rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len); | 1288 | rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len); |
1381 | if (rlc->rd_ser_len != | 1289 | if (rlc->rd_ser_len != GNUNET_GNSRECORD_records_serialize (rd_count, |
1382 | GNUNET_GNSRECORD_records_serialize (rd_count, | 1290 | rd, |
1383 | rd, | 1291 | rlc->rd_ser_len, |
1384 | rlc->rd_ser_len, | 1292 | rlc->res_rd)) |
1385 | rlc->res_rd)) | ||
1386 | { | 1293 | { |
1387 | GNUNET_break (0); | 1294 | GNUNET_break (0); |
1388 | GNUNET_free (rlc->res_rd); | 1295 | GNUNET_free (rlc->res_rd); |
1389 | rlc->res_rd = NULL; | 1296 | rlc->res_rd = NULL; |
1390 | rlc->res_rd_count = 0; | 1297 | rlc->res_rd_count = 0; |
1391 | rlc->rd_ser_len = 0; | 1298 | rlc->rd_ser_len = 0; |
@@ -1404,8 +1311,7 @@ lookup_it (void *cls, | |||
1404 | * @return #GNUNET_OK if @a ll_msg is well-formed | 1311 | * @return #GNUNET_OK if @a ll_msg is well-formed |
1405 | */ | 1312 | */ |
1406 | static int | 1313 | static int |
1407 | check_record_lookup (void *cls, | 1314 | check_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) |
1408 | const struct LabelLookupMessage *ll_msg) | ||
1409 | { | 1315 | { |
1410 | uint32_t name_len; | 1316 | uint32_t name_len; |
1411 | size_t src_size; | 1317 | size_t src_size; |
@@ -1430,8 +1336,7 @@ check_record_lookup (void *cls, | |||
1430 | * @param ll_msg message of type `struct LabelLookupMessage` | 1336 | * @param ll_msg message of type `struct LabelLookupMessage` |
1431 | */ | 1337 | */ |
1432 | static void | 1338 | static void |
1433 | handle_record_lookup (void *cls, | 1339 | handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg) |
1434 | const struct LabelLookupMessage *ll_msg) | ||
1435 | { | 1340 | { |
1436 | struct NamestoreClient *nc = cls; | 1341 | struct NamestoreClient *nc = cls; |
1437 | struct GNUNET_MQ_Envelope *env; | 1342 | struct GNUNET_MQ_Envelope *env; |
@@ -1471,27 +1376,23 @@ handle_record_lookup (void *cls, | |||
1471 | &lookup_it, | 1376 | &lookup_it, |
1472 | &rlc); | 1377 | &rlc); |
1473 | GNUNET_free (conv_name); | 1378 | GNUNET_free (conv_name); |
1474 | env = GNUNET_MQ_msg_extra (llr_msg, | 1379 | env = |
1475 | name_len + rlc.rd_ser_len, | 1380 | GNUNET_MQ_msg_extra (llr_msg, |
1476 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE); | 1381 | name_len + rlc.rd_ser_len, |
1382 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE); | ||
1477 | llr_msg->gns_header.r_id = ll_msg->gns_header.r_id; | 1383 | llr_msg->gns_header.r_id = ll_msg->gns_header.r_id; |
1478 | llr_msg->private_key = ll_msg->zone; | 1384 | llr_msg->private_key = ll_msg->zone; |
1479 | llr_msg->name_len = htons (name_len); | 1385 | llr_msg->name_len = htons (name_len); |
1480 | llr_msg->rd_count = htons (rlc.res_rd_count); | 1386 | llr_msg->rd_count = htons (rlc.res_rd_count); |
1481 | llr_msg->rd_len = htons (rlc.rd_ser_len); | 1387 | llr_msg->rd_len = htons (rlc.rd_ser_len); |
1482 | res_name = (char *) &llr_msg[1]; | 1388 | res_name = (char *) &llr_msg[1]; |
1483 | if ((GNUNET_YES == rlc.found) && (GNUNET_OK == res)) | 1389 | if ((GNUNET_YES == rlc.found) && (GNUNET_OK == res)) |
1484 | llr_msg->found = ntohs (GNUNET_YES); | 1390 | llr_msg->found = ntohs (GNUNET_YES); |
1485 | else | 1391 | else |
1486 | llr_msg->found = ntohs (GNUNET_NO); | 1392 | llr_msg->found = ntohs (GNUNET_NO); |
1487 | GNUNET_memcpy (&llr_msg[1], | 1393 | GNUNET_memcpy (&llr_msg[1], name_tmp, name_len); |
1488 | name_tmp, | 1394 | GNUNET_memcpy (&res_name[name_len], rlc.res_rd, rlc.rd_ser_len); |
1489 | name_len); | 1395 | GNUNET_MQ_send (nc->mq, env); |
1490 | GNUNET_memcpy (&res_name[name_len], | ||
1491 | rlc.res_rd, | ||
1492 | rlc.rd_ser_len); | ||
1493 | GNUNET_MQ_send (nc->mq, | ||
1494 | env); | ||
1495 | GNUNET_free_non_null (rlc.res_rd); | 1396 | GNUNET_free_non_null (rlc.res_rd); |
1496 | } | 1397 | } |
1497 | 1398 | ||
@@ -1504,8 +1405,7 @@ handle_record_lookup (void *cls, | |||
1504 | * @return #GNUNET_OK if @a rp_msg is well-formed | 1405 | * @return #GNUNET_OK if @a rp_msg is well-formed |
1505 | */ | 1406 | */ |
1506 | static int | 1407 | static int |
1507 | check_record_store (void *cls, | 1408 | check_record_store (void *cls, const struct RecordStoreMessage *rp_msg) |
1508 | const struct RecordStoreMessage *rp_msg) | ||
1509 | { | 1409 | { |
1510 | size_t name_len; | 1410 | size_t name_len; |
1511 | size_t msg_size; | 1411 | size_t msg_size; |
@@ -1523,14 +1423,13 @@ check_record_store (void *cls, | |||
1523 | GNUNET_break (0); | 1423 | GNUNET_break (0); |
1524 | return GNUNET_SYSERR; | 1424 | return GNUNET_SYSERR; |
1525 | } | 1425 | } |
1526 | if ( (0 == name_len) || | 1426 | if ((0 == name_len) || (name_len > MAX_NAME_LEN)) |
1527 | (name_len > MAX_NAME_LEN) ) | ||
1528 | { | 1427 | { |
1529 | GNUNET_break (0); | 1428 | GNUNET_break (0); |
1530 | return GNUNET_SYSERR; | 1429 | return GNUNET_SYSERR; |
1531 | } | 1430 | } |
1532 | name_tmp = (const char *) &rp_msg[1]; | 1431 | name_tmp = (const char *) &rp_msg[1]; |
1533 | if ('\0' != name_tmp[name_len -1]) | 1432 | if ('\0' != name_tmp[name_len - 1]) |
1534 | { | 1433 | { |
1535 | GNUNET_break (0); | 1434 | GNUNET_break (0); |
1536 | return GNUNET_SYSERR; | 1435 | return GNUNET_SYSERR; |
@@ -1546,8 +1445,7 @@ check_record_store (void *cls, | |||
1546 | * @param rp_msg message of type `struct RecordStoreMessage` | 1445 | * @param rp_msg message of type `struct RecordStoreMessage` |
1547 | */ | 1446 | */ |
1548 | static void | 1447 | static void |
1549 | handle_record_store (void *cls, | 1448 | handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg) |
1550 | const struct RecordStoreMessage *rp_msg) | ||
1551 | { | 1449 | { |
1552 | struct NamestoreClient *nc = cls; | 1450 | struct NamestoreClient *nc = cls; |
1553 | size_t name_len; | 1451 | size_t name_len; |
@@ -1561,7 +1459,7 @@ handle_record_store (void *cls, | |||
1561 | struct StoreActivity *sa; | 1459 | struct StoreActivity *sa; |
1562 | 1460 | ||
1563 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1564 | "Received NAMESTORE_RECORD_STORE message\n"); | 1462 | "Received NAMESTORE_RECORD_STORE message\n"); |
1565 | rid = ntohl (rp_msg->gns_header.r_id); | 1463 | rid = ntohl (rp_msg->gns_header.r_id); |
1566 | name_len = ntohs (rp_msg->name_len); | 1464 | name_len = ntohs (rp_msg->name_len); |
1567 | rd_count = ntohs (rp_msg->rd_count); | 1465 | rd_count = ntohs (rp_msg->rd_count); |
@@ -1570,13 +1468,10 @@ handle_record_store (void *cls, | |||
1570 | name_tmp = (const char *) &rp_msg[1]; | 1468 | name_tmp = (const char *) &rp_msg[1]; |
1571 | rd_ser = &name_tmp[name_len]; | 1469 | rd_ser = &name_tmp[name_len]; |
1572 | { | 1470 | { |
1573 | struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)]; | 1471 | struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL (rd_count)]; |
1574 | 1472 | ||
1575 | if (GNUNET_OK != | 1473 | if (GNUNET_OK != |
1576 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, | 1474 | GNUNET_GNSRECORD_records_deserialize (rd_ser_len, rd_ser, rd_count, rd)) |
1577 | rd_ser, | ||
1578 | rd_count, | ||
1579 | rd)) | ||
1580 | { | 1475 | { |
1581 | GNUNET_break (0); | 1476 | GNUNET_break (0); |
1582 | GNUNET_SERVICE_client_drop (nc->client); | 1477 | GNUNET_SERVICE_client_drop (nc->client); |
@@ -1598,16 +1493,15 @@ handle_record_store (void *cls, | |||
1598 | 1, | 1493 | 1, |
1599 | GNUNET_NO); | 1494 | GNUNET_NO); |
1600 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1601 | "Creating %u records for name `%s'\n", | 1496 | "Creating %u records for name `%s'\n", |
1602 | (unsigned int) rd_count, | 1497 | (unsigned int) rd_count, |
1603 | conv_name); | 1498 | conv_name); |
1604 | if ( (0 == rd_count) && | 1499 | if ((0 == rd_count) && |
1605 | (GNUNET_NO == | 1500 | (GNUNET_NO == GSN_database->lookup_records (GSN_database->cls, |
1606 | GSN_database->lookup_records (GSN_database->cls, | 1501 | &rp_msg->private_key, |
1607 | &rp_msg->private_key, | 1502 | conv_name, |
1608 | conv_name, | 1503 | NULL, |
1609 | NULL, | 1504 | 0))) |
1610 | 0)) ) | ||
1611 | { | 1505 | { |
1612 | /* This name does not exist, so cannot be removed */ | 1506 | /* This name does not exist, so cannot be removed */ |
1613 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1507 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1619,50 +1513,43 @@ handle_record_store (void *cls, | |||
1619 | { | 1513 | { |
1620 | /* remove "NICK" records, unless this is for the | 1514 | /* remove "NICK" records, unless this is for the |
1621 | #GNUNET_GNS_EMPTY_LABEL_AT label */ | 1515 | #GNUNET_GNS_EMPTY_LABEL_AT label */ |
1622 | struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL(rd_count)]; | 1516 | struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL (rd_count)]; |
1623 | unsigned int rd_clean_off; | 1517 | unsigned int rd_clean_off; |
1624 | int have_nick; | 1518 | int have_nick; |
1625 | 1519 | ||
1626 | rd_clean_off = 0; | 1520 | rd_clean_off = 0; |
1627 | have_nick = GNUNET_NO; | 1521 | have_nick = GNUNET_NO; |
1628 | for (unsigned int i=0;i<rd_count;i++) | 1522 | for (unsigned int i = 0; i < rd_count; i++) |
1629 | { | 1523 | { |
1630 | rd_clean[rd_clean_off] = rd[i]; | 1524 | rd_clean[rd_clean_off] = rd[i]; |
1631 | if ( (0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, | 1525 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) || |
1632 | conv_name)) || | 1526 | (GNUNET_GNSRECORD_TYPE_NICK != rd[i].record_type)) |
1633 | (GNUNET_GNSRECORD_TYPE_NICK != rd[i].record_type) ) | ||
1634 | rd_clean_off++; | 1527 | rd_clean_off++; |
1635 | 1528 | ||
1636 | if ( (0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, | 1529 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && |
1637 | conv_name)) && | 1530 | (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type)) |
1638 | (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) ) | 1531 | { |
1639 | { | 1532 | cache_nick (&rp_msg->private_key, &rd[i]); |
1640 | cache_nick (&rp_msg->private_key, | 1533 | have_nick = GNUNET_YES; |
1641 | &rd[i]); | 1534 | } |
1642 | have_nick = GNUNET_YES; | ||
1643 | } | ||
1644 | } | 1535 | } |
1645 | if ( (0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, | 1536 | if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) && |
1646 | conv_name)) && | 1537 | (GNUNET_NO == have_nick)) |
1647 | (GNUNET_NO == have_nick) ) | ||
1648 | { | 1538 | { |
1649 | /* remove nick record from cache, in case we have one there */ | 1539 | /* remove nick record from cache, in case we have one there */ |
1650 | cache_nick (&rp_msg->private_key, | 1540 | cache_nick (&rp_msg->private_key, NULL); |
1651 | NULL); | ||
1652 | } | 1541 | } |
1653 | res = GSN_database->store_records (GSN_database->cls, | 1542 | res = GSN_database->store_records (GSN_database->cls, |
1654 | &rp_msg->private_key, | 1543 | &rp_msg->private_key, |
1655 | conv_name, | 1544 | conv_name, |
1656 | rd_clean_off, | 1545 | rd_clean_off, |
1657 | rd_clean); | 1546 | rd_clean); |
1658 | } | 1547 | } |
1659 | 1548 | ||
1660 | if (GNUNET_OK != res) | 1549 | if (GNUNET_OK != res) |
1661 | { | 1550 | { |
1662 | /* store not successful, not need to tell monitors */ | 1551 | /* store not successful, not need to tell monitors */ |
1663 | send_store_response (nc, | 1552 | send_store_response (nc, res, rid); |
1664 | res, | ||
1665 | rid); | ||
1666 | GNUNET_SERVICE_client_continue (nc->client); | 1553 | GNUNET_SERVICE_client_continue (nc->client); |
1667 | GNUNET_free (conv_name); | 1554 | GNUNET_free (conv_name); |
1668 | return; | 1555 | return; |
@@ -1670,14 +1557,10 @@ handle_record_store (void *cls, | |||
1670 | 1557 | ||
1671 | sa = GNUNET_malloc (sizeof (struct StoreActivity) + | 1558 | sa = GNUNET_malloc (sizeof (struct StoreActivity) + |
1672 | ntohs (rp_msg->gns_header.header.size)); | 1559 | ntohs (rp_msg->gns_header.header.size)); |
1673 | GNUNET_CONTAINER_DLL_insert (sa_head, | 1560 | GNUNET_CONTAINER_DLL_insert (sa_head, sa_tail, sa); |
1674 | sa_tail, | ||
1675 | sa); | ||
1676 | sa->nc = nc; | 1561 | sa->nc = nc; |
1677 | sa->rsm = (const struct RecordStoreMessage *) &sa[1]; | 1562 | sa->rsm = (const struct RecordStoreMessage *) &sa[1]; |
1678 | GNUNET_memcpy (&sa[1], | 1563 | GNUNET_memcpy (&sa[1], rp_msg, ntohs (rp_msg->gns_header.header.size)); |
1679 | rp_msg, | ||
1680 | ntohs (rp_msg->gns_header.header.size)); | ||
1681 | sa->zm_pos = monitor_head; | 1564 | sa->zm_pos = monitor_head; |
1682 | sa->conv_name = conv_name; | 1565 | sa->conv_name = conv_name; |
1683 | continue_store_activity (sa); | 1566 | continue_store_activity (sa); |
@@ -1722,11 +1605,11 @@ struct ZoneToNameCtx | |||
1722 | */ | 1605 | */ |
1723 | static void | 1606 | static void |
1724 | handle_zone_to_name_it (void *cls, | 1607 | handle_zone_to_name_it (void *cls, |
1725 | uint64_t seq, | 1608 | uint64_t seq, |
1726 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1609 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1727 | const char *name, | 1610 | const char *name, |
1728 | unsigned int rd_count, | 1611 | unsigned int rd_count, |
1729 | const struct GNUNET_GNSRECORD_Data *rd) | 1612 | const struct GNUNET_GNSRECORD_Data *rd) |
1730 | { | 1613 | { |
1731 | struct ZoneToNameCtx *ztn_ctx = cls; | 1614 | struct ZoneToNameCtx *ztn_ctx = cls; |
1732 | struct GNUNET_MQ_Envelope *env; | 1615 | struct GNUNET_MQ_Envelope *env; |
@@ -1740,12 +1623,11 @@ handle_zone_to_name_it (void *cls, | |||
1740 | 1623 | ||
1741 | GNUNET_assert (0 != seq); | 1624 | GNUNET_assert (0 != seq); |
1742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1625 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1743 | "Found result for zone-to-name lookup: `%s'\n", | 1626 | "Found result for zone-to-name lookup: `%s'\n", |
1744 | name); | 1627 | name); |
1745 | res = GNUNET_YES; | 1628 | res = GNUNET_YES; |
1746 | name_len = (NULL == name) ? 0 : strlen (name) + 1; | 1629 | name_len = (NULL == name) ? 0 : strlen (name) + 1; |
1747 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, | 1630 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd); |
1748 | rd); | ||
1749 | if (rd_ser_len < 0) | 1631 | if (rd_ser_len < 0) |
1750 | { | 1632 | { |
1751 | GNUNET_break (0); | 1633 | GNUNET_break (0); |
@@ -1759,9 +1641,10 @@ handle_zone_to_name_it (void *cls, | |||
1759 | ztn_ctx->success = GNUNET_SYSERR; | 1641 | ztn_ctx->success = GNUNET_SYSERR; |
1760 | return; | 1642 | return; |
1761 | } | 1643 | } |
1762 | env = GNUNET_MQ_msg_extra (ztnr_msg, | 1644 | env = |
1763 | name_len + rd_ser_len, | 1645 | GNUNET_MQ_msg_extra (ztnr_msg, |
1764 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); | 1646 | name_len + rd_ser_len, |
1647 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); | ||
1765 | ztnr_msg->gns_header.header.size = htons (msg_size); | 1648 | ztnr_msg->gns_header.header.size = htons (msg_size); |
1766 | ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid); | 1649 | ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid); |
1767 | ztnr_msg->res = htons (res); | 1650 | ztnr_msg->res = htons (res); |
@@ -1770,18 +1653,13 @@ handle_zone_to_name_it (void *cls, | |||
1770 | ztnr_msg->name_len = htons (name_len); | 1653 | ztnr_msg->name_len = htons (name_len); |
1771 | ztnr_msg->zone = *zone_key; | 1654 | ztnr_msg->zone = *zone_key; |
1772 | name_tmp = (char *) &ztnr_msg[1]; | 1655 | name_tmp = (char *) &ztnr_msg[1]; |
1773 | GNUNET_memcpy (name_tmp, | 1656 | GNUNET_memcpy (name_tmp, name, name_len); |
1774 | name, | ||
1775 | name_len); | ||
1776 | rd_tmp = &name_tmp[name_len]; | 1657 | rd_tmp = &name_tmp[name_len]; |
1777 | GNUNET_assert (rd_ser_len == | 1658 | GNUNET_assert ( |
1778 | GNUNET_GNSRECORD_records_serialize (rd_count, | 1659 | rd_ser_len == |
1779 | rd, | 1660 | GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_tmp)); |
1780 | rd_ser_len, | ||
1781 | rd_tmp)); | ||
1782 | ztn_ctx->success = GNUNET_OK; | 1661 | ztn_ctx->success = GNUNET_OK; |
1783 | GNUNET_MQ_send (ztn_ctx->nc->mq, | 1662 | GNUNET_MQ_send (ztn_ctx->nc->mq, env); |
1784 | env); | ||
1785 | } | 1663 | } |
1786 | 1664 | ||
1787 | 1665 | ||
@@ -1792,24 +1670,22 @@ handle_zone_to_name_it (void *cls, | |||
1792 | * @param ztn_msg message of type 'struct ZoneToNameMessage' | 1670 | * @param ztn_msg message of type 'struct ZoneToNameMessage' |
1793 | */ | 1671 | */ |
1794 | static void | 1672 | static void |
1795 | handle_zone_to_name (void *cls, | 1673 | handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg) |
1796 | const struct ZoneToNameMessage *ztn_msg) | ||
1797 | { | 1674 | { |
1798 | struct NamestoreClient *nc = cls; | 1675 | struct NamestoreClient *nc = cls; |
1799 | struct ZoneToNameCtx ztn_ctx; | 1676 | struct ZoneToNameCtx ztn_ctx; |
1800 | struct GNUNET_MQ_Envelope *env; | 1677 | struct GNUNET_MQ_Envelope *env; |
1801 | struct ZoneToNameResponseMessage *ztnr_msg; | 1678 | struct ZoneToNameResponseMessage *ztnr_msg; |
1802 | 1679 | ||
1803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME message\n"); |
1804 | "Received ZONE_TO_NAME message\n"); | ||
1805 | ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id); | 1681 | ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id); |
1806 | ztn_ctx.nc = nc; | 1682 | ztn_ctx.nc = nc; |
1807 | ztn_ctx.success = GNUNET_NO; | 1683 | ztn_ctx.success = GNUNET_NO; |
1808 | if (GNUNET_SYSERR == | 1684 | if (GNUNET_SYSERR == GSN_database->zone_to_name (GSN_database->cls, |
1809 | GSN_database->zone_to_name (GSN_database->cls, | 1685 | &ztn_msg->zone, |
1810 | &ztn_msg->zone, | 1686 | &ztn_msg->value_zone, |
1811 | &ztn_msg->value_zone, | 1687 | &handle_zone_to_name_it, |
1812 | &handle_zone_to_name_it, &ztn_ctx)) | 1688 | &ztn_ctx)) |
1813 | { | 1689 | { |
1814 | /* internal error, hang up instead of signalling something | 1690 | /* internal error, hang up instead of signalling something |
1815 | that might be wrong */ | 1691 | that might be wrong */ |
@@ -1823,11 +1699,10 @@ handle_zone_to_name (void *cls, | |||
1823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1699 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1824 | "Found no result for zone-to-name lookup.\n"); | 1700 | "Found no result for zone-to-name lookup.\n"); |
1825 | env = GNUNET_MQ_msg (ztnr_msg, | 1701 | env = GNUNET_MQ_msg (ztnr_msg, |
1826 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); | 1702 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); |
1827 | ztnr_msg->gns_header.r_id = ztn_msg->gns_header.r_id; | 1703 | ztnr_msg->gns_header.r_id = ztn_msg->gns_header.r_id; |
1828 | ztnr_msg->res = htons (GNUNET_NO); | 1704 | ztnr_msg->res = htons (GNUNET_NO); |
1829 | GNUNET_MQ_send (nc->mq, | 1705 | GNUNET_MQ_send (nc->mq, env); |
1830 | env); | ||
1831 | } | 1706 | } |
1832 | GNUNET_SERVICE_client_continue (nc->client); | 1707 | GNUNET_SERVICE_client_continue (nc->client); |
1833 | } | 1708 | } |
@@ -1848,7 +1723,6 @@ struct ZoneIterationProcResult | |||
1848 | * Number of results left to be returned in this iteration. | 1723 | * Number of results left to be returned in this iteration. |
1849 | */ | 1724 | */ |
1850 | uint64_t limit; | 1725 | uint64_t limit; |
1851 | |||
1852 | }; | 1726 | }; |
1853 | 1727 | ||
1854 | 1728 | ||
@@ -1864,25 +1738,22 @@ struct ZoneIterationProcResult | |||
1864 | */ | 1738 | */ |
1865 | static void | 1739 | static void |
1866 | zone_iterate_proc (void *cls, | 1740 | zone_iterate_proc (void *cls, |
1867 | uint64_t seq, | 1741 | uint64_t seq, |
1868 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | 1742 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, |
1869 | const char *name, | 1743 | const char *name, |
1870 | unsigned int rd_count, | 1744 | unsigned int rd_count, |
1871 | const struct GNUNET_GNSRECORD_Data *rd) | 1745 | const struct GNUNET_GNSRECORD_Data *rd) |
1872 | { | 1746 | { |
1873 | struct ZoneIterationProcResult *proc = cls; | 1747 | struct ZoneIterationProcResult *proc = cls; |
1874 | int do_refresh_block; | 1748 | int do_refresh_block; |
1875 | 1749 | ||
1876 | GNUNET_assert (0 != seq); | 1750 | GNUNET_assert (0 != seq); |
1877 | if ( (NULL == zone_key) && | 1751 | if ((NULL == zone_key) && (NULL == name)) |
1878 | (NULL == name) ) | ||
1879 | { | 1752 | { |
1880 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration done\n"); |
1881 | "Iteration done\n"); | ||
1882 | return; | 1754 | return; |
1883 | } | 1755 | } |
1884 | if ( (NULL == zone_key) || | 1756 | if ((NULL == zone_key) || (NULL == name)) |
1885 | (NULL == name) ) | ||
1886 | { | 1757 | { |
1887 | /* what is this!? should never happen */ | 1758 | /* what is this!? should never happen */ |
1888 | GNUNET_break (0); | 1759 | GNUNET_break (0); |
@@ -1905,20 +1776,14 @@ zone_iterate_proc (void *cls, | |||
1905 | 1776 | ||
1906 | 1777 | ||
1907 | do_refresh_block = GNUNET_NO; | 1778 | do_refresh_block = GNUNET_NO; |
1908 | for (unsigned int i=0;i<rd_count;i++) | 1779 | for (unsigned int i = 0; i < rd_count; i++) |
1909 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) | 1780 | if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) |
1910 | { | 1781 | { |
1911 | do_refresh_block = GNUNET_YES; | 1782 | do_refresh_block = GNUNET_YES; |
1912 | break; | 1783 | break; |
1913 | } | 1784 | } |
1914 | if (GNUNET_YES == do_refresh_block) | 1785 | if (GNUNET_YES == do_refresh_block) |
1915 | refresh_block (NULL, | 1786 | refresh_block (NULL, proc->zi, 0, zone_key, name, rd_count, rd); |
1916 | proc->zi, | ||
1917 | 0, | ||
1918 | zone_key, | ||
1919 | name, | ||
1920 | rd_count, | ||
1921 | rd); | ||
1922 | } | 1787 | } |
1923 | 1788 | ||
1924 | 1789 | ||
@@ -1929,16 +1794,13 @@ zone_iterate_proc (void *cls, | |||
1929 | * @param limit number of results to return in one pass | 1794 | * @param limit number of results to return in one pass |
1930 | */ | 1795 | */ |
1931 | static void | 1796 | static void |
1932 | run_zone_iteration_round (struct ZoneIteration *zi, | 1797 | run_zone_iteration_round (struct ZoneIteration *zi, uint64_t limit) |
1933 | uint64_t limit) | ||
1934 | { | 1798 | { |
1935 | struct ZoneIterationProcResult proc; | 1799 | struct ZoneIterationProcResult proc; |
1936 | struct GNUNET_TIME_Absolute start; | 1800 | struct GNUNET_TIME_Absolute start; |
1937 | struct GNUNET_TIME_Relative duration; | 1801 | struct GNUNET_TIME_Relative duration; |
1938 | 1802 | ||
1939 | memset (&proc, | 1803 | memset (&proc, 0, sizeof (proc)); |
1940 | 0, | ||
1941 | sizeof (proc)); | ||
1942 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1804 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1943 | "Asked to return up to %llu records at position %llu\n", | 1805 | "Asked to return up to %llu records at position %llu\n", |
1944 | (unsigned long long) limit, | 1806 | (unsigned long long) limit, |
@@ -1949,15 +1811,14 @@ run_zone_iteration_round (struct ZoneIteration *zi, | |||
1949 | GNUNET_break (GNUNET_SYSERR != | 1811 | GNUNET_break (GNUNET_SYSERR != |
1950 | GSN_database->iterate_records (GSN_database->cls, | 1812 | GSN_database->iterate_records (GSN_database->cls, |
1951 | (0 == GNUNET_is_zero (&zi->zone)) | 1813 | (0 == GNUNET_is_zero (&zi->zone)) |
1952 | ? NULL | 1814 | ? NULL |
1953 | : &zi->zone, | 1815 | : &zi->zone, |
1954 | zi->seq, | 1816 | zi->seq, |
1955 | limit, | 1817 | limit, |
1956 | &zone_iterate_proc, | 1818 | &zone_iterate_proc, |
1957 | &proc)); | 1819 | &proc)); |
1958 | duration = GNUNET_TIME_absolute_get_duration (start); | 1820 | duration = GNUNET_TIME_absolute_get_duration (start); |
1959 | duration = GNUNET_TIME_relative_divide (duration, | 1821 | duration = GNUNET_TIME_relative_divide (duration, limit - proc.limit); |
1960 | limit - proc.limit); | ||
1961 | GNUNET_STATISTICS_set (statistics, | 1822 | GNUNET_STATISTICS_set (statistics, |
1962 | "NAMESTORE iteration delay (μs/record)", | 1823 | "NAMESTORE iteration delay (μs/record)", |
1963 | duration.rel_value_us, | 1824 | duration.rel_value_us, |
@@ -1993,11 +1854,8 @@ handle_iteration_start (void *cls, | |||
1993 | zi->nc = nc; | 1854 | zi->nc = nc; |
1994 | zi->zone = zis_msg->zone; | 1855 | zi->zone = zis_msg->zone; |
1995 | 1856 | ||
1996 | GNUNET_CONTAINER_DLL_insert (nc->op_head, | 1857 | GNUNET_CONTAINER_DLL_insert (nc->op_head, nc->op_tail, zi); |
1997 | nc->op_tail, | 1858 | run_zone_iteration_round (zi, 1); |
1998 | zi); | ||
1999 | run_zone_iteration_round (zi, | ||
2000 | 1); | ||
2001 | } | 1859 | } |
2002 | 1860 | ||
2003 | 1861 | ||
@@ -2027,9 +1885,7 @@ handle_iteration_stop (void *cls, | |||
2027 | GNUNET_SERVICE_client_drop (nc->client); | 1885 | GNUNET_SERVICE_client_drop (nc->client); |
2028 | return; | 1886 | return; |
2029 | } | 1887 | } |
2030 | GNUNET_CONTAINER_DLL_remove (nc->op_head, | 1888 | GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, zi); |
2031 | nc->op_tail, | ||
2032 | zi); | ||
2033 | GNUNET_free (zi); | 1889 | GNUNET_free (zi); |
2034 | GNUNET_SERVICE_client_continue (nc->client); | 1890 | GNUNET_SERVICE_client_continue (nc->client); |
2035 | } | 1891 | } |
@@ -2067,8 +1923,7 @@ handle_iteration_next (void *cls, | |||
2067 | GNUNET_SERVICE_client_drop (nc->client); | 1923 | GNUNET_SERVICE_client_drop (nc->client); |
2068 | return; | 1924 | return; |
2069 | } | 1925 | } |
2070 | run_zone_iteration_round (zi, | 1926 | run_zone_iteration_round (zi, limit); |
2071 | limit); | ||
2072 | } | 1927 | } |
2073 | 1928 | ||
2074 | 1929 | ||
@@ -2082,8 +1937,7 @@ monitor_unblock (struct ZoneMonitor *zm) | |||
2082 | { | 1937 | { |
2083 | struct StoreActivity *sa = sa_head; | 1938 | struct StoreActivity *sa = sa_head; |
2084 | 1939 | ||
2085 | while ( (NULL != sa) && | 1940 | while ((NULL != sa) && (zm->limit > zm->iteration_cnt)) |
2086 | (zm->limit > zm->iteration_cnt) ) | ||
2087 | { | 1941 | { |
2088 | struct StoreActivity *sn = sa->next; | 1942 | struct StoreActivity *sn = sa->next; |
2089 | 1943 | ||
@@ -2105,9 +1959,10 @@ monitor_unblock (struct ZoneMonitor *zm) | |||
2105 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); | 1959 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); |
2106 | if (NULL != zm->sa_wait_warning) | 1960 | if (NULL != zm->sa_wait_warning) |
2107 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | 1961 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); |
2108 | zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, | 1962 | zm->sa_wait_warning = |
2109 | &warn_monitor_slow, | 1963 | GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, |
2110 | zm); | 1964 | &warn_monitor_slow, |
1965 | zm); | ||
2111 | } | 1966 | } |
2112 | } | 1967 | } |
2113 | 1968 | ||
@@ -2123,15 +1978,12 @@ monitor_sync (struct ZoneMonitor *zm) | |||
2123 | struct GNUNET_MQ_Envelope *env; | 1978 | struct GNUNET_MQ_Envelope *env; |
2124 | struct GNUNET_MessageHeader *sync; | 1979 | struct GNUNET_MessageHeader *sync; |
2125 | 1980 | ||
2126 | env = GNUNET_MQ_msg (sync, | 1981 | env = GNUNET_MQ_msg (sync, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC); |
2127 | GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC); | 1982 | GNUNET_MQ_send (zm->nc->mq, env); |
2128 | GNUNET_MQ_send (zm->nc->mq, | ||
2129 | env); | ||
2130 | /* mark iteration done */ | 1983 | /* mark iteration done */ |
2131 | zm->in_first_iteration = GNUNET_NO; | 1984 | zm->in_first_iteration = GNUNET_NO; |
2132 | zm->iteration_cnt = 0; | 1985 | zm->iteration_cnt = 0; |
2133 | if ( (zm->limit > 0) && | 1986 | if ((zm->limit > 0) && (zm->sa_waiting)) |
2134 | (zm->sa_waiting) ) | ||
2135 | monitor_unblock (zm); | 1987 | monitor_unblock (zm); |
2136 | } | 1988 | } |
2137 | 1989 | ||
@@ -2174,20 +2026,13 @@ monitor_iterate_cb (void *cls, | |||
2174 | GNUNET_NO); | 2026 | GNUNET_NO); |
2175 | zm->limit--; | 2027 | zm->limit--; |
2176 | zm->iteration_cnt--; | 2028 | zm->iteration_cnt--; |
2177 | send_lookup_response (zm->nc, | 2029 | send_lookup_response (zm->nc, 0, zone_key, name, rd_count, rd); |
2178 | 0, | 2030 | if ((0 == zm->iteration_cnt) && (0 != zm->limit)) |
2179 | zone_key, | ||
2180 | name, | ||
2181 | rd_count, | ||
2182 | rd); | ||
2183 | if ( (0 == zm->iteration_cnt) && | ||
2184 | (0 != zm->limit) ) | ||
2185 | { | 2031 | { |
2186 | /* We are done with the current iteration batch, AND the | 2032 | /* We are done with the current iteration batch, AND the |
2187 | client would right now accept more, so go again! */ | 2033 | client would right now accept more, so go again! */ |
2188 | GNUNET_assert (NULL == zm->task); | 2034 | GNUNET_assert (NULL == zm->task); |
2189 | zm->task = GNUNET_SCHEDULER_add_now (&monitor_iteration_next, | 2035 | zm->task = GNUNET_SCHEDULER_add_now (&monitor_iteration_next, zm); |
2190 | zm); | ||
2191 | } | 2036 | } |
2192 | } | 2037 | } |
2193 | 2038 | ||
@@ -2199,29 +2044,23 @@ monitor_iterate_cb (void *cls, | |||
2199 | * @param zis_msg message from the client | 2044 | * @param zis_msg message from the client |
2200 | */ | 2045 | */ |
2201 | static void | 2046 | static void |
2202 | handle_monitor_start (void *cls, | 2047 | handle_monitor_start (void *cls, const struct ZoneMonitorStartMessage *zis_msg) |
2203 | const struct ZoneMonitorStartMessage *zis_msg) | ||
2204 | { | 2048 | { |
2205 | struct NamestoreClient *nc = cls; | 2049 | struct NamestoreClient *nc = cls; |
2206 | struct ZoneMonitor *zm; | 2050 | struct ZoneMonitor *zm; |
2207 | 2051 | ||
2208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_MONITOR_START message\n"); |
2209 | "Received ZONE_MONITOR_START message\n"); | ||
2210 | zm = GNUNET_new (struct ZoneMonitor); | 2053 | zm = GNUNET_new (struct ZoneMonitor); |
2211 | zm->nc = nc; | 2054 | zm->nc = nc; |
2212 | zm->zone = zis_msg->zone; | 2055 | zm->zone = zis_msg->zone; |
2213 | zm->limit = 1; | 2056 | zm->limit = 1; |
2214 | zm->in_first_iteration = (GNUNET_YES == ntohl (zis_msg->iterate_first)); | 2057 | zm->in_first_iteration = (GNUNET_YES == ntohl (zis_msg->iterate_first)); |
2215 | GNUNET_CONTAINER_DLL_insert (monitor_head, | 2058 | GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, zm); |
2216 | monitor_tail, | ||
2217 | zm); | ||
2218 | GNUNET_SERVICE_client_mark_monitor (nc->client); | 2059 | GNUNET_SERVICE_client_mark_monitor (nc->client); |
2219 | GNUNET_SERVICE_client_continue (nc->client); | 2060 | GNUNET_SERVICE_client_continue (nc->client); |
2220 | GNUNET_notification_context_add (monitor_nc, | 2061 | GNUNET_notification_context_add (monitor_nc, nc->mq); |
2221 | nc->mq); | ||
2222 | if (zm->in_first_iteration) | 2062 | if (zm->in_first_iteration) |
2223 | zm->task = GNUNET_SCHEDULER_add_now (&monitor_iteration_next, | 2063 | zm->task = GNUNET_SCHEDULER_add_now (&monitor_iteration_next, zm); |
2224 | zm); | ||
2225 | else | 2064 | else |
2226 | monitor_sync (zm); | 2065 | monitor_sync (zm); |
2227 | } | 2066 | } |
@@ -2246,8 +2085,8 @@ monitor_iteration_next (void *cls) | |||
2246 | zm->iteration_cnt = zm->limit; /* use it all */ | 2085 | zm->iteration_cnt = zm->limit; /* use it all */ |
2247 | ret = GSN_database->iterate_records (GSN_database->cls, | 2086 | ret = GSN_database->iterate_records (GSN_database->cls, |
2248 | (0 == GNUNET_is_zero (&zm->zone)) | 2087 | (0 == GNUNET_is_zero (&zm->zone)) |
2249 | ? NULL | 2088 | ? NULL |
2250 | : &zm->zone, | 2089 | : &zm->zone, |
2251 | zm->seq, | 2090 | zm->seq, |
2252 | zm->iteration_cnt, | 2091 | zm->iteration_cnt, |
2253 | &monitor_iterate_cb, | 2092 | &monitor_iterate_cb, |
@@ -2273,8 +2112,7 @@ monitor_iteration_next (void *cls) | |||
2273 | * @param nm message from the client | 2112 | * @param nm message from the client |
2274 | */ | 2113 | */ |
2275 | static void | 2114 | static void |
2276 | handle_monitor_next (void *cls, | 2115 | handle_monitor_next (void *cls, const struct ZoneMonitorNextMessage *nm) |
2277 | const struct ZoneMonitorNextMessage *nm) | ||
2278 | { | 2116 | { |
2279 | struct NamestoreClient *nc = cls; | 2117 | struct NamestoreClient *nc = cls; |
2280 | struct ZoneMonitor *zm; | 2118 | struct ZoneMonitor *zm; |
@@ -2301,18 +2139,15 @@ handle_monitor_next (void *cls, | |||
2301 | return; | 2139 | return; |
2302 | } | 2140 | } |
2303 | zm->limit += inc; | 2141 | zm->limit += inc; |
2304 | if ( (zm->in_first_iteration) && | 2142 | if ((zm->in_first_iteration) && (zm->limit == inc)) |
2305 | (zm->limit == inc) ) | ||
2306 | { | 2143 | { |
2307 | /* We are still iterating, and the previous iteration must | 2144 | /* We are still iterating, and the previous iteration must |
2308 | have stopped due to the client's limit, so continue it! */ | 2145 | have stopped due to the client's limit, so continue it! */ |
2309 | GNUNET_assert (NULL == zm->task); | 2146 | GNUNET_assert (NULL == zm->task); |
2310 | zm->task = GNUNET_SCHEDULER_add_now (&monitor_iteration_next, | 2147 | zm->task = GNUNET_SCHEDULER_add_now (&monitor_iteration_next, zm); |
2311 | zm); | ||
2312 | } | 2148 | } |
2313 | GNUNET_assert (zm->iteration_cnt <= zm->limit); | 2149 | GNUNET_assert (zm->iteration_cnt <= zm->limit); |
2314 | if ( (zm->limit > zm->iteration_cnt) && | 2150 | if ((zm->limit > zm->iteration_cnt) && (zm->sa_waiting)) |
2315 | (zm->sa_waiting) ) | ||
2316 | { | 2151 | { |
2317 | monitor_unblock (zm); | 2152 | monitor_unblock (zm); |
2318 | } | 2153 | } |
@@ -2321,9 +2156,10 @@ handle_monitor_next (void *cls, | |||
2321 | if (NULL != zm->sa_wait_warning) | 2156 | if (NULL != zm->sa_wait_warning) |
2322 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | 2157 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); |
2323 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); | 2158 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); |
2324 | zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, | 2159 | zm->sa_wait_warning = |
2325 | &warn_monitor_slow, | 2160 | GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, |
2326 | zm); | 2161 | &warn_monitor_slow, |
2162 | zm); | ||
2327 | } | 2163 | } |
2328 | } | 2164 | } |
2329 | 2165 | ||
@@ -2344,14 +2180,11 @@ run (void *cls, | |||
2344 | 2180 | ||
2345 | (void) cls; | 2181 | (void) cls; |
2346 | (void) service; | 2182 | (void) service; |
2347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2183 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting namestore service\n"); |
2348 | "Starting namestore service\n"); | 2184 | cache_keys = |
2349 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno (cfg, | 2185 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "namestore", "CACHE_KEYS"); |
2350 | "namestore", | 2186 | disable_namecache = |
2351 | "CACHE_KEYS"); | 2187 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "namecache", "DISABLE"); |
2352 | disable_namecache = GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
2353 | "namecache", | ||
2354 | "DISABLE"); | ||
2355 | GSN_cfg = cfg; | 2188 | GSN_cfg = cfg; |
2356 | monitor_nc = GNUNET_notification_context_create (1); | 2189 | monitor_nc = GNUNET_notification_context_create (1); |
2357 | if (GNUNET_YES != disable_namecache) | 2190 | if (GNUNET_YES != disable_namecache) |
@@ -2360,24 +2193,17 @@ run (void *cls, | |||
2360 | GNUNET_assert (NULL != namecache); | 2193 | GNUNET_assert (NULL != namecache); |
2361 | } | 2194 | } |
2362 | /* Loading database plugin */ | 2195 | /* Loading database plugin */ |
2363 | if (GNUNET_OK != | 2196 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, |
2364 | GNUNET_CONFIGURATION_get_value_string (cfg, | 2197 | "namestore", |
2365 | "namestore", | 2198 | "database", |
2366 | "database", | 2199 | &database)) |
2367 | &database)) | 2200 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); |
2368 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2201 | |
2369 | "No database backend configured\n"); | 2202 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_namestore_%s", database); |
2370 | 2203 | GSN_database = GNUNET_PLUGIN_load (db_lib_name, (void *) GSN_cfg); | |
2371 | GNUNET_asprintf (&db_lib_name, | ||
2372 | "libgnunet_plugin_namestore_%s", | ||
2373 | database); | ||
2374 | GSN_database = GNUNET_PLUGIN_load (db_lib_name, | ||
2375 | (void *) GSN_cfg); | ||
2376 | GNUNET_free (database); | 2204 | GNUNET_free (database); |
2377 | statistics = GNUNET_STATISTICS_create ("namestore", | 2205 | statistics = GNUNET_STATISTICS_create ("namestore", cfg); |
2378 | cfg); | 2206 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); |
2379 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, | ||
2380 | NULL); | ||
2381 | if (NULL == GSN_database) | 2207 | if (NULL == GSN_database) |
2382 | { | 2208 | { |
2383 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2209 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2392,46 +2218,46 @@ run (void *cls, | |||
2392 | /** | 2218 | /** |
2393 | * Define "main" method using service macro. | 2219 | * Define "main" method using service macro. |
2394 | */ | 2220 | */ |
2395 | GNUNET_SERVICE_MAIN | 2221 | GNUNET_SERVICE_MAIN ( |
2396 | ("namestore", | 2222 | "namestore", |
2397 | GNUNET_SERVICE_OPTION_NONE, | 2223 | GNUNET_SERVICE_OPTION_NONE, |
2398 | &run, | 2224 | &run, |
2399 | &client_connect_cb, | 2225 | &client_connect_cb, |
2400 | &client_disconnect_cb, | 2226 | &client_disconnect_cb, |
2401 | NULL, | 2227 | NULL, |
2402 | GNUNET_MQ_hd_var_size (record_store, | 2228 | GNUNET_MQ_hd_var_size (record_store, |
2403 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, | 2229 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, |
2404 | struct RecordStoreMessage, | 2230 | struct RecordStoreMessage, |
2405 | NULL), | 2231 | NULL), |
2406 | GNUNET_MQ_hd_var_size (record_lookup, | 2232 | GNUNET_MQ_hd_var_size (record_lookup, |
2407 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, | 2233 | GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, |
2408 | struct LabelLookupMessage, | 2234 | struct LabelLookupMessage, |
2409 | NULL), | 2235 | NULL), |
2410 | GNUNET_MQ_hd_fixed_size (zone_to_name, | 2236 | GNUNET_MQ_hd_fixed_size (zone_to_name, |
2411 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, | 2237 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, |
2412 | struct ZoneToNameMessage, | 2238 | struct ZoneToNameMessage, |
2413 | NULL), | 2239 | NULL), |
2414 | GNUNET_MQ_hd_fixed_size (iteration_start, | 2240 | GNUNET_MQ_hd_fixed_size (iteration_start, |
2415 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, | 2241 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, |
2416 | struct ZoneIterationStartMessage, | 2242 | struct ZoneIterationStartMessage, |
2417 | NULL), | 2243 | NULL), |
2418 | GNUNET_MQ_hd_fixed_size (iteration_next, | 2244 | GNUNET_MQ_hd_fixed_size (iteration_next, |
2419 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, | 2245 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, |
2420 | struct ZoneIterationNextMessage, | 2246 | struct ZoneIterationNextMessage, |
2421 | NULL), | 2247 | NULL), |
2422 | GNUNET_MQ_hd_fixed_size (iteration_stop, | 2248 | GNUNET_MQ_hd_fixed_size (iteration_stop, |
2423 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, | 2249 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, |
2424 | struct ZoneIterationStopMessage, | 2250 | struct ZoneIterationStopMessage, |
2425 | NULL), | 2251 | NULL), |
2426 | GNUNET_MQ_hd_fixed_size (monitor_start, | 2252 | GNUNET_MQ_hd_fixed_size (monitor_start, |
2427 | GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, | 2253 | GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, |
2428 | struct ZoneMonitorStartMessage, | 2254 | struct ZoneMonitorStartMessage, |
2429 | NULL), | 2255 | NULL), |
2430 | GNUNET_MQ_hd_fixed_size (monitor_next, | 2256 | GNUNET_MQ_hd_fixed_size (monitor_next, |
2431 | GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT, | 2257 | GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT, |
2432 | struct ZoneMonitorNextMessage, | 2258 | struct ZoneMonitorNextMessage, |
2433 | NULL), | 2259 | NULL), |
2434 | GNUNET_MQ_handler_end ()); | 2260 | GNUNET_MQ_handler_end ()); |
2435 | 2261 | ||
2436 | 2262 | ||
2437 | /* end of gnunet-service-namestore.c */ | 2263 | /* end of gnunet-service-namestore.c */ |