diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
commit | 83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch) | |
tree | d0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/fs | |
parent | 28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff) | |
download | gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip |
curly wars / auto-indentation
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_file_information.c | 112 | ||||
-rw-r--r-- | src/fs/fs_uri.c | 22 | ||||
-rw-r--r-- | src/fs/gnunet-fs.c | 27 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 42 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 85 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_cp.h | 7 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_indexing.c | 9 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_lc.c | 3 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pe.c | 90 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 91 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.h | 4 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_put.c | 6 |
12 files changed, 217 insertions, 281 deletions
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index ce4f189a9..bb84b948e 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c | |||
@@ -437,7 +437,7 @@ GNUNET_FS_directory_scanner_default (void *cls, struct GNUNET_FS_Handle *h, | |||
437 | */ | 437 | */ |
438 | struct MetaValueInformation | 438 | struct MetaValueInformation |
439 | { | 439 | { |
440 | 440 | ||
441 | /** | 441 | /** |
442 | * Mime-type of data. | 442 | * Mime-type of data. |
443 | */ | 443 | */ |
@@ -481,21 +481,17 @@ struct MetaValueInformation | |||
481 | * used in the main libextractor library and yielding | 481 | * used in the main libextractor library and yielding |
482 | * meta data). | 482 | * meta data). |
483 | * @param type libextractor-type describing the meta data | 483 | * @param type libextractor-type describing the meta data |
484 | * @param format basic format information about data | 484 | * @param format basic format information about data |
485 | * @param data_mime_type mime-type of data (not of the original file); | 485 | * @param data_mime_type mime-type of data (not of the original file); |
486 | * can be NULL (if mime-type is not known) | 486 | * can be NULL (if mime-type is not known) |
487 | * @param data actual meta-data found | 487 | * @param data actual meta-data found |
488 | * @param data_len number of bytes in data | 488 | * @param data_len number of bytes in data |
489 | * @return 0 to continue extracting / iterating | 489 | * @return 0 to continue extracting / iterating |
490 | */ | 490 | */ |
491 | static int | 491 | static int |
492 | update_metamap (void *cls, | 492 | update_metamap (void *cls, const char *plugin_name, |
493 | const char *plugin_name, | 493 | enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format, |
494 | enum EXTRACTOR_MetaType type, | 494 | const char *data_mime_type, const char *data, size_t data_len) |
495 | enum EXTRACTOR_MetaFormat format, | ||
496 | const char *data_mime_type, | ||
497 | const char *data, | ||
498 | size_t data_len) | ||
499 | { | 495 | { |
500 | struct GNUNET_CONTAINER_MultiHashMap *map = cls; | 496 | struct GNUNET_CONTAINER_MultiHashMap *map = cls; |
501 | GNUNET_HashCode key; | 497 | GNUNET_HashCode key; |
@@ -512,10 +508,10 @@ update_metamap (void *cls, | |||
512 | mvi->type = type; | 508 | mvi->type = type; |
513 | mvi->format = format; | 509 | mvi->format = format; |
514 | GNUNET_CONTAINER_multihashmap_put (map, &key, mvi, | 510 | GNUNET_CONTAINER_multihashmap_put (map, &key, mvi, |
515 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 511 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
516 | } | 512 | } |
517 | mvi->frequency++; | 513 | mvi->frequency++; |
518 | return 0; | 514 | return 0; |
519 | } | 515 | } |
520 | 516 | ||
521 | 517 | ||
@@ -524,7 +520,7 @@ update_metamap (void *cls, | |||
524 | */ | 520 | */ |
525 | struct KeywordInformation | 521 | struct KeywordInformation |
526 | { | 522 | { |
527 | 523 | ||
528 | /** | 524 | /** |
529 | * Mime-type of keyword. | 525 | * Mime-type of keyword. |
530 | */ | 526 | */ |
@@ -581,37 +577,35 @@ struct EntryProcCls | |||
581 | * @param fi information for publishing the file | 577 | * @param fi information for publishing the file |
582 | */ | 578 | */ |
583 | static void | 579 | static void |
584 | dirproc_add (void *cls, const char *filename, | 580 | dirproc_add (void *cls, const char *filename, |
585 | struct GNUNET_FS_FileInformation *fi) | 581 | struct GNUNET_FS_FileInformation *fi) |
586 | { | 582 | { |
587 | struct EntryProcCls *dc = cls; | 583 | struct EntryProcCls *dc = cls; |
588 | unsigned int i; | 584 | unsigned int i; |
589 | const char *kw; | 585 | const char *kw; |
590 | struct KeywordInformation *ki; | 586 | struct KeywordInformation *ki; |
591 | GNUNET_HashCode key; | 587 | GNUNET_HashCode key; |
592 | 588 | ||
593 | GNUNET_assert (fi->next == NULL); | 589 | GNUNET_assert (fi->next == NULL); |
594 | GNUNET_assert (fi->dir == NULL); | 590 | GNUNET_assert (fi->dir == NULL); |
595 | fi->next = dc->entries; | 591 | fi->next = dc->entries; |
596 | dc->entries = fi; | 592 | dc->entries = fi; |
597 | dc->count++; | 593 | dc->count++; |
598 | if (NULL != fi->meta) | 594 | if (NULL != fi->meta) |
599 | GNUNET_CONTAINER_meta_data_iterate (fi->meta, | 595 | GNUNET_CONTAINER_meta_data_iterate (fi->meta, &update_metamap, dc->metamap); |
600 | &update_metamap, | 596 | for (i = 0; i < fi->keywords->data.ksk.keywordCount; i++) |
601 | dc->metamap); | ||
602 | for (i=0;i<fi->keywords->data.ksk.keywordCount;i++) | ||
603 | { | 597 | { |
604 | kw = fi->keywords->data.ksk.keywords[i]; | 598 | kw = fi->keywords->data.ksk.keywords[i]; |
605 | GNUNET_CRYPTO_hash (kw, strlen(kw), &key); | 599 | GNUNET_CRYPTO_hash (kw, strlen (kw), &key); |
606 | ki = GNUNET_CONTAINER_multihashmap_get (dc->keywordmap, &key); | 600 | ki = GNUNET_CONTAINER_multihashmap_get (dc->keywordmap, &key); |
607 | if (ki == NULL) | 601 | if (ki == NULL) |
608 | { | 602 | { |
609 | ki = GNUNET_malloc (sizeof (struct KeywordInformation)); | 603 | ki = GNUNET_malloc (sizeof (struct KeywordInformation)); |
610 | ki->keyword = &kw[1]; | 604 | ki->keyword = &kw[1]; |
611 | GNUNET_CONTAINER_multihashmap_put (dc->keywordmap, &key, ki, | 605 | GNUNET_CONTAINER_multihashmap_put (dc->keywordmap, &key, ki, |
612 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 606 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
613 | } | 607 | } |
614 | ki->frequency++; | 608 | ki->frequency++; |
615 | } | 609 | } |
616 | } | 610 | } |
617 | 611 | ||
@@ -633,7 +627,7 @@ struct ComputeDirectoryMetadataContext | |||
633 | 627 | ||
634 | /** | 628 | /** |
635 | * Threshold to apply for adding meta data. | 629 | * Threshold to apply for adding meta data. |
636 | */ | 630 | */ |
637 | unsigned int threshold; | 631 | unsigned int threshold; |
638 | }; | 632 | }; |
639 | 633 | ||
@@ -650,29 +644,22 @@ struct ComputeDirectoryMetadataContext | |||
650 | * @return GNUNET_OK | 644 | * @return GNUNET_OK |
651 | */ | 645 | */ |
652 | static int | 646 | static int |
653 | compute_directory_metadata (void *cls, | 647 | compute_directory_metadata (void *cls, const GNUNET_HashCode * key, void *value) |
654 | const GNUNET_HashCode *key, | ||
655 | void *value) | ||
656 | { | 648 | { |
657 | struct ComputeDirectoryMetadataContext *cdmc = cls; | 649 | struct ComputeDirectoryMetadataContext *cdmc = cls; |
658 | struct MetaValueInformation *mvi = value; | 650 | struct MetaValueInformation *mvi = value; |
659 | 651 | ||
660 | if (mvi->frequency > cdmc->threshold) | 652 | if (mvi->frequency > cdmc->threshold) |
661 | { | 653 | { |
662 | if (mvi->type != EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME) | 654 | if (mvi->type != EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME) |
663 | (void) GNUNET_CONTAINER_meta_data_insert (cdmc->meta, | 655 | (void) GNUNET_CONTAINER_meta_data_insert (cdmc->meta, "<children>", |
664 | "<children>", | 656 | mvi->type, mvi->format, |
665 | mvi->type, | 657 | mvi->mime_type, mvi->data, |
666 | mvi->format, | 658 | mvi->data_size); |
667 | mvi->mime_type, | 659 | if ((mvi->format == EXTRACTOR_METAFORMAT_UTF8) || |
668 | mvi->data, | 660 | (mvi->format == EXTRACTOR_METAFORMAT_C_STRING)) |
669 | mvi->data_size); | 661 | GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk, mvi->data, GNUNET_NO); |
670 | if ( (mvi->format == EXTRACTOR_METAFORMAT_UTF8) || | 662 | } |
671 | (mvi->format == EXTRACTOR_METAFORMAT_C_STRING) ) | ||
672 | GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk, | ||
673 | mvi->data, | ||
674 | GNUNET_NO); | ||
675 | } | ||
676 | GNUNET_free (mvi); | 663 | GNUNET_free (mvi); |
677 | return GNUNET_OK; | 664 | return GNUNET_OK; |
678 | } | 665 | } |
@@ -680,7 +667,7 @@ compute_directory_metadata (void *cls, | |||
680 | 667 | ||
681 | /** | 668 | /** |
682 | * Add keywords that occur in more than the threshold entries of the | 669 | * Add keywords that occur in more than the threshold entries of the |
683 | * directory to the directory itself. | 670 | * directory to the directory itself. |
684 | * | 671 | * |
685 | * @param cls the 'struct ComputeDirectoryMetadataContext' | 672 | * @param cls the 'struct ComputeDirectoryMetadataContext' |
686 | * @param key unused | 673 | * @param key unused |
@@ -688,17 +675,13 @@ compute_directory_metadata (void *cls, | |||
688 | * @return GNUNET_OK | 675 | * @return GNUNET_OK |
689 | */ | 676 | */ |
690 | static int | 677 | static int |
691 | compute_directory_keywords (void *cls, | 678 | compute_directory_keywords (void *cls, const GNUNET_HashCode * key, void *value) |
692 | const GNUNET_HashCode *key, | ||
693 | void *value) | ||
694 | { | 679 | { |
695 | struct ComputeDirectoryMetadataContext *cdmc = cls; | 680 | struct ComputeDirectoryMetadataContext *cdmc = cls; |
696 | struct KeywordInformation *ki = value; | 681 | struct KeywordInformation *ki = value; |
697 | 682 | ||
698 | if (ki->frequency > cdmc->threshold) | 683 | if (ki->frequency > cdmc->threshold) |
699 | (void) GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk, | 684 | (void) GNUNET_FS_uri_ksk_add_keyword (cdmc->ksk, ki->keyword, GNUNET_NO); |
700 | ki->keyword, | ||
701 | GNUNET_NO); | ||
702 | GNUNET_free (ki); | 685 | GNUNET_free (ki); |
703 | return GNUNET_OK; | 686 | return GNUNET_OK; |
704 | } | 687 | } |
@@ -751,36 +734,31 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, | |||
751 | dc.metamap = GNUNET_CONTAINER_multihashmap_create (64); | 734 | dc.metamap = GNUNET_CONTAINER_multihashmap_create (64); |
752 | dc.keywordmap = GNUNET_CONTAINER_multihashmap_create (64); | 735 | dc.keywordmap = GNUNET_CONTAINER_multihashmap_create (64); |
753 | /* update children to point to directory and generate statistics | 736 | /* update children to point to directory and generate statistics |
754 | on all meta data in children */ | 737 | * on all meta data in children */ |
755 | scanner (scanner_cls, h, filename, do_index, bo, &dirproc_add, &dc, emsg); | 738 | scanner (scanner_cls, h, filename, do_index, bo, &dirproc_add, &dc, emsg); |
756 | cdmc.meta = GNUNET_CONTAINER_meta_data_create (); | 739 | cdmc.meta = GNUNET_CONTAINER_meta_data_create (); |
757 | cdmc.ksk = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 740 | cdmc.ksk = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
758 | cdmc.ksk->type = ksk; | 741 | cdmc.ksk->type = ksk; |
759 | cdmc.threshold = 1 + dc.count / 2; /* 50% threshold for now */ | 742 | cdmc.threshold = 1 + dc.count / 2; /* 50% threshold for now */ |
760 | GNUNET_FS_meta_data_make_directory (cdmc.meta); | 743 | GNUNET_FS_meta_data_make_directory (cdmc.meta); |
761 | GNUNET_CONTAINER_multihashmap_iterate (dc.metamap, | 744 | GNUNET_CONTAINER_multihashmap_iterate (dc.metamap, |
762 | &compute_directory_metadata, | 745 | &compute_directory_metadata, &cdmc); |
763 | &cdmc); | ||
764 | GNUNET_CONTAINER_multihashmap_iterate (dc.keywordmap, | 746 | GNUNET_CONTAINER_multihashmap_iterate (dc.keywordmap, |
765 | &compute_directory_keywords, | 747 | &compute_directory_keywords, &cdmc); |
766 | &cdmc); | ||
767 | GNUNET_CONTAINER_multihashmap_destroy (dc.metamap); | 748 | GNUNET_CONTAINER_multihashmap_destroy (dc.metamap); |
768 | GNUNET_CONTAINER_multihashmap_destroy (dc.keywordmap); | 749 | GNUNET_CONTAINER_multihashmap_destroy (dc.keywordmap); |
769 | GNUNET_FS_uri_ksk_add_keyword (cdmc.ksk, | 750 | GNUNET_FS_uri_ksk_add_keyword (cdmc.ksk, GNUNET_FS_DIRECTORY_MIME, GNUNET_NO); |
770 | GNUNET_FS_DIRECTORY_MIME, | ||
771 | GNUNET_NO); | ||
772 | cksk = GNUNET_FS_uri_ksk_canonicalize (cdmc.ksk); | 751 | cksk = GNUNET_FS_uri_ksk_canonicalize (cdmc.ksk); |
773 | 752 | ||
774 | /* remove keywords in children that are already in the | 753 | /* remove keywords in children that are already in the |
775 | parent */ | 754 | * parent */ |
776 | for (epos = dc.entries; NULL != epos; epos = epos->next) | 755 | for (epos = dc.entries; NULL != epos; epos = epos->next) |
777 | { | 756 | { |
778 | for (i=0;i<cksk->data.ksk.keywordCount;i++) | 757 | for (i = 0; i < cksk->data.ksk.keywordCount; i++) |
779 | { | 758 | { |
780 | kw = cksk->data.ksk.keywords[i]; | 759 | kw = cksk->data.ksk.keywords[i]; |
781 | GNUNET_FS_uri_ksk_remove_keyword (epos->keywords, | 760 | GNUNET_FS_uri_ksk_remove_keyword (epos->keywords, &kw[1]); |
782 | &kw[1]); | 761 | } |
783 | } | ||
784 | } | 762 | } |
785 | ret = | 763 | ret = |
786 | GNUNET_FS_file_information_create_empty_directory (h, client_info, cksk, | 764 | GNUNET_FS_file_information_create_empty_directory (h, client_info, cksk, |
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 2057a18f6..48fabc1fb 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -1033,9 +1033,8 @@ canonicalize_keyword (const char *in) | |||
1033 | wpos++; | 1033 | wpos++; |
1034 | break; | 1034 | break; |
1035 | default: | 1035 | default: |
1036 | if (isspace ((unsigned char) *rpos) || | 1036 | if (isspace ((unsigned char) *rpos) || isdigit ((unsigned char) *rpos)) |
1037 | isdigit ((unsigned char) *rpos) ) | 1037 | break; |
1038 | break; | ||
1039 | /* replace characters listed above with '_' */ | 1038 | /* replace characters listed above with '_' */ |
1040 | *wpos = '_'; | 1039 | *wpos = '_'; |
1041 | wpos++; | 1040 | wpos++; |
@@ -1073,24 +1072,19 @@ GNUNET_FS_uri_ksk_canonicalize (const struct GNUNET_FS_Uri *uri) | |||
1073 | for (i = 0; i < kc; i++) | 1072 | for (i = 0; i < kc; i++) |
1074 | { | 1073 | { |
1075 | in = uri->data.ksk.keywords[i]; | 1074 | in = uri->data.ksk.keywords[i]; |
1076 | GNUNET_FS_uri_ksk_add_keyword (ret, | 1075 | GNUNET_FS_uri_ksk_add_keyword (ret, &in[1], |
1077 | &in[1], | 1076 | (in[0] == '+') ? GNUNET_YES : GNUNET_NO); |
1078 | (in[0] == '+') ? GNUNET_YES : GNUNET_NO); | ||
1079 | sb = GNUNET_strdup (&in[1]); | 1077 | sb = GNUNET_strdup (&in[1]); |
1080 | #define DELIMS " \\|\"'`/&@-_,.;!?+-*^$#~=[]{}()<>" | 1078 | #define DELIMS " \\|\"'`/&@-_,.;!?+-*^$#~=[]{}()<>" |
1081 | for (tok = strtok (sb, DELIMS); NULL != tok; tok = strtok (NULL, DELIMS)) | 1079 | for (tok = strtok (sb, DELIMS); NULL != tok; tok = strtok (NULL, DELIMS)) |
1082 | #undef DELIMS | 1080 | #undef DELIMS |
1083 | { | 1081 | { |
1084 | if (strlen(tok) < 3) | 1082 | if (strlen (tok) < 3) |
1085 | continue; | 1083 | continue; |
1086 | GNUNET_FS_uri_ksk_add_keyword (ret, | 1084 | GNUNET_FS_uri_ksk_add_keyword (ret, tok, GNUNET_NO); |
1087 | tok, | ||
1088 | GNUNET_NO); | ||
1089 | cc = canonicalize_keyword (tok); | 1085 | cc = canonicalize_keyword (tok); |
1090 | if (strlen (cc) > 2) | 1086 | if (strlen (cc) > 2) |
1091 | GNUNET_FS_uri_ksk_add_keyword (ret, | 1087 | GNUNET_FS_uri_ksk_add_keyword (ret, cc, GNUNET_NO); |
1092 | cc, | ||
1093 | GNUNET_NO); | ||
1094 | } | 1088 | } |
1095 | GNUNET_free (sb); | 1089 | GNUNET_free (sb); |
1096 | } | 1090 | } |
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c index 9b3602d73..310c8a1ae 100644 --- a/src/fs/gnunet-fs.c +++ b/src/fs/gnunet-fs.c | |||
@@ -53,8 +53,7 @@ static int verbose; | |||
53 | * @param tc unused | 53 | * @param tc unused |
54 | */ | 54 | */ |
55 | static void | 55 | static void |
56 | do_shutdown (void *cls, | 56 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
57 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
58 | { | 57 | { |
59 | GNUNET_FS_stop (fs); | 58 | GNUNET_FS_stop (fs); |
60 | fs = NULL; | 59 | fs = NULL; |
@@ -70,18 +69,12 @@ do_shutdown (void *cls, | |||
70 | * @return GNUNET_OK to continue iteration | 69 | * @return GNUNET_OK to continue iteration |
71 | */ | 70 | */ |
72 | static int | 71 | static int |
73 | print_indexed (void *cls, const char *filename, | 72 | print_indexed (void *cls, const char *filename, const GNUNET_HashCode * file_id) |
74 | const GNUNET_HashCode * file_id) | ||
75 | { | 73 | { |
76 | if (verbose) | 74 | if (verbose) |
77 | fprintf (stdout, | 75 | fprintf (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename); |
78 | "%s: %s\n", | ||
79 | GNUNET_h2s (file_id), | ||
80 | filename); | ||
81 | else | 76 | else |
82 | fprintf (stdout, | 77 | fprintf (stdout, "%s\n", filename); |
83 | "%s\n", | ||
84 | filename); | ||
85 | return GNUNET_OK; | 78 | return GNUNET_OK; |
86 | } | 79 | } |
87 | 80 | ||
@@ -100,18 +93,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
100 | { | 93 | { |
101 | if (list_indexed_files) | 94 | if (list_indexed_files) |
102 | { | 95 | { |
103 | fs = GNUNET_FS_start (cfg, | 96 | fs = GNUNET_FS_start (cfg, "gnunet-fs", NULL, NULL, GNUNET_FS_FLAGS_NONE); |
104 | "gnunet-fs", | ||
105 | NULL, NULL, | ||
106 | GNUNET_FS_FLAGS_NONE); | ||
107 | if (NULL == fs) | 97 | if (NULL == fs) |
108 | { | 98 | { |
109 | ret = 1; | 99 | ret = 1; |
110 | return; | 100 | return; |
111 | } | 101 | } |
112 | GNUNET_FS_get_indexed_files (fs, | 102 | GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL, &do_shutdown, NULL); |
113 | &print_indexed, NULL, | ||
114 | &do_shutdown, NULL); | ||
115 | } | 103 | } |
116 | } | 104 | } |
117 | 105 | ||
@@ -134,8 +122,7 @@ main (int argc, char *const *argv) | |||
134 | }; | 122 | }; |
135 | return (GNUNET_OK == | 123 | return (GNUNET_OK == |
136 | GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]", | 124 | GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]", |
137 | gettext_noop | 125 | gettext_noop ("Special file-sharing operations"), |
138 | ("Special file-sharing operations"), | ||
139 | options, &run, NULL)) ? ret : 1; | 126 | options, &run, NULL)) ? ret : 1; |
140 | } | 127 | } |
141 | 128 | ||
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 404993130..f588ee9c4 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -226,19 +226,20 @@ GSF_test_get_load_too_high_ (uint32_t priority) | |||
226 | */ | 226 | */ |
227 | static void | 227 | static void |
228 | update_latencies (const struct GNUNET_ATS_Information *atsi, | 228 | update_latencies (const struct GNUNET_ATS_Information *atsi, |
229 | unsigned int atsi_count) | 229 | unsigned int atsi_count) |
230 | { | 230 | { |
231 | unsigned int i; | 231 | unsigned int i; |
232 | 232 | ||
233 | for (i=0;i<atsi_count;i++) | 233 | for (i = 0; i < atsi_count; i++) |
234 | { | 234 | { |
235 | if (ntohl(atsi[i].type) == GNUNET_ATS_QUALITY_NET_DELAY) | 235 | if (ntohl (atsi[i].type) == GNUNET_ATS_QUALITY_NET_DELAY) |
236 | { | 236 | { |
237 | GSF_avg_latency.rel_value = (GSF_avg_latency.rel_value * 31 + ntohl (atsi[i].value)) / 32; | 237 | GSF_avg_latency.rel_value = |
238 | (GSF_avg_latency.rel_value * 31 + ntohl (atsi[i].value)) / 32; | ||
238 | GNUNET_STATISTICS_set (GSF_stats, | 239 | GNUNET_STATISTICS_set (GSF_stats, |
239 | gettext_noop ("# running average P2P latency (ms)"), | 240 | gettext_noop |
240 | GSF_avg_latency.rel_value, | 241 | ("# running average P2P latency (ms)"), |
241 | GNUNET_NO); | 242 | GSF_avg_latency.rel_value, GNUNET_NO); |
242 | break; | 243 | break; |
243 | } | 244 | } |
244 | } | 245 | } |
@@ -261,7 +262,7 @@ static int | |||
261 | handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other, | 262 | handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other, |
262 | const struct GNUNET_MessageHeader *message, | 263 | const struct GNUNET_MessageHeader *message, |
263 | const struct GNUNET_ATS_Information *atsi, | 264 | const struct GNUNET_ATS_Information *atsi, |
264 | unsigned int atsi_count) | 265 | unsigned int atsi_count) |
265 | { | 266 | { |
266 | struct GSF_ConnectedPeer *cp; | 267 | struct GSF_ConnectedPeer *cp; |
267 | 268 | ||
@@ -294,13 +295,11 @@ consider_request_for_forwarding (void *cls, | |||
294 | { | 295 | { |
295 | struct GSF_PendingRequest *pr = cls; | 296 | struct GSF_PendingRequest *pr = cls; |
296 | 297 | ||
297 | if (GNUNET_YES != | 298 | if (GNUNET_YES != GSF_pending_request_test_target_ (pr, peer)) |
298 | GSF_pending_request_test_target_ (pr, | ||
299 | peer)) | ||
300 | { | 299 | { |
301 | GNUNET_STATISTICS_update (GSF_stats, | 300 | GNUNET_STATISTICS_update (GSF_stats, |
302 | gettext_noop ("# Loopback routes suppressed"), 1, | 301 | gettext_noop ("# Loopback routes suppressed"), 1, |
303 | GNUNET_NO); | 302 | GNUNET_NO); |
304 | return; | 303 | return; |
305 | } | 304 | } |
306 | GSF_plan_add_ (cp, pr); | 305 | GSF_plan_add_ (cp, pr); |
@@ -343,7 +342,7 @@ static int | |||
343 | handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other, | 342 | handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other, |
344 | const struct GNUNET_MessageHeader *message, | 343 | const struct GNUNET_MessageHeader *message, |
345 | const struct GNUNET_ATS_Information *atsi, | 344 | const struct GNUNET_ATS_Information *atsi, |
346 | unsigned int atsi_count) | 345 | unsigned int atsi_count) |
347 | { | 346 | { |
348 | struct GSF_PendingRequest *pr; | 347 | struct GSF_PendingRequest *pr; |
349 | 348 | ||
@@ -475,13 +474,11 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key, | |||
475 | struct GNUNET_PeerIdentity pid; | 474 | struct GNUNET_PeerIdentity pid; |
476 | 475 | ||
477 | GSF_connected_peer_get_identity_ (cp, &pid); | 476 | GSF_connected_peer_get_identity_ (cp, &pid); |
478 | if (GNUNET_YES != | 477 | if (GNUNET_YES != GSF_pending_request_test_target_ (pr, &pid)) |
479 | GSF_pending_request_test_target_ (pr, | ||
480 | &pid)) | ||
481 | { | 478 | { |
482 | GNUNET_STATISTICS_update (GSF_stats, | 479 | GNUNET_STATISTICS_update (GSF_stats, |
483 | gettext_noop ("# Loopback routes suppressed"), 1, | 480 | gettext_noop ("# Loopback routes suppressed"), 1, |
484 | GNUNET_NO); | 481 | GNUNET_NO); |
485 | return GNUNET_YES; | 482 | return GNUNET_YES; |
486 | } | 483 | } |
487 | GSF_plan_add_ (cp, pr); | 484 | GSF_plan_add_ (cp, pr); |
@@ -500,7 +497,7 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key, | |||
500 | static void | 497 | static void |
501 | peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, | 498 | peer_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, |
502 | const struct GNUNET_ATS_Information *atsi, | 499 | const struct GNUNET_ATS_Information *atsi, |
503 | unsigned int atsi_count) | 500 | unsigned int atsi_count) |
504 | { | 501 | { |
505 | struct GSF_ConnectedPeer *cp; | 502 | struct GSF_ConnectedPeer *cp; |
506 | 503 | ||
@@ -568,9 +565,8 @@ main_init (struct GNUNET_SERVER_Handle *server, | |||
568 | GSF_core = GNUNET_CORE_connect (GSF_cfg, 2, /* larger? */ | 565 | GSF_core = GNUNET_CORE_connect (GSF_cfg, 2, /* larger? */ |
569 | NULL, &peer_init_handler, | 566 | NULL, &peer_init_handler, |
570 | &peer_connect_handler, | 567 | &peer_connect_handler, |
571 | &GSF_peer_disconnect_handler_, | 568 | &GSF_peer_disconnect_handler_, NULL, |
572 | NULL, GNUNET_NO, | 569 | GNUNET_NO, NULL, GNUNET_NO, p2p_handlers); |
573 | NULL, GNUNET_NO, p2p_handlers); | ||
574 | if (NULL == GSF_core) | 570 | if (NULL == GSF_core) |
575 | { | 571 | { |
576 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 572 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 859d9275f..d4c81d509 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -332,15 +332,14 @@ get_trust_filename (const struct GNUNET_PeerIdentity *id) | |||
332 | * @return connection latency | 332 | * @return connection latency |
333 | */ | 333 | */ |
334 | static struct GNUNET_TIME_Relative | 334 | static struct GNUNET_TIME_Relative |
335 | get_latency (const struct GNUNET_ATS_Information *atsi, | 335 | get_latency (const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) |
336 | unsigned int atsi_count) | ||
337 | { | 336 | { |
338 | unsigned int i; | 337 | unsigned int i; |
339 | 338 | ||
340 | for (i=0;i<atsi_count;i++) | 339 | for (i = 0; i < atsi_count; i++) |
341 | if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DELAY) | 340 | if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DELAY) |
342 | return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 341 | return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
343 | ntohl (atsi->value)); | 342 | ntohl (atsi->value)); |
344 | return GNUNET_TIME_UNIT_SECONDS; | 343 | return GNUNET_TIME_UNIT_SECONDS; |
345 | } | 344 | } |
346 | 345 | ||
@@ -354,8 +353,7 @@ get_latency (const struct GNUNET_ATS_Information *atsi, | |||
354 | */ | 353 | */ |
355 | static void | 354 | static void |
356 | update_atsi (struct GSF_ConnectedPeer *cp, | 355 | update_atsi (struct GSF_ConnectedPeer *cp, |
357 | const struct GNUNET_ATS_Information *atsi, | 356 | const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count) |
358 | unsigned int atsi_count) | ||
359 | { | 357 | { |
360 | struct GNUNET_TIME_Relative latency; | 358 | struct GNUNET_TIME_Relative latency; |
361 | 359 | ||
@@ -402,7 +400,7 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf); | |||
402 | */ | 400 | */ |
403 | static void | 401 | static void |
404 | ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | 402 | ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, |
405 | int32_t amount, struct GNUNET_TIME_Relative res_delay); | 403 | int32_t amount, struct GNUNET_TIME_Relative res_delay); |
406 | 404 | ||
407 | 405 | ||
408 | /** | 406 | /** |
@@ -425,11 +423,9 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth) | |||
425 | 423 | ||
426 | if (0 != cp->inc_preference) | 424 | if (0 != cp->inc_preference) |
427 | { | 425 | { |
428 | GNUNET_ATS_change_preference (ats, | 426 | GNUNET_ATS_change_preference (ats, &target, GNUNET_ATS_PREFERENCE_BANDWIDTH, |
429 | &target, | 427 | (double) cp->inc_preference, |
430 | GNUNET_ATS_PREFERENCE_BANDWIDTH, | 428 | GNUNET_ATS_PREFERENCE_END); |
431 | (double) cp->inc_preference, | ||
432 | GNUNET_ATS_PREFERENCE_END); | ||
433 | cp->inc_preference = 0; | 429 | cp->inc_preference = 0; |
434 | } | 430 | } |
435 | 431 | ||
@@ -442,9 +438,8 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth) | |||
442 | /* reservation already done! */ | 438 | /* reservation already done! */ |
443 | pth->was_reserved = GNUNET_YES; | 439 | pth->was_reserved = GNUNET_YES; |
444 | cp->rc = | 440 | cp->rc = |
445 | GNUNET_ATS_reserve_bandwidth (ats, &target, | 441 | GNUNET_ATS_reserve_bandwidth (ats, &target, DBLOCK_SIZE, |
446 | DBLOCK_SIZE, | 442 | &ats_reserve_callback, cp); |
447 | &ats_reserve_callback, cp); | ||
448 | } | 443 | } |
449 | GNUNET_assert (pth->cth == NULL); | 444 | GNUNET_assert (pth->cth == NULL); |
450 | pth->cth_in_progress++; | 445 | pth->cth_in_progress++; |
@@ -525,9 +520,8 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
525 | GNUNET_PEER_resolve (cp->ppd.pid, &target); | 520 | GNUNET_PEER_resolve (cp->ppd.pid, &target); |
526 | cp->rc_delay_task = GNUNET_SCHEDULER_NO_TASK; | 521 | cp->rc_delay_task = GNUNET_SCHEDULER_NO_TASK; |
527 | cp->rc = | 522 | cp->rc = |
528 | GNUNET_ATS_reserve_bandwidth (ats, &target, | 523 | GNUNET_ATS_reserve_bandwidth (ats, &target, DBLOCK_SIZE, |
529 | DBLOCK_SIZE, | 524 | &ats_reserve_callback, cp); |
530 | &ats_reserve_callback, cp); | ||
531 | } | 525 | } |
532 | 526 | ||
533 | 527 | ||
@@ -543,15 +537,14 @@ retry_reservation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
543 | */ | 537 | */ |
544 | static void | 538 | static void |
545 | ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | 539 | ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, |
546 | int32_t amount, struct GNUNET_TIME_Relative res_delay) | 540 | int32_t amount, struct GNUNET_TIME_Relative res_delay) |
547 | { | 541 | { |
548 | struct GSF_ConnectedPeer *cp = cls; | 542 | struct GSF_ConnectedPeer *cp = cls; |
549 | struct GSF_PeerTransmitHandle *pth; | 543 | struct GSF_PeerTransmitHandle *pth; |
550 | 544 | ||
551 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
552 | "Reserved %d bytes / need to wait %llu ms for reservation\n", | 546 | "Reserved %d bytes / need to wait %llu ms for reservation\n", |
553 | (int) amount, | 547 | (int) amount, (unsigned long long) res_delay.rel_value); |
554 | (unsigned long long) res_delay.rel_value); | ||
555 | cp->rc = NULL; | 548 | cp->rc = NULL; |
556 | if (0 == amount) | 549 | if (0 == amount) |
557 | { | 550 | { |
@@ -587,22 +580,20 @@ ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
587 | struct GSF_ConnectedPeer * | 580 | struct GSF_ConnectedPeer * |
588 | GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | 581 | GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, |
589 | const struct GNUNET_ATS_Information *atsi, | 582 | const struct GNUNET_ATS_Information *atsi, |
590 | unsigned int atsi_count) | 583 | unsigned int atsi_count) |
591 | { | 584 | { |
592 | struct GSF_ConnectedPeer *cp; | 585 | struct GSF_ConnectedPeer *cp; |
593 | char *fn; | 586 | char *fn; |
594 | uint32_t trust; | 587 | uint32_t trust; |
595 | 588 | ||
596 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n", |
597 | "Connected to peer %s\n", | 590 | GNUNET_i2s (peer)); |
598 | GNUNET_i2s (peer)); | ||
599 | cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer)); | 591 | cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer)); |
600 | cp->ppd.pid = GNUNET_PEER_intern (peer); | 592 | cp->ppd.pid = GNUNET_PEER_intern (peer); |
601 | cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); | 593 | cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); |
602 | cp->rc = | 594 | cp->rc = |
603 | GNUNET_ATS_reserve_bandwidth (ats, peer, | 595 | GNUNET_ATS_reserve_bandwidth (ats, peer, DBLOCK_SIZE, |
604 | DBLOCK_SIZE, | 596 | &ats_reserve_callback, cp); |
605 | &ats_reserve_callback, cp); | ||
606 | fn = get_trust_filename (peer); | 597 | fn = get_trust_filename (peer); |
607 | if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && | 598 | if ((GNUNET_DISK_file_test (fn) == GNUNET_YES) && |
608 | (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) | 599 | (sizeof (trust) == GNUNET_DISK_fn_read (fn, &trust, sizeof (trust)))) |
@@ -613,11 +604,9 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | |||
613 | GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey, | 604 | GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey, |
614 | cp, | 605 | cp, |
615 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 606 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
616 | GNUNET_STATISTICS_set (GSF_stats, | 607 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), |
617 | gettext_noop | 608 | GNUNET_CONTAINER_multihashmap_size (cp_map), |
618 | ("# peers connected"), | 609 | GNUNET_NO); |
619 | GNUNET_CONTAINER_multihashmap_size (cp_map), | ||
620 | GNUNET_NO); | ||
621 | update_atsi (cp, atsi, atsi_count); | 610 | update_atsi (cp, atsi, atsi_count); |
622 | GSF_push_start_ (cp); | 611 | GSF_push_start_ (cp); |
623 | return cp; | 612 | return cp; |
@@ -681,9 +670,8 @@ int | |||
681 | GSF_handle_p2p_migration_stop_ (void *cls, | 670 | GSF_handle_p2p_migration_stop_ (void *cls, |
682 | const struct GNUNET_PeerIdentity *other, | 671 | const struct GNUNET_PeerIdentity *other, |
683 | const struct GNUNET_MessageHeader *message, | 672 | const struct GNUNET_MessageHeader *message, |
684 | const struct GNUNET_ATS_Information | 673 | const struct GNUNET_ATS_Information *atsi, |
685 | *atsi, | 674 | unsigned int atsi_count) |
686 | unsigned int atsi_count) | ||
687 | { | 675 | { |
688 | struct GSF_ConnectedPeer *cp; | 676 | struct GSF_ConnectedPeer *cp; |
689 | const struct MigrationStopMessage *msm; | 677 | const struct MigrationStopMessage *msm; |
@@ -697,9 +685,8 @@ GSF_handle_p2p_migration_stop_ (void *cls, | |||
697 | return GNUNET_OK; | 685 | return GNUNET_OK; |
698 | } | 686 | } |
699 | GNUNET_STATISTICS_update (GSF_stats, | 687 | GNUNET_STATISTICS_update (GSF_stats, |
700 | gettext_noop | 688 | gettext_noop ("# migration stop messages received"), |
701 | ("# migration stop messages received"), | 689 | 1, GNUNET_NO); |
702 | 1, GNUNET_NO); | ||
703 | bt = GNUNET_TIME_relative_ntoh (msm->duration); | 690 | bt = GNUNET_TIME_relative_ntoh (msm->duration); |
704 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 691 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
705 | _("Migration of content to peer `%s' blocked for %llu ms\n"), | 692 | _("Migration of content to peer `%s' blocked for %llu ms\n"), |
@@ -841,8 +828,8 @@ get_randomized_delay () | |||
841 | ret = | 828 | ret = |
842 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 829 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
843 | GNUNET_CRYPTO_random_u32 | 830 | GNUNET_CRYPTO_random_u32 |
844 | (GNUNET_CRYPTO_QUALITY_WEAK, | 831 | (GNUNET_CRYPTO_QUALITY_WEAK, |
845 | 2 * GSF_avg_latency.rel_value + 1)); | 832 | 2 * GSF_avg_latency.rel_value + 1)); |
846 | GNUNET_STATISTICS_update (GSF_stats, | 833 | GNUNET_STATISTICS_update (GSF_stats, |
847 | gettext_noop | 834 | gettext_noop |
848 | ("# artificial delays introduced (ms)"), | 835 | ("# artificial delays introduced (ms)"), |
@@ -1179,7 +1166,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
1179 | return NULL; | 1166 | return NULL; |
1180 | } | 1167 | } |
1181 | if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO)) | 1168 | if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO)) |
1182 | cp = GSF_peer_get_ ((const struct GNUNET_PeerIdentity*) &opt[bits++]); | 1169 | cp = GSF_peer_get_ ((const struct GNUNET_PeerIdentity *) &opt[bits++]); |
1183 | else | 1170 | else |
1184 | cp = cps; | 1171 | cp = cps; |
1185 | if (cp == NULL) | 1172 | if (cp == NULL) |
@@ -1323,9 +1310,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
1323 | 0) ? (const char *) &opt[bits] : NULL, | 1310 | 0) ? (const char *) &opt[bits] : NULL, |
1324 | bfsize, ntohl (gm->filter_mutator), | 1311 | bfsize, ntohl (gm->filter_mutator), |
1325 | 1 /* anonymity */ , | 1312 | 1 /* anonymity */ , |
1326 | (uint32_t) priority, ttl, spid, | 1313 | (uint32_t) priority, ttl, spid, GNUNET_PEER_intern (other), NULL, 0, /* replies_seen */ |
1327 | GNUNET_PEER_intern (other), | ||
1328 | NULL, 0, /* replies_seen */ | ||
1329 | &handle_p2p_reply, peerreq); | 1314 | &handle_p2p_reply, peerreq); |
1330 | GNUNET_assert (NULL != pr); | 1315 | GNUNET_assert (NULL != pr); |
1331 | peerreq->pr = pr; | 1316 | peerreq->pr = pr; |
@@ -1547,11 +1532,9 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1547 | GNUNET_assert (GNUNET_YES == | 1532 | GNUNET_assert (GNUNET_YES == |
1548 | GNUNET_CONTAINER_multihashmap_remove (cp_map, | 1533 | GNUNET_CONTAINER_multihashmap_remove (cp_map, |
1549 | &peer->hashPubKey, cp)); | 1534 | &peer->hashPubKey, cp)); |
1550 | GNUNET_STATISTICS_set (GSF_stats, | 1535 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), |
1551 | gettext_noop | 1536 | GNUNET_CONTAINER_multihashmap_size (cp_map), |
1552 | ("# peers connected"), | 1537 | GNUNET_NO); |
1553 | GNUNET_CONTAINER_multihashmap_size (cp_map), | ||
1554 | GNUNET_NO); | ||
1555 | if (NULL != cp->migration_pth) | 1538 | if (NULL != cp->migration_pth) |
1556 | { | 1539 | { |
1557 | GSF_peer_transmit_cancel_ (cp->migration_pth); | 1540 | GSF_peer_transmit_cancel_ (cp->migration_pth); |
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 8923513c7..a2cc5232c 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h | |||
@@ -174,7 +174,7 @@ struct GSF_PeerTransmitHandle; | |||
174 | struct GSF_ConnectedPeer * | 174 | struct GSF_ConnectedPeer * |
175 | GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | 175 | GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, |
176 | const struct GNUNET_ATS_Information *atsi, | 176 | const struct GNUNET_ATS_Information *atsi, |
177 | unsigned int atsi_count); | 177 | unsigned int atsi_count); |
178 | 178 | ||
179 | 179 | ||
180 | /** | 180 | /** |
@@ -270,9 +270,8 @@ int | |||
270 | GSF_handle_p2p_migration_stop_ (void *cls, | 270 | GSF_handle_p2p_migration_stop_ (void *cls, |
271 | const struct GNUNET_PeerIdentity *other, | 271 | const struct GNUNET_PeerIdentity *other, |
272 | const struct GNUNET_MessageHeader *message, | 272 | const struct GNUNET_MessageHeader *message, |
273 | const struct GNUNET_ATS_Information | 273 | const struct GNUNET_ATS_Information *atsi, |
274 | *atsi, | 274 | unsigned int atsi_count); |
275 | unsigned int atsi_count); | ||
276 | 275 | ||
277 | 276 | ||
278 | /** | 277 | /** |
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 5978e4d66..41a40e125 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c | |||
@@ -538,13 +538,12 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, uint32_t size, | |||
538 | odb = (const struct OnDemandBlock *) data; | 538 | odb = (const struct OnDemandBlock *) data; |
539 | off = GNUNET_ntohll (odb->offset); | 539 | off = GNUNET_ntohll (odb->offset); |
540 | fn = (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id); | 540 | fn = (const char *) GNUNET_CONTAINER_multihashmap_get (ifm, &odb->file_id); |
541 | if ( (NULL == fn) || | 541 | if ((NULL == fn) || (0 != ACCESS (fn, R_OK))) |
542 | (0 != ACCESS (fn, R_OK)) ) | ||
543 | { | 542 | { |
544 | GNUNET_STATISTICS_update (GSF_stats, | 543 | GNUNET_STATISTICS_update (GSF_stats, |
545 | gettext_noop ("# index blocks removed: original file inaccessible"), | 544 | gettext_noop |
546 | 1, | 545 | ("# index blocks removed: original file inaccessible"), |
547 | GNUNET_YES); | 546 | 1, GNUNET_YES); |
548 | GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, | 547 | GNUNET_DATASTORE_remove (dsh, key, size, data, -1, -1, |
549 | GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); | 548 | GNUNET_TIME_UNIT_FOREVER_REL, &remove_cont, NULL); |
550 | return GNUNET_SYSERR; | 549 | return GNUNET_SYSERR; |
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c index 9f284ed8f..30a7f57d6 100644 --- a/src/fs/gnunet-service-fs_lc.c +++ b/src/fs/gnunet-service-fs_lc.c | |||
@@ -375,7 +375,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, | |||
375 | ntohl (sm->anonymity_level), | 375 | ntohl (sm->anonymity_level), |
376 | 0 /* priority */ , | 376 | 0 /* priority */ , |
377 | 0 /* ttl */ , | 377 | 0 /* ttl */ , |
378 | 0 /* sender PID */ , 0 /* origin PID */, | 378 | 0 /* sender PID */ , |
379 | 0 /* origin PID */ , | ||
379 | (const GNUNET_HashCode *) &sm[1], sc, | 380 | (const GNUNET_HashCode *) &sm[1], sc, |
380 | &client_response_handler, cr); | 381 | &client_response_handler, cr); |
381 | return cr->pr; | 382 | return cr->pr; |
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index 088a3dc11..41dd61a64 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c | |||
@@ -263,22 +263,25 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
263 | if (rp->transmission_counter < 8) | 263 | if (rp->transmission_counter < 8) |
264 | delay = | 264 | delay = |
265 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 265 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
266 | rp->transmission_counter); | 266 | rp->transmission_counter); |
267 | else if (rp->transmission_counter < 32) | 267 | else if (rp->transmission_counter < 32) |
268 | delay = | 268 | delay = |
269 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 269 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
270 | 8 + (1LL << (rp->transmission_counter - 8))); | 270 | 8 + |
271 | (1LL << (rp->transmission_counter - 8))); | ||
271 | else | 272 | else |
272 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 273 | delay = |
273 | 8 + (1LL << 24)); | 274 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
274 | delay.rel_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 275 | 8 + (1LL << 24)); |
275 | delay.rel_value + 1); | 276 | delay.rel_value = |
277 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
278 | delay.rel_value + 1); | ||
276 | if (rp->transmission_counter != 0) | 279 | if (rp->transmission_counter != 0) |
277 | delay.rel_value += TTL_DECREMENT; | 280 | delay.rel_value += TTL_DECREMENT; |
278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 281 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
279 | "Considering (re)transmission number %u in %llu ms\n", | 282 | "Considering (re)transmission number %u in %llu ms\n", |
280 | (unsigned int) rp->transmission_counter, | 283 | (unsigned int) rp->transmission_counter, |
281 | (unsigned long long) delay.rel_value); | 284 | (unsigned long long) delay.rel_value); |
282 | rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); | 285 | rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); |
283 | #if DEBUG_FS | 286 | #if DEBUG_FS |
284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -295,9 +298,9 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) | |||
295 | GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp, | 298 | GNUNET_CONTAINER_heap_insert (pp->delay_heap, rp, |
296 | rp->earliest_transmission.abs_value); | 299 | rp->earliest_transmission.abs_value); |
297 | GNUNET_assert (GNUNET_YES == | 300 | GNUNET_assert (GNUNET_YES == |
298 | GNUNET_CONTAINER_multihashmap_contains_value (pp->plan_map, | 301 | GNUNET_CONTAINER_multihashmap_contains_value (pp->plan_map, |
299 | get_rp_key (rp), | 302 | get_rp_key (rp), |
300 | rp)); | 303 | rp)); |
301 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) | 304 | if (GNUNET_SCHEDULER_NO_TASK != pp->task) |
302 | GNUNET_SCHEDULER_cancel (pp->task); | 305 | GNUNET_SCHEDULER_cancel (pp->task); |
303 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); | 306 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); |
@@ -351,8 +354,9 @@ transmit_message_callback (void *cls, size_t buf_size, void *buf) | |||
351 | /* failed, try again... */ | 354 | /* failed, try again... */ |
352 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); | 355 | pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp); |
353 | GNUNET_STATISTICS_update (GSF_stats, | 356 | GNUNET_STATISTICS_update (GSF_stats, |
354 | gettext_noop ("# transmission failed (core has no bandwidth)"), 1, | 357 | gettext_noop |
355 | GNUNET_NO); | 358 | ("# transmission failed (core has no bandwidth)"), |
359 | 1, GNUNET_NO); | ||
356 | return 0; | 360 | return 0; |
357 | } | 361 | } |
358 | rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap); | 362 | rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap); |
@@ -433,22 +437,17 @@ schedule_peer_transmission (void *cls, | |||
433 | #if DEBUG_FS | 437 | #if DEBUG_FS |
434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
435 | "Sleeping for %llu ms before retrying requests on plan %p.\n", | 439 | "Sleeping for %llu ms before retrying requests on plan %p.\n", |
436 | (unsigned long long) | 440 | (unsigned long long) delay.rel_value, pp); |
437 | delay.rel_value, pp); | ||
438 | #endif | 441 | #endif |
439 | GNUNET_STATISTICS_set (GSF_stats, | 442 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout"), |
440 | gettext_noop ("# delay heap timeout"), | 443 | delay.rel_value, GNUNET_NO); |
441 | delay.rel_value, | 444 | |
442 | GNUNET_NO); | ||
443 | |||
444 | pp->task = | 445 | pp->task = |
445 | GNUNET_SCHEDULER_add_delayed (delay, | 446 | GNUNET_SCHEDULER_add_delayed (delay, &schedule_peer_transmission, pp); |
446 | &schedule_peer_transmission, pp); | ||
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | GNUNET_STATISTICS_update (GSF_stats, | 449 | GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plans executed"), |
450 | gettext_noop ("# query plans executed"), 1, | 450 | 1, GNUNET_NO); |
451 | GNUNET_NO); | ||
452 | /* process from priority heap */ | 451 | /* process from priority heap */ |
453 | rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap); | 452 | rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap); |
454 | #if DEBUG_FS > 1 | 453 | #if DEBUG_FS > 1 |
@@ -488,9 +487,7 @@ struct MergeContext | |||
488 | * GNUNET_NO if not (merge success) | 487 | * GNUNET_NO if not (merge success) |
489 | */ | 488 | */ |
490 | static int | 489 | static int |
491 | merge_pr (void *cls, | 490 | merge_pr (void *cls, const GNUNET_HashCode * query, void *element) |
492 | const GNUNET_HashCode *query, | ||
493 | void *element) | ||
494 | { | 491 | { |
495 | struct MergeContext *mpr = cls; | 492 | struct MergeContext *mpr = cls; |
496 | struct GSF_RequestPlan *rp = element; | 493 | struct GSF_RequestPlan *rp = element; |
@@ -550,8 +547,7 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) | |||
550 | if (NULL == pp) | 547 | if (NULL == pp) |
551 | { | 548 | { |
552 | pp = GNUNET_malloc (sizeof (struct PeerPlan)); | 549 | pp = GNUNET_malloc (sizeof (struct PeerPlan)); |
553 | pp->plan_map = | 550 | pp->plan_map = GNUNET_CONTAINER_multihashmap_create (128); |
554 | GNUNET_CONTAINER_multihashmap_create (128); | ||
555 | pp->priority_heap = | 551 | pp->priority_heap = |
556 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX); | 552 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX); |
557 | pp->delay_heap = | 553 | pp->delay_heap = |
@@ -563,13 +559,13 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) | |||
563 | mpc.merged = GNUNET_NO; | 559 | mpc.merged = GNUNET_NO; |
564 | mpc.pr = pr; | 560 | mpc.pr = pr; |
565 | GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map, | 561 | GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map, |
566 | &GSF_pending_request_get_data_ (pr)->query, | 562 | &GSF_pending_request_get_data_ |
567 | &merge_pr, &mpc); | 563 | (pr)->query, &merge_pr, &mpc); |
568 | if (mpc.merged != GNUNET_NO) | 564 | if (mpc.merged != GNUNET_NO) |
569 | return; | 565 | return; |
570 | GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map, | 566 | GNUNET_CONTAINER_multihashmap_get_multiple (pp->plan_map, |
571 | &GSF_pending_request_get_data_ (pr)->query, | 567 | &GSF_pending_request_get_data_ |
572 | &merge_pr, &mpc); | 568 | (pr)->query, &merge_pr, &mpc); |
573 | if (mpc.merged != GNUNET_NO) | 569 | if (mpc.merged != GNUNET_NO) |
574 | return; | 570 | return; |
575 | plan_count++; | 571 | plan_count++; |
@@ -592,10 +588,9 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) | |||
592 | GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); | 588 | GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); |
593 | rp->pp = pp; | 589 | rp->pp = pp; |
594 | GNUNET_assert (GNUNET_YES == | 590 | GNUNET_assert (GNUNET_YES == |
595 | GNUNET_CONTAINER_multihashmap_put (pp->plan_map, | 591 | GNUNET_CONTAINER_multihashmap_put (pp->plan_map, |
596 | get_rp_key (rp), | 592 | get_rp_key (rp), rp, |
597 | rp, | 593 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
598 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
599 | plan (pp, rp); | 594 | plan (pp, rp); |
600 | } | 595 | } |
601 | 596 | ||
@@ -632,9 +627,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) | |||
632 | while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->priority_heap))) | 627 | while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->priority_heap))) |
633 | { | 628 | { |
634 | GNUNET_break (GNUNET_YES == | 629 | GNUNET_break (GNUNET_YES == |
635 | GNUNET_CONTAINER_multihashmap_remove (pp->plan_map, | 630 | GNUNET_CONTAINER_multihashmap_remove (pp->plan_map, |
636 | get_rp_key (rp), | 631 | get_rp_key (rp), rp)); |
637 | rp)); | ||
638 | while (NULL != (prl = rp->prl_head)) | 632 | while (NULL != (prl = rp->prl_head)) |
639 | { | 633 | { |
640 | GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl); | 634 | GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl); |
@@ -649,9 +643,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) | |||
649 | while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->delay_heap))) | 643 | while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->delay_heap))) |
650 | { | 644 | { |
651 | GNUNET_break (GNUNET_YES == | 645 | GNUNET_break (GNUNET_YES == |
652 | GNUNET_CONTAINER_multihashmap_remove (pp->plan_map, | 646 | GNUNET_CONTAINER_multihashmap_remove (pp->plan_map, |
653 | get_rp_key (rp), | 647 | get_rp_key (rp), rp)); |
654 | rp)); | ||
655 | while (NULL != (prl = rp->prl_head)) | 648 | while (NULL != (prl = rp->prl_head)) |
656 | { | 649 | { |
657 | GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl); | 650 | GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl); |
@@ -695,9 +688,10 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr) | |||
695 | GNUNET_CONTAINER_heap_remove_node (rp->hn); | 688 | GNUNET_CONTAINER_heap_remove_node (rp->hn); |
696 | plan_count--; | 689 | plan_count--; |
697 | GNUNET_break (GNUNET_YES == | 690 | GNUNET_break (GNUNET_YES == |
698 | GNUNET_CONTAINER_multihashmap_remove (rp->pp->plan_map, | 691 | GNUNET_CONTAINER_multihashmap_remove (rp->pp->plan_map, |
699 | &GSF_pending_request_get_data_ (rpr->prl->pr)->query, | 692 | &GSF_pending_request_get_data_ |
700 | rp)); | 693 | (rpr->prl->pr)->query, |
694 | rp)); | ||
701 | GNUNET_free (rp); | 695 | GNUNET_free (rp); |
702 | } | 696 | } |
703 | GNUNET_free (rpr->prl); | 697 | GNUNET_free (rpr->prl); |
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 63ae3a75f..ac183a980 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -216,10 +216,10 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr) | |||
216 | if (pr->bf != NULL) | 216 | if (pr->bf != NULL) |
217 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); | 217 | GNUNET_CONTAINER_bloomfilter_free (pr->bf); |
218 | pr->mingle = | 218 | pr->mingle = |
219 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); | 219 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); |
220 | pr->bf = GNUNET_BLOCK_construct_bloomfilter (pr->mingle, | 220 | pr->bf = |
221 | pr->replies_seen, | 221 | GNUNET_BLOCK_construct_bloomfilter (pr->mingle, pr->replies_seen, |
222 | pr->replies_seen_count); | 222 | pr->replies_seen_count); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
@@ -319,7 +319,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, | |||
319 | if (NULL != bf_data) | 319 | if (NULL != bf_data) |
320 | { | 320 | { |
321 | pr->bf = | 321 | pr->bf = |
322 | GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, GNUNET_CONSTANTS_BLOOMFILTER_K); | 322 | GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size, |
323 | GNUNET_CONSTANTS_BLOOMFILTER_K); | ||
323 | pr->mingle = mingle; | 324 | pr->mingle = mingle; |
324 | } | 325 | } |
325 | else if ((replies_seen_count > 0) && | 326 | else if ((replies_seen_count > 0) && |
@@ -433,17 +434,16 @@ GSF_pending_request_update_ (struct GSF_PendingRequest *pr, | |||
433 | pr->mingle = | 434 | pr->mingle = |
434 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); | 435 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX); |
435 | pr->bf = | 436 | pr->bf = |
436 | GNUNET_BLOCK_construct_bloomfilter (pr->mingle, | 437 | GNUNET_BLOCK_construct_bloomfilter (pr->mingle, replies_seen, |
437 | replies_seen, | 438 | replies_seen_count); |
438 | replies_seen_count); | 439 | } |
439 | } | ||
440 | else | 440 | else |
441 | { | 441 | { |
442 | for (i = 0; i < pr->replies_seen_count; i++) | 442 | for (i = 0; i < pr->replies_seen_count; i++) |
443 | { | 443 | { |
444 | GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash); | 444 | GNUNET_BLOCK_mingle_hash (&replies_seen[i], pr->mingle, &mhash); |
445 | GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash); | 445 | GNUNET_CONTAINER_bloomfilter_add (pr->bf, &mhash); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | } | 448 | } |
449 | } | 449 | } |
@@ -970,10 +970,10 @@ static void | |||
970 | handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, | 970 | handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, |
971 | const GNUNET_HashCode * key, | 971 | const GNUNET_HashCode * key, |
972 | const struct GNUNET_PeerIdentity *get_path, | 972 | const struct GNUNET_PeerIdentity *get_path, |
973 | unsigned int get_path_length, | 973 | unsigned int get_path_length, |
974 | const struct GNUNET_PeerIdentity *put_path, | 974 | const struct GNUNET_PeerIdentity *put_path, |
975 | unsigned int put_path_length, | 975 | unsigned int put_path_length, enum GNUNET_BLOCK_Type type, |
976 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) | 976 | size_t size, const void *data) |
977 | { | 977 | { |
978 | struct GSF_PendingRequest *pr = cls; | 978 | struct GSF_PendingRequest *pr = cls; |
979 | struct ProcessReplyClosure prq; | 979 | struct ProcessReplyClosure prq; |
@@ -1051,11 +1051,10 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr) | |||
1051 | pr->gh = | 1051 | pr->gh = |
1052 | GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL, | 1052 | GNUNET_DHT_get_start (GSF_dht, GNUNET_TIME_UNIT_FOREVER_REL, |
1053 | pr->public_data.type, &pr->public_data.query, | 1053 | pr->public_data.type, &pr->public_data.query, |
1054 | 5 /* DEFAULT_GET_REPLICATION */, | 1054 | 5 /* DEFAULT_GET_REPLICATION */ , |
1055 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 1055 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
1056 | /* FIXME: can no longer pass pr->bf/pr->mingle... */ | 1056 | /* FIXME: can no longer pass pr->bf/pr->mingle... */ |
1057 | xquery, xquery_size, &handle_dht_reply, | 1057 | xquery, xquery_size, &handle_dht_reply, pr); |
1058 | pr); | ||
1059 | } | 1058 | } |
1060 | 1059 | ||
1061 | 1060 | ||
@@ -1231,16 +1230,17 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size, | |||
1231 | /* queue priority */ , | 1230 | /* queue priority */ , |
1232 | (0 != | 1231 | (0 != |
1233 | (GSF_PRO_PRIORITY_UNLIMITED & | 1232 | (GSF_PRO_PRIORITY_UNLIMITED & |
1234 | pr->public_data.options)) ? UINT_MAX : datastore_queue_size | 1233 | pr->public_data.options)) ? UINT_MAX : |
1234 | datastore_queue_size | ||
1235 | /* max queue size */ , | 1235 | /* max queue size */ , |
1236 | GNUNET_TIME_UNIT_FOREVER_REL, | 1236 | GNUNET_TIME_UNIT_FOREVER_REL, |
1237 | &process_local_reply, pr); | 1237 | &process_local_reply, pr); |
1238 | if (NULL != pr->qe) | 1238 | if (NULL != pr->qe) |
1239 | return; /* we're done */ | 1239 | return; /* we're done */ |
1240 | GNUNET_STATISTICS_update (GSF_stats, | 1240 | GNUNET_STATISTICS_update (GSF_stats, |
1241 | gettext_noop | 1241 | gettext_noop |
1242 | ("# Datastore lookups concluded (error queueing)"), | 1242 | ("# Datastore lookups concluded (error queueing)"), |
1243 | 1, GNUNET_NO); | 1243 | 1, GNUNET_NO); |
1244 | goto check_error_and_continue; | 1244 | goto check_error_and_continue; |
1245 | } | 1245 | } |
1246 | old_rf = pr->public_data.results_found; | 1246 | old_rf = pr->public_data.results_found; |
@@ -1270,7 +1270,8 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size, | |||
1270 | /* queue priority */ , | 1270 | /* queue priority */ , |
1271 | (0 != | 1271 | (0 != |
1272 | (GSF_PRO_PRIORITY_UNLIMITED & | 1272 | (GSF_PRO_PRIORITY_UNLIMITED & |
1273 | pr->public_data.options)) ? UINT_MAX : datastore_queue_size | 1273 | pr->public_data.options)) ? UINT_MAX : |
1274 | datastore_queue_size | ||
1274 | /* max queue size */ , | 1275 | /* max queue size */ , |
1275 | GNUNET_TIME_UNIT_FOREVER_REL, | 1276 | GNUNET_TIME_UNIT_FOREVER_REL, |
1276 | &process_local_reply, pr); | 1277 | &process_local_reply, pr); |
@@ -1329,7 +1330,8 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size, | |||
1329 | /* queue priority */ , | 1330 | /* queue priority */ , |
1330 | (0 != | 1331 | (0 != |
1331 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | 1332 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> |
1332 | public_data.options)) ? UINT_MAX : datastore_queue_size | 1333 | public_data.options)) ? UINT_MAX : |
1334 | datastore_queue_size | ||
1333 | /* max queue size */ , | 1335 | /* max queue size */ , |
1334 | GNUNET_TIME_UNIT_FOREVER_REL, | 1336 | GNUNET_TIME_UNIT_FOREVER_REL, |
1335 | &process_local_reply, pr); | 1337 | &process_local_reply, pr); |
@@ -1353,21 +1355,24 @@ check_error_and_continue: | |||
1353 | 1355 | ||
1354 | /** | 1356 | /** |
1355 | * Is the given target a legitimate peer for forwarding the given request? | 1357 | * Is the given target a legitimate peer for forwarding the given request? |
1356 | * | 1358 | * |
1357 | * @param pr request | 1359 | * @param pr request |
1358 | * @param target | 1360 | * @param target |
1359 | * @return GNUNET_YES if this request could be forwarded to the given peer | 1361 | * @return GNUNET_YES if this request could be forwarded to the given peer |
1360 | */ | 1362 | */ |
1361 | int | 1363 | int |
1362 | GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, | 1364 | GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, |
1363 | const struct GNUNET_PeerIdentity *target) | 1365 | const struct GNUNET_PeerIdentity *target) |
1364 | { | 1366 | { |
1365 | struct GNUNET_PeerIdentity pi; | 1367 | struct GNUNET_PeerIdentity pi; |
1366 | 1368 | ||
1367 | if (0 == pr->origin_pid) | 1369 | if (0 == pr->origin_pid) |
1368 | return GNUNET_YES; | 1370 | return GNUNET_YES; |
1369 | GNUNET_PEER_resolve (pr->origin_pid, &pi); | 1371 | GNUNET_PEER_resolve (pr->origin_pid, &pi); |
1370 | return (0 == memcmp (&pi, target, sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :GNUNET_YES; | 1372 | return (0 == |
1373 | memcmp (&pi, target, | ||
1374 | sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO : | ||
1375 | GNUNET_YES; | ||
1371 | } | 1376 | } |
1372 | 1377 | ||
1373 | 1378 | ||
@@ -1405,16 +1410,17 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr, | |||
1405 | /* queue priority */ , | 1410 | /* queue priority */ , |
1406 | (0 != | 1411 | (0 != |
1407 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | 1412 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> |
1408 | public_data.options)) ? UINT_MAX : datastore_queue_size | 1413 | public_data.options)) ? UINT_MAX : |
1414 | datastore_queue_size | ||
1409 | /* max queue size */ , | 1415 | /* max queue size */ , |
1410 | GNUNET_TIME_UNIT_FOREVER_REL, | 1416 | GNUNET_TIME_UNIT_FOREVER_REL, |
1411 | &process_local_reply, pr); | 1417 | &process_local_reply, pr); |
1412 | if (NULL != pr->qe) | 1418 | if (NULL != pr->qe) |
1413 | return; | 1419 | return; |
1414 | GNUNET_STATISTICS_update (GSF_stats, | 1420 | GNUNET_STATISTICS_update (GSF_stats, |
1415 | gettext_noop | 1421 | gettext_noop |
1416 | ("# Datastore lookups concluded (error queueing)"), | 1422 | ("# Datastore lookups concluded (error queueing)"), |
1417 | 1, GNUNET_NO); | 1423 | 1, GNUNET_NO); |
1418 | GNUNET_SCHEDULER_cancel (pr->warn_task); | 1424 | GNUNET_SCHEDULER_cancel (pr->warn_task); |
1419 | pr->warn_task = GNUNET_SCHEDULER_NO_TASK; | 1425 | pr->warn_task = GNUNET_SCHEDULER_NO_TASK; |
1420 | pr->llc_cont = NULL; | 1426 | pr->llc_cont = NULL; |
@@ -1566,10 +1572,8 @@ GSF_pending_request_init_ () | |||
1566 | "MAX_PENDING_REQUESTS"); | 1572 | "MAX_PENDING_REQUESTS"); |
1567 | } | 1573 | } |
1568 | if (GNUNET_OK != | 1574 | if (GNUNET_OK != |
1569 | GNUNET_CONFIGURATION_get_value_number (GSF_cfg, | 1575 | GNUNET_CONFIGURATION_get_value_number (GSF_cfg, "core", "TOTAL_QUOTA_OUT", |
1570 | "core", | 1576 | &bps)) |
1571 | "TOTAL_QUOTA_OUT", | ||
1572 | &bps)) | ||
1573 | { | 1577 | { |
1574 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1578 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1575 | _ | 1579 | _ |
@@ -1578,9 +1582,10 @@ GSF_pending_request_init_ () | |||
1578 | bps = 65536; | 1582 | bps = 65536; |
1579 | } | 1583 | } |
1580 | /* queue size should be #queries we can have pending and satisfy within | 1584 | /* queue size should be #queries we can have pending and satisfy within |
1581 | a carry interval: */ | 1585 | * a carry interval: */ |
1582 | datastore_queue_size = bps * GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S / DBLOCK_SIZE; | 1586 | datastore_queue_size = |
1583 | 1587 | bps * GNUNET_CONSTANTS_MAX_BANDWIDTH_CARRY_S / DBLOCK_SIZE; | |
1588 | |||
1584 | active_to_migration = | 1589 | active_to_migration = |
1585 | GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING"); | 1590 | GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, "FS", "CONTENT_CACHING"); |
1586 | datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); | 1591 | datastore_put_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); |
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h index 538a38248..00249afcf 100644 --- a/src/fs/gnunet-service-fs_pr.h +++ b/src/fs/gnunet-service-fs_pr.h | |||
@@ -359,14 +359,14 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr, | |||
359 | 359 | ||
360 | /** | 360 | /** |
361 | * Is the given target a legitimate peer for forwarding the given request? | 361 | * Is the given target a legitimate peer for forwarding the given request? |
362 | * | 362 | * |
363 | * @param pr request | 363 | * @param pr request |
364 | * @param target | 364 | * @param target |
365 | * @return GNUNET_YES if this request could be forwarded to the given peer | 365 | * @return GNUNET_YES if this request could be forwarded to the given peer |
366 | */ | 366 | */ |
367 | int | 367 | int |
368 | GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, | 368 | GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr, |
369 | const struct GNUNET_PeerIdentity *target); | 369 | const struct GNUNET_PeerIdentity *target); |
370 | 370 | ||
371 | 371 | ||
372 | 372 | ||
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index c029b4141..07d32ef31 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.c | |||
@@ -161,9 +161,9 @@ process_dht_put_content (void *cls, const GNUNET_HashCode * key, size_t size, | |||
161 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), | 161 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), |
162 | type); | 162 | type); |
163 | #endif | 163 | #endif |
164 | GNUNET_DHT_put (GSF_dht, key, 5 /* DEFAULT_PUT_REPLICATION */, | 164 | GNUNET_DHT_put (GSF_dht, key, 5 /* DEFAULT_PUT_REPLICATION */ , |
165 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 165 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, type, size, data, |
166 | type, size, data, expiration, GNUNET_TIME_UNIT_FOREVER_REL, | 166 | expiration, GNUNET_TIME_UNIT_FOREVER_REL, |
167 | &delay_dht_put_blocks, po); | 167 | &delay_dht_put_blocks, po); |
168 | } | 168 | } |
169 | 169 | ||