diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-09 21:38:59 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-09 21:39:08 +0100 |
commit | 6037291cd4f4ead8719325632b7e00e163a59cb9 (patch) | |
tree | cf648cf9a9041d748c6ba1356a3ffcc5731fb5a1 | |
parent | 20906d422b2918e8afe7bb624bd843ae8bb54c98 (diff) | |
download | gnunet-6037291cd4f4ead8719325632b7e00e163a59cb9.tar.gz gnunet-6037291cd4f4ead8719325632b7e00e163a59cb9.zip |
fix #4608
-rw-r--r-- | src/fs/fs_search.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index e31115f39..af0b551ef 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -1088,15 +1088,17 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1088 | unsigned int left; | 1088 | unsigned int left; |
1089 | unsigned int todo; | 1089 | unsigned int todo; |
1090 | unsigned int fit; | 1090 | unsigned int fit; |
1091 | int first_call; | ||
1092 | unsigned int search_request_map_offset; | 1091 | unsigned int search_request_map_offset; |
1093 | unsigned int keyword_offset; | 1092 | unsigned int keyword_offset; |
1093 | int first_call; | ||
1094 | 1094 | ||
1095 | memset (&mbc, 0, sizeof (mbc)); | 1095 | memset (&mbc, 0, sizeof (mbc)); |
1096 | mbc.sc = sc; | 1096 | mbc.sc = sc; |
1097 | if (GNUNET_FS_uri_test_ksk (sc->uri)) | 1097 | if (GNUNET_FS_uri_test_ksk (sc->uri)) |
1098 | { | 1098 | { |
1099 | mbc.put_cnt = 0; | 1099 | /* This will calculate the result set size ONLY for |
1100 | "keyword_offset == 0", so we will have to recalculate | ||
1101 | it for the other keywords later! */ | ||
1100 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | 1102 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, |
1101 | &find_result_set, | 1103 | &find_result_set, |
1102 | &mbc); | 1104 | &mbc); |
@@ -1109,7 +1111,6 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1109 | } | 1111 | } |
1110 | search_request_map_offset = 0; | 1112 | search_request_map_offset = 0; |
1111 | keyword_offset = 0; | 1113 | keyword_offset = 0; |
1112 | |||
1113 | first_call = GNUNET_YES; | 1114 | first_call = GNUNET_YES; |
1114 | while ( (0 != (left = | 1115 | while ( (0 != (left = |
1115 | (total_seen_results - search_request_map_offset))) || | 1116 | (total_seen_results - search_request_map_offset))) || |
@@ -1128,6 +1129,11 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1128 | GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 1129 | GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
1129 | mbc.skip_cnt = search_request_map_offset; | 1130 | mbc.skip_cnt = search_request_map_offset; |
1130 | mbc.xoff = (struct GNUNET_HashCode *) &sm[1]; | 1131 | mbc.xoff = (struct GNUNET_HashCode *) &sm[1]; |
1132 | sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK); | ||
1133 | sm->anonymity_level = htonl (sc->anonymity); | ||
1134 | memset (&sm->target, | ||
1135 | 0, | ||
1136 | sizeof (struct GNUNET_PeerIdentity)); | ||
1131 | 1137 | ||
1132 | if (GNUNET_FS_uri_test_ksk (sc->uri)) | 1138 | if (GNUNET_FS_uri_test_ksk (sc->uri)) |
1133 | { | 1139 | { |
@@ -1135,17 +1141,12 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1135 | /* calculate how many results we can send in this message */ | 1141 | /* calculate how many results we can send in this message */ |
1136 | mbc.put_cnt = todo; | 1142 | mbc.put_cnt = todo; |
1137 | /* now build message */ | 1143 | /* now build message */ |
1138 | sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK); | ||
1139 | sm->anonymity_level = htonl (sc->anonymity); | ||
1140 | memset (&sm->target, | ||
1141 | 0, | ||
1142 | sizeof (struct GNUNET_PeerIdentity)); | ||
1143 | sm->query = sc->requests[keyword_offset].uquery; | 1144 | sm->query = sc->requests[keyword_offset].uquery; |
1144 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | 1145 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, |
1145 | &build_result_set, | 1146 | &build_result_set, |
1146 | &mbc); | 1147 | &mbc); |
1147 | search_request_map_offset += todo; | 1148 | search_request_map_offset += todo; |
1148 | GNUNET_assert (0 == mbc.put_cnt); /* #4608 reports this fails? */ | 1149 | GNUNET_assert (0 == mbc.put_cnt); |
1149 | GNUNET_assert (total_seen_results >= search_request_map_offset); | 1150 | GNUNET_assert (total_seen_results >= search_request_map_offset); |
1150 | if (total_seen_results != search_request_map_offset) | 1151 | if (total_seen_results != search_request_map_offset) |
1151 | { | 1152 | { |
@@ -1156,11 +1157,17 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1156 | { | 1157 | { |
1157 | sm->options = htonl (options); | 1158 | sm->options = htonl (options); |
1158 | keyword_offset++; | 1159 | keyword_offset++; |
1159 | search_request_map_offset = 0; | ||
1160 | if (sc->uri->data.ksk.keywordCount != keyword_offset) | 1160 | if (sc->uri->data.ksk.keywordCount != keyword_offset) |
1161 | { | 1161 | { |
1162 | /* more keywords => more requesting to be done... */ | 1162 | /* more keywords => more requesting to be done... */ |
1163 | first_call = GNUNET_YES; | 1163 | first_call = GNUNET_YES; |
1164 | search_request_map_offset = 0; | ||
1165 | mbc.put_cnt = 0; | ||
1166 | mbc.keyword_offset = keyword_offset; | ||
1167 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | ||
1168 | &find_result_set, | ||
1169 | &mbc); | ||
1170 | total_seen_results = mbc.put_cnt; | ||
1164 | } | 1171 | } |
1165 | } | 1172 | } |
1166 | } | 1173 | } |
@@ -1168,11 +1175,6 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1168 | { | 1175 | { |
1169 | GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri)); | 1176 | GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri)); |
1170 | 1177 | ||
1171 | sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK); | ||
1172 | sm->anonymity_level = htonl (sc->anonymity); | ||
1173 | memset (&sm->target, | ||
1174 | 0, | ||
1175 | sizeof (struct GNUNET_PeerIdentity)); | ||
1176 | GNUNET_CRYPTO_ecdsa_public_key_derive (&sc->uri->data.sks.ns, | 1178 | GNUNET_CRYPTO_ecdsa_public_key_derive (&sc->uri->data.sks.ns, |
1177 | sc->uri->data.sks.identifier, | 1179 | sc->uri->data.sks.identifier, |
1178 | "fs-ublock", | 1180 | "fs-ublock", |