diff options
author | tg(x) <*@tg-x.net> | 2017-03-22 10:08:01 +0100 |
---|---|---|
committer | tg(x) <*@tg-x.net> | 2017-03-22 10:08:01 +0100 |
commit | aa98f144e6db0da5a0a4cad83fe64a80bbab6692 (patch) | |
tree | 5a072b4e1b689bf4330b2a412bdadc705d33ff75 /src/fs | |
parent | caeeec6cacaa5354883494cb64b0a38e5c75da5d (diff) | |
parent | b424335cc632a11bd76bad5791cef10e8c985720 (diff) | |
download | gnunet-aa98f144e6db0da5a0a4cad83fe64a80bbab6692.tar.gz gnunet-aa98f144e6db0da5a0a4cad83fe64a80bbab6692.zip |
Merge branch 'master' of gnunet.org:gnunet
Diffstat (limited to 'src/fs')
28 files changed, 758 insertions, 615 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 4374d45ea..33260a794 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -202,7 +202,7 @@ gnunet_service_fs_LDADD = \ | |||
202 | $(top_builddir)/src/block/libgnunetblock.la \ | 202 | $(top_builddir)/src/block/libgnunetblock.la \ |
203 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 203 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
204 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 204 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
205 | $(top_builddir)/src/cadet/libgnunetcadetnew.la \ | 205 | $(top_builddir)/src/cadet/libgnunetcadet.la \ |
206 | $(top_builddir)/src/ats/libgnunetats.la \ | 206 | $(top_builddir)/src/ats/libgnunetats.la \ |
207 | $(top_builddir)/src/core/libgnunetcore.la \ | 207 | $(top_builddir)/src/core/libgnunetcore.la \ |
208 | $(top_builddir)/src/util/libgnunetutil.la \ | 208 | $(top_builddir)/src/util/libgnunetutil.la \ |
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h index e85de94a7..be22ea73e 100644 --- a/src/fs/fs_api.h +++ b/src/fs/fs_api.h | |||
@@ -1464,21 +1464,11 @@ struct GNUNET_FS_UnindexContext | |||
1464 | struct GNUNET_CRYPTO_FileHashContext *fhc; | 1464 | struct GNUNET_CRYPTO_FileHashContext *fhc; |
1465 | 1465 | ||
1466 | /** | 1466 | /** |
1467 | * Which values have we seen already? | ||
1468 | */ | ||
1469 | struct GNUNET_CONTAINER_MultiHashMap *seen_dh; | ||
1470 | |||
1471 | /** | ||
1472 | * Overall size of the file. | 1467 | * Overall size of the file. |
1473 | */ | 1468 | */ |
1474 | uint64_t file_size; | 1469 | uint64_t file_size; |
1475 | 1470 | ||
1476 | /** | 1471 | /** |
1477 | * Random offset given to #GNUNET_DATASTORE_get_key. | ||
1478 | */ | ||
1479 | uint64_t roff; | ||
1480 | |||
1481 | /** | ||
1482 | * When did we start? | 1472 | * When did we start? |
1483 | */ | 1473 | */ |
1484 | struct GNUNET_TIME_Absolute start_time; | 1474 | struct GNUNET_TIME_Absolute start_time; |
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c index a18a903be..514eb64b3 100644 --- a/src/fs/fs_directory.c +++ b/src/fs/fs_directory.c | |||
@@ -170,13 +170,14 @@ find_full_data (void *cls, const char *plugin_name, | |||
170 | * @param data pointer to the beginning of the directory | 170 | * @param data pointer to the beginning of the directory |
171 | * @param offset offset of data in the directory | 171 | * @param offset offset of data in the directory |
172 | * @param dep function to call on each entry | 172 | * @param dep function to call on each entry |
173 | * @param dep_cls closure for dep | 173 | * @param dep_cls closure for @a dep |
174 | * @return GNUNET_OK if this could be a block in a directory, | 174 | * @return #GNUNET_OK if this could be a block in a directory, |
175 | * GNUNET_NO if this could be part of a directory (but not 100% OK) | 175 | * #GNUNET_NO if this could be part of a directory (but not 100% OK) |
176 | * GNUNET_SYSERR if 'data' does not represent a directory | 176 | * #GNUNET_SYSERR if @a data does not represent a directory |
177 | */ | 177 | */ |
178 | int | 178 | int |
179 | GNUNET_FS_directory_list_contents (size_t size, const void *data, | 179 | GNUNET_FS_directory_list_contents (size_t size, |
180 | const void *data, | ||
180 | uint64_t offset, | 181 | uint64_t offset, |
181 | GNUNET_FS_DirectoryEntryProcessor dep, | 182 | GNUNET_FS_DirectoryEntryProcessor dep, |
182 | void *dep_cls) | 183 | void *dep_cls) |
@@ -194,12 +195,16 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data, | |||
194 | 195 | ||
195 | if ((offset == 0) && | 196 | if ((offset == 0) && |
196 | ((size < 8 + sizeof (uint32_t)) || | 197 | ((size < 8 + sizeof (uint32_t)) || |
197 | (0 != memcmp (cdata, GNUNET_FS_DIRECTORY_MAGIC, 8)))) | 198 | (0 != memcmp (cdata, |
199 | GNUNET_FS_DIRECTORY_MAGIC, | ||
200 | 8)))) | ||
198 | return GNUNET_SYSERR; | 201 | return GNUNET_SYSERR; |
199 | pos = offset; | 202 | pos = offset; |
200 | if (offset == 0) | 203 | if (offset == 0) |
201 | { | 204 | { |
202 | GNUNET_memcpy (&mdSize, &cdata[8], sizeof (uint32_t)); | 205 | GNUNET_memcpy (&mdSize, |
206 | &cdata[8], | ||
207 | sizeof (uint32_t)); | ||
203 | mdSize = ntohl (mdSize); | 208 | mdSize = ntohl (mdSize); |
204 | if (mdSize > size - 8 - sizeof (uint32_t)) | 209 | if (mdSize > size - 8 - sizeof (uint32_t)) |
205 | { | 210 | { |
@@ -215,7 +220,12 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data, | |||
215 | GNUNET_break (0); | 220 | GNUNET_break (0); |
216 | return GNUNET_SYSERR; /* malformed ! */ | 221 | return GNUNET_SYSERR; /* malformed ! */ |
217 | } | 222 | } |
218 | dep (dep_cls, NULL, NULL, md, 0, NULL); | 223 | dep (dep_cls, |
224 | NULL, | ||
225 | NULL, | ||
226 | md, | ||
227 | 0, | ||
228 | NULL); | ||
219 | GNUNET_CONTAINER_meta_data_destroy (md); | 229 | GNUNET_CONTAINER_meta_data_destroy (md); |
220 | pos = 8 + sizeof (uint32_t) + mdSize; | 230 | pos = 8 + sizeof (uint32_t) + mdSize; |
221 | } | 231 | } |
@@ -247,7 +257,7 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data, | |||
247 | 257 | ||
248 | uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg); | 258 | uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg); |
249 | pos = epos + 1; | 259 | pos = epos + 1; |
250 | if (uri == NULL) | 260 | if (NULL == uri) |
251 | { | 261 | { |
252 | GNUNET_free (emsg); | 262 | GNUNET_free (emsg); |
253 | pos--; /* go back to '\0' to force going to next alignment */ | 263 | pos--; /* go back to '\0' to force going to next alignment */ |
@@ -260,7 +270,9 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data, | |||
260 | return GNUNET_NO; /* illegal in directory! */ | 270 | return GNUNET_NO; /* illegal in directory! */ |
261 | } | 271 | } |
262 | 272 | ||
263 | GNUNET_memcpy (&mdSize, &cdata[pos], sizeof (uint32_t)); | 273 | GNUNET_memcpy (&mdSize, |
274 | &cdata[pos], | ||
275 | sizeof (uint32_t)); | ||
264 | mdSize = ntohl (mdSize); | 276 | mdSize = ntohl (mdSize); |
265 | pos += sizeof (uint32_t); | 277 | pos += sizeof (uint32_t); |
266 | if (pos + mdSize > size) | 278 | if (pos + mdSize > size) |
@@ -269,8 +281,9 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data, | |||
269 | return GNUNET_NO; /* malformed - or partial download */ | 281 | return GNUNET_NO; /* malformed - or partial download */ |
270 | } | 282 | } |
271 | 283 | ||
272 | md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos], mdSize); | 284 | md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos], |
273 | if (md == NULL) | 285 | mdSize); |
286 | if (NULL == md) | ||
274 | { | 287 | { |
275 | GNUNET_FS_uri_destroy (uri); | 288 | GNUNET_FS_uri_destroy (uri); |
276 | GNUNET_break (0); | 289 | GNUNET_break (0); |
@@ -282,10 +295,17 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data, | |||
282 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); | 295 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); |
283 | full_data.size = 0; | 296 | full_data.size = 0; |
284 | full_data.data = NULL; | 297 | full_data.data = NULL; |
285 | GNUNET_CONTAINER_meta_data_iterate (md, &find_full_data, &full_data); | 298 | GNUNET_CONTAINER_meta_data_iterate (md, |
286 | if (dep != NULL) | 299 | &find_full_data, |
300 | &full_data); | ||
301 | if (NULL != dep) | ||
287 | { | 302 | { |
288 | dep (dep_cls, filename, uri, md, full_data.size, full_data.data); | 303 | dep (dep_cls, |
304 | filename, | ||
305 | uri, | ||
306 | md, | ||
307 | full_data.size, | ||
308 | full_data.data); | ||
289 | } | 309 | } |
290 | GNUNET_free_non_null (full_data.data); | 310 | GNUNET_free_non_null (full_data.data); |
291 | GNUNET_free_non_null (filename); | 311 | GNUNET_free_non_null (filename); |
@@ -548,11 +568,12 @@ block_align (size_t start, unsigned int count, const size_t * sizes, | |||
548 | * @param bld directory to finish | 568 | * @param bld directory to finish |
549 | * @param rsize set to the number of bytes needed | 569 | * @param rsize set to the number of bytes needed |
550 | * @param rdata set to the encoded directory | 570 | * @param rdata set to the encoded directory |
551 | * @return GNUNET_OK on success | 571 | * @return #GNUNET_OK on success |
552 | */ | 572 | */ |
553 | int | 573 | int |
554 | GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, | 574 | GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, |
555 | size_t * rsize, void **rdata) | 575 | size_t * rsize, |
576 | void **rdata) | ||
556 | { | 577 | { |
557 | char *data; | 578 | char *data; |
558 | char *sptr; | 579 | char *sptr; |
@@ -575,9 +596,12 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, | |||
575 | bes = NULL; | 596 | bes = NULL; |
576 | if (0 < bld->count) | 597 | if (0 < bld->count) |
577 | { | 598 | { |
578 | sizes = GNUNET_malloc (bld->count * sizeof (size_t)); | 599 | sizes = GNUNET_new_array (bld->count, |
579 | perm = GNUNET_malloc (bld->count * sizeof (unsigned int)); | 600 | size_t); |
580 | bes = GNUNET_malloc (bld->count * sizeof (struct BuilderEntry *)); | 601 | perm = GNUNET_new_array (bld->count, |
602 | unsigned int); | ||
603 | bes = GNUNET_new_array (bld->count, | ||
604 | struct BuilderEntry *); | ||
581 | pos = bld->head; | 605 | pos = bld->head; |
582 | for (i = 0; i < bld->count; i++) | 606 | for (i = 0; i < bld->count; i++) |
583 | { | 607 | { |
@@ -599,7 +623,8 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, | |||
599 | data = GNUNET_malloc_large (size); | 623 | data = GNUNET_malloc_large (size); |
600 | if (data == NULL) | 624 | if (data == NULL) |
601 | { | 625 | { |
602 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "malloc"); | 626 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
627 | "malloc"); | ||
603 | *rsize = 0; | 628 | *rsize = 0; |
604 | *rdata = NULL; | 629 | *rdata = NULL; |
605 | GNUNET_free_non_null (sizes); | 630 | GNUNET_free_non_null (sizes); |
@@ -608,17 +633,22 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, | |||
608 | return GNUNET_SYSERR; | 633 | return GNUNET_SYSERR; |
609 | } | 634 | } |
610 | *rdata = data; | 635 | *rdata = data; |
611 | GNUNET_memcpy (data, GNUNET_DIRECTORY_MAGIC, strlen (GNUNET_DIRECTORY_MAGIC)); | 636 | GNUNET_memcpy (data, |
637 | GNUNET_DIRECTORY_MAGIC, | ||
638 | strlen (GNUNET_DIRECTORY_MAGIC)); | ||
612 | off = strlen (GNUNET_DIRECTORY_MAGIC); | 639 | off = strlen (GNUNET_DIRECTORY_MAGIC); |
613 | 640 | ||
614 | sptr = &data[off + sizeof (uint32_t)]; | 641 | sptr = &data[off + sizeof (uint32_t)]; |
615 | ret = | 642 | ret = |
616 | GNUNET_CONTAINER_meta_data_serialize (bld->meta, &sptr, | 643 | GNUNET_CONTAINER_meta_data_serialize (bld->meta, |
644 | &sptr, | ||
617 | size - off - sizeof (uint32_t), | 645 | size - off - sizeof (uint32_t), |
618 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); | 646 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); |
619 | GNUNET_assert (ret != -1); | 647 | GNUNET_assert (ret != -1); |
620 | big = htonl (ret); | 648 | big = htonl (ret); |
621 | GNUNET_memcpy (&data[off], &big, sizeof (uint32_t)); | 649 | GNUNET_memcpy (&data[off], |
650 | &big, | ||
651 | sizeof (uint32_t)); | ||
622 | off += sizeof (uint32_t) + ret; | 652 | off += sizeof (uint32_t) + ret; |
623 | for (j = 0; j < bld->count; j++) | 653 | for (j = 0; j < bld->count; j++) |
624 | { | 654 | { |
diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c index 2f79c7c05..7b9f178fd 100644 --- a/src/fs/fs_dirmetascan.c +++ b/src/fs/fs_dirmetascan.c | |||
@@ -245,12 +245,10 @@ finish_scan (void *cls) | |||
245 | * Calls the scanner progress handler. | 245 | * Calls the scanner progress handler. |
246 | * | 246 | * |
247 | * @param cls the closure (directory scanner object) | 247 | * @param cls the closure (directory scanner object) |
248 | * @param client always NULL | ||
249 | * @param msg message from the helper process | 248 | * @param msg message from the helper process |
250 | */ | 249 | */ |
251 | static int | 250 | static int |
252 | process_helper_msgs (void *cls, | 251 | process_helper_msgs (void *cls, |
253 | void *client, | ||
254 | const struct GNUNET_MessageHeader *msg) | 252 | const struct GNUNET_MessageHeader *msg) |
255 | { | 253 | { |
256 | struct GNUNET_FS_DirScanner *ds = cls; | 254 | struct GNUNET_FS_DirScanner *ds = cls; |
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index 0789162bf..ce852f2d0 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -37,14 +37,14 @@ static int | |||
37 | is_recursive_download (struct GNUNET_FS_DownloadContext *dc) | 37 | is_recursive_download (struct GNUNET_FS_DownloadContext *dc) |
38 | { | 38 | { |
39 | return (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE)) && | 39 | return (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE)) && |
40 | ((GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (dc->meta)) || | 40 | ( (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (dc->meta)) || |
41 | ((NULL == dc->meta) && | 41 | ( (NULL == dc->meta) && |
42 | ((NULL == dc->filename) || | 42 | ( (NULL == dc->filename) || |
43 | ((strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) && | 43 | ( (strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) && |
44 | (NULL != | 44 | (NULL != |
45 | strstr (dc->filename + strlen (dc->filename) - | 45 | strstr (dc->filename + strlen (dc->filename) - |
46 | strlen (GNUNET_FS_DIRECTORY_EXT), | 46 | strlen (GNUNET_FS_DIRECTORY_EXT), |
47 | GNUNET_FS_DIRECTORY_EXT)))))); | 47 | GNUNET_FS_DIRECTORY_EXT)) ) ) ) ); |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
@@ -278,10 +278,12 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc); | |||
278 | * @param data contents of the file (or NULL if they were not inlined) | 278 | * @param data contents of the file (or NULL if they were not inlined) |
279 | */ | 279 | */ |
280 | static void | 280 | static void |
281 | trigger_recursive_download (void *cls, const char *filename, | 281 | trigger_recursive_download (void *cls, |
282 | const char *filename, | ||
282 | const struct GNUNET_FS_Uri *uri, | 283 | const struct GNUNET_FS_Uri *uri, |
283 | const struct GNUNET_CONTAINER_MetaData *meta, | 284 | const struct GNUNET_CONTAINER_MetaData *meta, |
284 | size_t length, const void *data); | 285 | size_t length, |
286 | const void *data); | ||
285 | 287 | ||
286 | 288 | ||
287 | /** | 289 | /** |
@@ -304,24 +306,28 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc) | |||
304 | if (size64 != (uint64_t) size) | 306 | if (size64 != (uint64_t) size) |
305 | { | 307 | { |
306 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 308 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
307 | _ | 309 | _("Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n")); |
308 | ("Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n")); | ||
309 | return; | 310 | return; |
310 | } | 311 | } |
311 | if (NULL != dc->filename) | 312 | if (NULL != dc->filename) |
312 | { | 313 | { |
313 | h = GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ, | 314 | h = GNUNET_DISK_file_open (dc->filename, |
315 | GNUNET_DISK_OPEN_READ, | ||
314 | GNUNET_DISK_PERM_NONE); | 316 | GNUNET_DISK_PERM_NONE); |
315 | } | 317 | } |
316 | else | 318 | else |
317 | { | 319 | { |
318 | GNUNET_assert (NULL != dc->temp_filename); | 320 | GNUNET_assert (NULL != dc->temp_filename); |
319 | h = GNUNET_DISK_file_open (dc->temp_filename, GNUNET_DISK_OPEN_READ, | 321 | h = GNUNET_DISK_file_open (dc->temp_filename, |
322 | GNUNET_DISK_OPEN_READ, | ||
320 | GNUNET_DISK_PERM_NONE); | 323 | GNUNET_DISK_PERM_NONE); |
321 | } | 324 | } |
322 | if (NULL == h) | 325 | if (NULL == h) |
323 | return; /* oops */ | 326 | return; /* oops */ |
324 | data = GNUNET_DISK_file_map (h, &m, GNUNET_DISK_MAP_TYPE_READ, size); | 327 | data = GNUNET_DISK_file_map (h, |
328 | &m, | ||
329 | GNUNET_DISK_MAP_TYPE_READ, | ||
330 | size); | ||
325 | if (NULL == data) | 331 | if (NULL == data) |
326 | { | 332 | { |
327 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 333 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -329,15 +335,25 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc) | |||
329 | } | 335 | } |
330 | else | 336 | else |
331 | { | 337 | { |
332 | GNUNET_FS_directory_list_contents (size, data, 0, | 338 | if (GNUNET_OK != |
333 | &trigger_recursive_download, dc); | 339 | GNUNET_FS_directory_list_contents (size, |
340 | data, | ||
341 | 0, | ||
342 | &trigger_recursive_download, | ||
343 | dc)) | ||
344 | { | ||
345 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
346 | _("Failed to access full directroy contents of `%s' for recursive download\n"), | ||
347 | dc->filename); | ||
348 | } | ||
334 | GNUNET_DISK_file_unmap (m); | 349 | GNUNET_DISK_file_unmap (m); |
335 | } | 350 | } |
336 | GNUNET_DISK_file_close (h); | 351 | GNUNET_DISK_file_close (h); |
337 | if (NULL == dc->filename) | 352 | if (NULL == dc->filename) |
338 | { | 353 | { |
339 | if (0 != UNLINK (dc->temp_filename)) | 354 | if (0 != UNLINK (dc->temp_filename)) |
340 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", | 355 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, |
356 | "unlink", | ||
341 | dc->temp_filename); | 357 | dc->temp_filename); |
342 | GNUNET_free (dc->temp_filename); | 358 | GNUNET_free (dc->temp_filename); |
343 | dc->temp_filename = NULL; | 359 | dc->temp_filename = NULL; |
@@ -362,14 +378,16 @@ check_completed (struct GNUNET_FS_DownloadContext *dc) | |||
362 | struct GNUNET_FS_DownloadContext *pos; | 378 | struct GNUNET_FS_DownloadContext *pos; |
363 | 379 | ||
364 | /* first, check if we need to download children */ | 380 | /* first, check if we need to download children */ |
365 | if ((NULL == dc->child_head) && (is_recursive_download (dc))) | 381 | if (is_recursive_download (dc)) |
366 | full_recursive_download (dc); | 382 | full_recursive_download (dc); |
367 | /* then, check if children are done already */ | 383 | /* then, check if children are done already */ |
368 | for (pos = dc->child_head; NULL != pos; pos = pos->next) | 384 | for (pos = dc->child_head; NULL != pos; pos = pos->next) |
369 | { | 385 | { |
370 | if ((pos->emsg == NULL) && (pos->completed < pos->length)) | 386 | if ( (NULL == pos->emsg) && |
387 | (pos->completed < pos->length) ) | ||
371 | return; /* not done yet */ | 388 | return; /* not done yet */ |
372 | if ((pos->child_head != NULL) && (pos->has_finished != GNUNET_YES)) | 389 | if ( (NULL != pos->child_head) && |
390 | (pos->has_finished != GNUNET_YES) ) | ||
373 | return; /* not transitively done yet */ | 391 | return; /* not transitively done yet */ |
374 | } | 392 | } |
375 | /* All of our children are done, so mark this download done */ | 393 | /* All of our children are done, so mark this download done */ |
@@ -471,7 +489,11 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc, | |||
471 | } | 489 | } |
472 | GNUNET_CRYPTO_hash (&data[dr->offset], dlen, &in_chk.key); | 490 | GNUNET_CRYPTO_hash (&data[dr->offset], dlen, &in_chk.key); |
473 | GNUNET_CRYPTO_hash_to_aes_key (&in_chk.key, &sk, &iv); | 491 | GNUNET_CRYPTO_hash_to_aes_key (&in_chk.key, &sk, &iv); |
474 | if (-1 == GNUNET_CRYPTO_symmetric_encrypt (&data[dr->offset], dlen, &sk, &iv, enc)) | 492 | if (-1 == GNUNET_CRYPTO_symmetric_encrypt (&data[dr->offset], |
493 | dlen, | ||
494 | &sk, | ||
495 | &iv, | ||
496 | enc)) | ||
475 | { | 497 | { |
476 | GNUNET_break (0); | 498 | GNUNET_break (0); |
477 | return; | 499 | return; |
@@ -484,7 +506,9 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc, | |||
484 | dr->state = BRS_RECONSTRUCT_META_UP; | 506 | dr->state = BRS_RECONSTRUCT_META_UP; |
485 | break; | 507 | break; |
486 | case BRS_CHK_SET: | 508 | case BRS_CHK_SET: |
487 | if (0 != memcmp (&in_chk, &dr->chk, sizeof (struct ContentHashKey))) | 509 | if (0 != memcmp (&in_chk, |
510 | &dr->chk, | ||
511 | sizeof (struct ContentHashKey))) | ||
488 | { | 512 | { |
489 | /* other peer provided bogus meta data */ | 513 | /* other peer provided bogus meta data */ |
490 | GNUNET_break_op (0); | 514 | GNUNET_break_op (0); |
@@ -591,7 +615,10 @@ match_full_data (void *cls, const char *plugin_name, | |||
591 | GNUNET_break_op (0); | 615 | GNUNET_break_op (0); |
592 | return 1; /* bogus meta data */ | 616 | return 1; /* bogus meta data */ |
593 | } | 617 | } |
594 | try_match_block (dc, dc->top_request, data, data_len); | 618 | try_match_block (dc, |
619 | dc->top_request, | ||
620 | data, | ||
621 | data_len); | ||
595 | return 1; | 622 | return 1; |
596 | } | 623 | } |
597 | 624 | ||
@@ -820,10 +847,12 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc, | |||
820 | * @param data contents of the file (or NULL if they were not inlined) | 847 | * @param data contents of the file (or NULL if they were not inlined) |
821 | */ | 848 | */ |
822 | static void | 849 | static void |
823 | trigger_recursive_download (void *cls, const char *filename, | 850 | trigger_recursive_download (void *cls, |
851 | const char *filename, | ||
824 | const struct GNUNET_FS_Uri *uri, | 852 | const struct GNUNET_FS_Uri *uri, |
825 | const struct GNUNET_CONTAINER_MetaData *meta, | 853 | const struct GNUNET_CONTAINER_MetaData *meta, |
826 | size_t length, const void *data) | 854 | size_t length, |
855 | const void *data) | ||
827 | { | 856 | { |
828 | struct GNUNET_FS_DownloadContext *dc = cls; | 857 | struct GNUNET_FS_DownloadContext *dc = cls; |
829 | struct GNUNET_FS_DownloadContext *cpos; | 858 | struct GNUNET_FS_DownloadContext *cpos; |
@@ -936,9 +965,17 @@ trigger_recursive_download (void *cls, const char *filename, | |||
936 | (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri), | 965 | (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri), |
937 | (unsigned int) | 966 | (unsigned int) |
938 | GNUNET_CONTAINER_meta_data_get_serialized_size (meta)); | 967 | GNUNET_CONTAINER_meta_data_get_serialized_size (meta)); |
939 | GNUNET_FS_download_start (dc->h, uri, meta, full_name, temp_name, 0, | 968 | GNUNET_FS_download_start (dc->h, |
969 | uri, | ||
970 | meta, | ||
971 | full_name, | ||
972 | temp_name, | ||
973 | 0, | ||
940 | GNUNET_FS_uri_chk_get_file_size (uri), | 974 | GNUNET_FS_uri_chk_get_file_size (uri), |
941 | dc->anonymity, dc->options, NULL, dc); | 975 | dc->anonymity, |
976 | dc->options, | ||
977 | NULL, | ||
978 | dc); | ||
942 | GNUNET_free_non_null (full_name); | 979 | GNUNET_free_non_null (full_name); |
943 | GNUNET_free_non_null (temp_name); | 980 | GNUNET_free_non_null (temp_name); |
944 | GNUNET_free_non_null (fn); | 981 | GNUNET_free_non_null (fn); |
@@ -953,11 +990,9 @@ trigger_recursive_download (void *cls, const char *filename, | |||
953 | void | 990 | void |
954 | GNUNET_FS_free_download_request_ (struct DownloadRequest *dr) | 991 | GNUNET_FS_free_download_request_ (struct DownloadRequest *dr) |
955 | { | 992 | { |
956 | unsigned int i; | ||
957 | |||
958 | if (NULL == dr) | 993 | if (NULL == dr) |
959 | return; | 994 | return; |
960 | for (i = 0; i < dr->num_children; i++) | 995 | for (unsigned int i = 0; i < dr->num_children; i++) |
961 | GNUNET_FS_free_download_request_ (dr->children[i]); | 996 | GNUNET_FS_free_download_request_ (dr->children[i]); |
962 | GNUNET_free_non_null (dr->children); | 997 | GNUNET_free_non_null (dr->children); |
963 | GNUNET_free (dr); | 998 | GNUNET_free (dr); |
@@ -1509,13 +1544,17 @@ create_download_request (struct DownloadRequest *parent, | |||
1509 | GNUNET_assert (dr->num_children > 0); | 1544 | GNUNET_assert (dr->num_children > 0); |
1510 | 1545 | ||
1511 | dr->children = | 1546 | dr->children = |
1512 | GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *)); | 1547 | GNUNET_new_array (dr->num_children, |
1548 | struct DownloadRequest *); | ||
1513 | for (i = 0; i < dr->num_children; i++) | 1549 | for (i = 0; i < dr->num_children; i++) |
1514 | { | 1550 | { |
1515 | dr->children[i] = | 1551 | dr->children[i] = |
1516 | create_download_request (dr, i + head_skip, depth - 1, | 1552 | create_download_request (dr, |
1553 | i + head_skip, | ||
1554 | depth - 1, | ||
1517 | dr_offset + (i + head_skip) * child_block_size, | 1555 | dr_offset + (i + head_skip) * child_block_size, |
1518 | file_start_offset, desired_length); | 1556 | file_start_offset, |
1557 | desired_length); | ||
1519 | } | 1558 | } |
1520 | return dr; | 1559 | return dr; |
1521 | } | 1560 | } |
diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c index f78e311d3..bfe45957e 100644 --- a/src/fs/fs_getopt.c +++ b/src/fs/fs_getopt.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_fs_service.h" | 27 | #include "gnunet_fs_service.h" |
28 | #include "gnunet_getopt_lib.h" | ||
28 | #include "fs_api.h" | 29 | #include "fs_api.h" |
29 | 30 | ||
30 | /* ******************** command-line option parsing API ******************** */ | 31 | /* ******************** command-line option parsing API ******************** */ |
@@ -41,10 +42,10 @@ | |||
41 | * @param value command line argument given | 42 | * @param value command line argument given |
42 | * @return GNUNET_OK on success | 43 | * @return GNUNET_OK on success |
43 | */ | 44 | */ |
44 | int | 45 | static int |
45 | GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | 46 | getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext |
46 | *ctx, void *scls, const char *option, | 47 | *ctx, void *scls, const char *option, |
47 | const char *value) | 48 | const char *value) |
48 | { | 49 | { |
49 | struct GNUNET_FS_Uri **uri = scls; | 50 | struct GNUNET_FS_Uri **uri = scls; |
50 | struct GNUNET_FS_Uri *u = *uri; | 51 | struct GNUNET_FS_Uri *u = *uri; |
@@ -107,6 +108,34 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
107 | return GNUNET_OK; | 108 | return GNUNET_OK; |
108 | } | 109 | } |
109 | 110 | ||
111 | /** | ||
112 | * Allow user to specify keywords. | ||
113 | * | ||
114 | * @param shortName short name of the option | ||
115 | * @param name long name of the option | ||
116 | * @param argumentHelp help text for the option argument | ||
117 | * @param description long help text for the option | ||
118 | * @param[out] topKeywords set to the desired value | ||
119 | */ | ||
120 | struct GNUNET_GETOPT_CommandLineOption | ||
121 | GNUNET_FS_GETOPT_KEYWORDS (char shortName, | ||
122 | const char *name, | ||
123 | const char *argumentHelp, | ||
124 | const char *description, | ||
125 | struct GNUNET_FS_Uri **topKeywords) | ||
126 | { | ||
127 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
128 | .shortName = shortName, | ||
129 | .name = name, | ||
130 | .argumentHelp = argumentHelp, | ||
131 | .description = description, | ||
132 | .require_argument = 1, | ||
133 | .processor = &getopt_set_keywords, | ||
134 | .scls = (void *) topKeywords | ||
135 | }; | ||
136 | |||
137 | return clo; | ||
138 | } | ||
110 | 139 | ||
111 | /** | 140 | /** |
112 | * Command-line option parser function that allows the user to specify | 141 | * Command-line option parser function that allows the user to specify |
@@ -120,11 +149,11 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
120 | * @param value command line argument given | 149 | * @param value command line argument given |
121 | * @return #GNUNET_OK on success | 150 | * @return #GNUNET_OK on success |
122 | */ | 151 | */ |
123 | int | 152 | static int |
124 | GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | 153 | getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, |
125 | void *scls, | 154 | void *scls, |
126 | const char *option, | 155 | const char *option, |
127 | const char *value) | 156 | const char *value) |
128 | { | 157 | { |
129 | struct GNUNET_CONTAINER_MetaData **mm = scls; | 158 | struct GNUNET_CONTAINER_MetaData **mm = scls; |
130 | #if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR | 159 | #if HAVE_EXTRACTOR_H && HAVE_LIBEXTRACTOR |
@@ -200,4 +229,36 @@ GNUNET_FS_getopt_set_metadata (struct GNUNET_GETOPT_CommandLineProcessorContext | |||
200 | return GNUNET_OK; | 229 | return GNUNET_OK; |
201 | } | 230 | } |
202 | 231 | ||
232 | /** | ||
233 | * Allow user to specify metadata. | ||
234 | * | ||
235 | * @param shortName short name of the option | ||
236 | * @param name long name of the option | ||
237 | * @param argumentHelp help text for the option argument | ||
238 | * @param description long help text for the option | ||
239 | * @param[out] metadata set to the desired value | ||
240 | */ | ||
241 | struct GNUNET_GETOPT_CommandLineOption | ||
242 | GNUNET_FS_GETOPT_METADATA (char shortName, | ||
243 | const char *name, | ||
244 | const char *argumentHelp, | ||
245 | const char *description, | ||
246 | struct GNUNET_CONTAINER_MetaData **meta) | ||
247 | { | ||
248 | struct GNUNET_GETOPT_CommandLineOption clo = { | ||
249 | .shortName = shortName, | ||
250 | .name = name, | ||
251 | .argumentHelp = argumentHelp, | ||
252 | .description = description, | ||
253 | .require_argument = 1, | ||
254 | .processor = &getopt_set_metadata, | ||
255 | .scls = (void *) meta | ||
256 | }; | ||
257 | |||
258 | return clo; | ||
259 | } | ||
260 | |||
261 | |||
262 | |||
263 | |||
203 | /* end of fs_getopt.c */ | 264 | /* end of fs_getopt.c */ |
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 86a58a58b..759467ba4 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c | |||
@@ -837,7 +837,7 @@ hash_for_index_cb (void *cls, | |||
837 | GNUNET_assert (fn != NULL); | 837 | GNUNET_assert (fn != NULL); |
838 | slen = strlen (fn) + 1; | 838 | slen = strlen (fn) + 1; |
839 | if (slen >= | 839 | if (slen >= |
840 | GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage)) | 840 | GNUNET_MAX_MESSAGE_SIZE - sizeof (struct IndexStartMessage)) |
841 | { | 841 | { |
842 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 842 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
843 | _ | 843 | _ |
@@ -1226,7 +1226,7 @@ fip_signal_start (void *cls, | |||
1226 | { | 1226 | { |
1227 | kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri); | 1227 | kc = GNUNET_FS_uri_ksk_get_keyword_count (*uri); |
1228 | pc->reserve_entries += kc; | 1228 | pc->reserve_entries += kc; |
1229 | pc->reserve_space += GNUNET_SERVER_MAX_MESSAGE_SIZE * kc; | 1229 | pc->reserve_space += GNUNET_MAX_MESSAGE_SIZE * kc; |
1230 | } | 1230 | } |
1231 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; | 1231 | pi.status = GNUNET_FS_STATUS_PUBLISH_START; |
1232 | *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0); | 1232 | *client_info = GNUNET_FS_publish_make_status_ (&pi, pc, fi, 0); |
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 3cbf2afef..8c6f5edcf 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))) || |
@@ -1120,7 +1121,7 @@ schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc) | |||
1120 | if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY)) | 1121 | if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY)) |
1121 | options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY; | 1122 | options |= SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY; |
1122 | 1123 | ||
1123 | fit = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (*sm)) / sizeof (struct GNUNET_HashCode); | 1124 | fit = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof (*sm)) / sizeof (struct GNUNET_HashCode); |
1124 | todo = GNUNET_MIN (fit, | 1125 | todo = GNUNET_MIN (fit, |
1125 | left); | 1126 | left); |
1126 | env = GNUNET_MQ_msg_extra (sm, | 1127 | env = GNUNET_MQ_msg_extra (sm, |
@@ -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", |
@@ -1383,9 +1385,10 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc) | |||
1383 | GNUNET_assert (0 != sc->uri->data.ksk.keywordCount); | 1385 | GNUNET_assert (0 != sc->uri->data.ksk.keywordCount); |
1384 | anon = GNUNET_CRYPTO_ecdsa_key_get_anonymous (); | 1386 | anon = GNUNET_CRYPTO_ecdsa_key_get_anonymous (); |
1385 | GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub); | 1387 | GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub); |
1386 | sc->requests = | 1388 | sc->requests |
1387 | GNUNET_malloc (sizeof (struct SearchRequestEntry) * | 1389 | = GNUNET_new_array (sc->uri->data.ksk.keywordCount, |
1388 | sc->uri->data.ksk.keywordCount); | 1390 | struct SearchRequestEntry); |
1391 | |||
1389 | for (i = 0; i < sc->uri->data.ksk.keywordCount; i++) | 1392 | for (i = 0; i < sc->uri->data.ksk.keywordCount; i++) |
1390 | { | 1393 | { |
1391 | keyword = &sc->uri->data.ksk.keywords[i][1]; | 1394 | keyword = &sc->uri->data.ksk.keywords[i][1]; |
@@ -1666,8 +1669,8 @@ search_result_stop (void *cls, | |||
1666 | if (NULL != sr->download) | 1669 | if (NULL != sr->download) |
1667 | { | 1670 | { |
1668 | sr->download->search = NULL; | 1671 | sr->download->search = NULL; |
1669 | sr->download->top = | 1672 | sr->download->top |
1670 | GNUNET_FS_make_top (sr->download->h, | 1673 | = GNUNET_FS_make_top (sr->download->h, |
1671 | &GNUNET_FS_download_signal_suspend_, | 1674 | &GNUNET_FS_download_signal_suspend_, |
1672 | sr->download); | 1675 | sr->download); |
1673 | if (NULL != sr->download->serialization) | 1676 | if (NULL != sr->download->serialization) |
@@ -1679,7 +1682,8 @@ search_result_stop (void *cls, | |||
1679 | sr->download->serialization = NULL; | 1682 | sr->download->serialization = NULL; |
1680 | } | 1683 | } |
1681 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT; | 1684 | pi.status = GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT; |
1682 | GNUNET_FS_download_make_status_ (&pi, sr->download); | 1685 | GNUNET_FS_download_make_status_ (&pi, |
1686 | sr->download); | ||
1683 | GNUNET_FS_download_sync_ (sr->download); | 1687 | GNUNET_FS_download_sync_ (sr->download); |
1684 | sr->download = NULL; | 1688 | sr->download = NULL; |
1685 | } | 1689 | } |
@@ -1745,25 +1749,28 @@ GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc) | |||
1745 | if (NULL != sc->top) | 1749 | if (NULL != sc->top) |
1746 | GNUNET_FS_end_top (sc->h, sc->top); | 1750 | GNUNET_FS_end_top (sc->h, sc->top); |
1747 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, | 1751 | GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, |
1748 | &search_result_stop, sc); | 1752 | &search_result_stop, |
1753 | sc); | ||
1749 | if (NULL != sc->psearch_result) | 1754 | if (NULL != sc->psearch_result) |
1750 | sc->psearch_result->update_search = NULL; | 1755 | sc->psearch_result->update_search = NULL; |
1751 | if (NULL != sc->serialization) | 1756 | if (NULL != sc->serialization) |
1752 | { | 1757 | { |
1753 | GNUNET_FS_remove_sync_file_ (sc->h, | 1758 | GNUNET_FS_remove_sync_file_ (sc->h, |
1754 | (sc->psearch_result != | 1759 | (NULL != sc->psearch_result) |
1755 | NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH : | 1760 | ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH |
1756 | GNUNET_FS_SYNC_PATH_MASTER_SEARCH, | 1761 | : GNUNET_FS_SYNC_PATH_MASTER_SEARCH, |
1757 | sc->serialization); | 1762 | sc->serialization); |
1758 | GNUNET_FS_remove_sync_dir_ (sc->h, | 1763 | GNUNET_FS_remove_sync_dir_ (sc->h, |
1759 | (sc->psearch_result != | 1764 | (NULL != sc->psearch_result) |
1760 | NULL) ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH : | 1765 | ? GNUNET_FS_SYNC_PATH_CHILD_SEARCH |
1761 | GNUNET_FS_SYNC_PATH_MASTER_SEARCH, | 1766 | : GNUNET_FS_SYNC_PATH_MASTER_SEARCH, |
1762 | sc->serialization); | 1767 | sc->serialization); |
1763 | GNUNET_free (sc->serialization); | 1768 | GNUNET_free (sc->serialization); |
1764 | } | 1769 | } |
1765 | pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED; | 1770 | pi.status = GNUNET_FS_STATUS_SEARCH_STOPPED; |
1766 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc); | 1771 | sc->client_info = GNUNET_FS_search_make_status_ (&pi, |
1772 | sc->h, | ||
1773 | sc); | ||
1767 | GNUNET_break (NULL == sc->client_info); | 1774 | GNUNET_break (NULL == sc->client_info); |
1768 | if (NULL != sc->task) | 1775 | if (NULL != sc->task) |
1769 | { | 1776 | { |
diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index b3c632203..e57e4e494 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c | |||
@@ -285,9 +285,9 @@ GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size, | |||
285 | te->progress = progress; | 285 | te->progress = progress; |
286 | te->cont = cont; | 286 | te->cont = cont; |
287 | te->chk_tree_depth = GNUNET_FS_compute_depth (size); | 287 | te->chk_tree_depth = GNUNET_FS_compute_depth (size); |
288 | te->chk_tree = | 288 | te->chk_tree |
289 | GNUNET_malloc (te->chk_tree_depth * CHK_PER_INODE * | 289 | = GNUNET_new_array (te->chk_tree_depth * CHK_PER_INODE, |
290 | sizeof (struct ContentHashKey)); | 290 | struct ContentHashKey); |
291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
292 | "Created tree encoder for file with %llu bytes and depth %u\n", | 292 | "Created tree encoder for file with %llu bytes and depth %u\n", |
293 | (unsigned long long) size, | 293 | (unsigned long long) size, |
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index a672b84d5..e1c7ea535 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c | |||
@@ -312,8 +312,6 @@ unindex_finish (struct GNUNET_FS_UnindexContext *uc) | |||
312 | uc->fh = NULL; | 312 | uc->fh = NULL; |
313 | GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); | 313 | GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO); |
314 | uc->dsh = NULL; | 314 | uc->dsh = NULL; |
315 | GNUNET_CONTAINER_multihashmap_destroy (uc->seen_dh); | ||
316 | uc->seen_dh = NULL; | ||
317 | uc->state = UNINDEX_STATE_FS_NOTIFY; | 315 | uc->state = UNINDEX_STATE_FS_NOTIFY; |
318 | GNUNET_FS_unindex_sync_ (uc); | 316 | GNUNET_FS_unindex_sync_ (uc); |
319 | uc->mq = GNUNET_CLIENT_connect (uc->h->cfg, | 317 | uc->mq = GNUNET_CLIENT_connect (uc->h->cfg, |
@@ -444,7 +442,6 @@ continue_after_remove (void *cls, | |||
444 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 442 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
445 | _("Failed to remove UBlock: %s\n"), | 443 | _("Failed to remove UBlock: %s\n"), |
446 | msg); | 444 | msg); |
447 | GNUNET_CONTAINER_multihashmap_clear (uc->seen_dh); | ||
448 | uc->ksk_offset++; | 445 | uc->ksk_offset++; |
449 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); | 446 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); |
450 | } | 447 | } |
@@ -454,7 +451,8 @@ continue_after_remove (void *cls, | |||
454 | * Function called from datastore with result from us looking for | 451 | * Function called from datastore with result from us looking for |
455 | * a UBlock. There are four cases: | 452 | * a UBlock. There are four cases: |
456 | * 1) no result, means we move on to the next keyword | 453 | * 1) no result, means we move on to the next keyword |
457 | * 2) UID is the same as the first UID, means we move on to next keyword | 454 | * 2) data hash is the same as an already seen data hash, means we move on to |
455 | * next keyword | ||
458 | * 3) UBlock for a different CHK, means we keep looking for more | 456 | * 3) UBlock for a different CHK, means we keep looking for more |
459 | * 4) UBlock is for our CHK, means we remove the block and then move | 457 | * 4) UBlock is for our CHK, means we remove the block and then move |
460 | * on to the next keyword | 458 | * on to the next keyword |
@@ -485,34 +483,15 @@ process_kblock_for_unindex (void *cls, | |||
485 | const struct UBlock *ub; | 483 | const struct UBlock *ub; |
486 | struct GNUNET_FS_Uri *chk_uri; | 484 | struct GNUNET_FS_Uri *chk_uri; |
487 | struct GNUNET_HashCode query; | 485 | struct GNUNET_HashCode query; |
488 | struct GNUNET_HashCode dh; | ||
489 | 486 | ||
490 | uc->dqe = NULL; | 487 | uc->dqe = NULL; |
491 | if (NULL == data) | 488 | if (NULL == data) |
492 | { | 489 | { |
493 | /* no result */ | 490 | /* no result */ |
494 | GNUNET_CONTAINER_multihashmap_clear (uc->seen_dh); | ||
495 | uc->ksk_offset++; | 491 | uc->ksk_offset++; |
496 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); | 492 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); |
497 | return; | 493 | return; |
498 | } | 494 | } |
499 | GNUNET_CRYPTO_hash (data, | ||
500 | size, | ||
501 | &dh); | ||
502 | if (GNUNET_YES == | ||
503 | GNUNET_CONTAINER_multihashmap_contains (uc->seen_dh, | ||
504 | &dh)) | ||
505 | { | ||
506 | GNUNET_CONTAINER_multihashmap_clear (uc->seen_dh); | ||
507 | uc->ksk_offset++; | ||
508 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); | ||
509 | return; | ||
510 | } | ||
511 | GNUNET_assert (GNUNET_OK == | ||
512 | GNUNET_CONTAINER_multihashmap_put (uc->seen_dh, | ||
513 | &dh, | ||
514 | uc, | ||
515 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
516 | GNUNET_assert (GNUNET_BLOCK_TYPE_FS_UBLOCK == type); | 495 | GNUNET_assert (GNUNET_BLOCK_TYPE_FS_UBLOCK == type); |
517 | if (size < sizeof (struct UBlock)) | 496 | if (size < sizeof (struct UBlock)) |
518 | { | 497 | { |
@@ -565,23 +544,24 @@ process_kblock_for_unindex (void *cls, | |||
565 | GNUNET_FS_uri_destroy (chk_uri); | 544 | GNUNET_FS_uri_destroy (chk_uri); |
566 | /* matches! */ | 545 | /* matches! */ |
567 | uc->dqe = GNUNET_DATASTORE_remove (uc->dsh, | 546 | uc->dqe = GNUNET_DATASTORE_remove (uc->dsh, |
568 | key, | 547 | key, |
569 | size, | 548 | size, |
570 | data, | 549 | data, |
571 | 0 /* priority */, | 550 | 0 /* priority */, |
572 | 1 /* queue size */, | 551 | 1 /* queue size */, |
573 | &continue_after_remove, | 552 | &continue_after_remove, |
574 | uc); | 553 | uc); |
575 | return; | 554 | return; |
576 | get_next: | 555 | get_next: |
577 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, | 556 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, |
578 | uc->roff++, | 557 | uid + 1 /* next_uid */, |
579 | &uc->uquery, | 558 | false /* random */, |
580 | GNUNET_BLOCK_TYPE_FS_UBLOCK, | 559 | &uc->uquery, |
581 | 0 /* priority */, | 560 | GNUNET_BLOCK_TYPE_FS_UBLOCK, |
561 | 0 /* priority */, | ||
582 | 1 /* queue size */, | 562 | 1 /* queue size */, |
583 | &process_kblock_for_unindex, | 563 | &process_kblock_for_unindex, |
584 | uc); | 564 | uc); |
585 | } | 565 | } |
586 | 566 | ||
587 | 567 | ||
@@ -626,13 +606,14 @@ GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) | |||
626 | sizeof (dpub), | 606 | sizeof (dpub), |
627 | &uc->uquery); | 607 | &uc->uquery); |
628 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, | 608 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, |
629 | uc->roff++, | 609 | 0 /* next_uid */, |
630 | &uc->uquery, | 610 | false /* random */, |
631 | GNUNET_BLOCK_TYPE_FS_UBLOCK, | 611 | &uc->uquery, |
632 | 0 /* priority */, | 612 | GNUNET_BLOCK_TYPE_FS_UBLOCK, |
613 | 0 /* priority */, | ||
633 | 1 /* queue size */, | 614 | 1 /* queue size */, |
634 | &process_kblock_for_unindex, | 615 | &process_kblock_for_unindex, |
635 | uc); | 616 | uc); |
636 | } | 617 | } |
637 | 618 | ||
638 | 619 | ||
@@ -825,8 +806,6 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, | |||
825 | uc->start_time = GNUNET_TIME_absolute_get (); | 806 | uc->start_time = GNUNET_TIME_absolute_get (); |
826 | uc->file_size = size; | 807 | uc->file_size = size; |
827 | uc->client_info = cctx; | 808 | uc->client_info = cctx; |
828 | uc->seen_dh = GNUNET_CONTAINER_multihashmap_create (4, | ||
829 | GNUNET_NO); | ||
830 | GNUNET_FS_unindex_sync_ (uc); | 809 | GNUNET_FS_unindex_sync_ (uc); |
831 | pi.status = GNUNET_FS_STATUS_UNINDEX_START; | 810 | pi.status = GNUNET_FS_STATUS_UNINDEX_START; |
832 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 811 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; |
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index fa27e6e9b..11968b750 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -309,7 +309,8 @@ uri_ksk_parse (const char *s, | |||
309 | } | 309 | } |
310 | iret = max; | 310 | iret = max; |
311 | dup = GNUNET_strdup (s); | 311 | dup = GNUNET_strdup (s); |
312 | keywords = GNUNET_malloc (max * sizeof (char *)); | 312 | keywords = GNUNET_new_array (max, |
313 | char *); | ||
313 | for (i = slen - 1; i >= (int) pos; i--) | 314 | for (i = slen - 1; i >= (int) pos; i--) |
314 | { | 315 | { |
315 | if ((s[i] == '%') && (&s[i] == strstr (&s[i], "%22"))) | 316 | if ((s[i] == '%') && (&s[i] == strstr (&s[i], "%22"))) |
@@ -937,7 +938,8 @@ GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1, | |||
937 | return NULL; | 938 | return NULL; |
938 | } | 939 | } |
939 | kc = u1->data.ksk.keywordCount; | 940 | kc = u1->data.ksk.keywordCount; |
940 | kl = GNUNET_malloc ((kc + u2->data.ksk.keywordCount) * sizeof (char *)); | 941 | kl = GNUNET_new_array (kc + u2->data.ksk.keywordCount, |
942 | char *); | ||
941 | for (i = 0; i < u1->data.ksk.keywordCount; i++) | 943 | for (i = 0; i < u1->data.ksk.keywordCount; i++) |
942 | kl[i] = GNUNET_strdup (u1->data.ksk.keywords[i]); | 944 | kl[i] = GNUNET_strdup (u1->data.ksk.keywords[i]); |
943 | for (i = 0; i < u2->data.ksk.keywordCount; i++) | 945 | for (i = 0; i < u2->data.ksk.keywordCount; i++) |
@@ -991,8 +993,9 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri) | |||
991 | } | 993 | } |
992 | if (ret->data.ksk.keywordCount > 0) | 994 | if (ret->data.ksk.keywordCount > 0) |
993 | { | 995 | { |
994 | ret->data.ksk.keywords = | 996 | ret->data.ksk.keywords |
995 | GNUNET_malloc (ret->data.ksk.keywordCount * sizeof (char *)); | 997 | = GNUNET_new_array (ret->data.ksk.keywordCount, |
998 | char *); | ||
996 | for (i = 0; i < ret->data.ksk.keywordCount; i++) | 999 | for (i = 0; i < ret->data.ksk.keywordCount; i++) |
997 | ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]); | 1000 | ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]); |
998 | } | 1001 | } |
@@ -1078,7 +1081,8 @@ GNUNET_FS_uri_ksk_create (const char *keywords, | |||
1078 | *emsg = GNUNET_strdup (_("Number of double-quotes not balanced!\n")); | 1081 | *emsg = GNUNET_strdup (_("Number of double-quotes not balanced!\n")); |
1079 | return NULL; | 1082 | return NULL; |
1080 | } | 1083 | } |
1081 | keywordarr = GNUNET_malloc (num_Words * sizeof (char *)); | 1084 | keywordarr = GNUNET_new_array (num_Words, |
1085 | char *); | ||
1082 | num_Words = 0; | 1086 | num_Words = 0; |
1083 | inWord = 0; | 1087 | inWord = 0; |
1084 | pos = searchString; | 1088 | pos = searchString; |
@@ -1151,7 +1155,8 @@ GNUNET_FS_uri_ksk_create_from_args (unsigned int argc, | |||
1151 | uri = GNUNET_new (struct GNUNET_FS_Uri); | 1155 | uri = GNUNET_new (struct GNUNET_FS_Uri); |
1152 | uri->type = GNUNET_FS_URI_KSK; | 1156 | uri->type = GNUNET_FS_URI_KSK; |
1153 | uri->data.ksk.keywordCount = argc; | 1157 | uri->data.ksk.keywordCount = argc; |
1154 | uri->data.ksk.keywords = GNUNET_malloc (argc * sizeof (char *)); | 1158 | uri->data.ksk.keywords = GNUNET_new_array (argc, |
1159 | char *); | ||
1155 | for (i = 0; i < argc; i++) | 1160 | for (i = 0; i < argc; i++) |
1156 | { | 1161 | { |
1157 | keyword = argv[i]; | 1162 | keyword = argv[i]; |
@@ -1766,8 +1771,9 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData | |||
1766 | } | 1771 | } |
1767 | /* x3 because there might be a normalized variant of every keyword, | 1772 | /* x3 because there might be a normalized variant of every keyword, |
1768 | plus theoretically one more for mime... */ | 1773 | plus theoretically one more for mime... */ |
1769 | ret->data.ksk.keywords = GNUNET_malloc | 1774 | ret->data.ksk.keywords |
1770 | (sizeof (char *) * (ent + tok_keywords + paren_keywords) * 3); | 1775 | = GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3, |
1776 | char *); | ||
1771 | GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret); | 1777 | GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret); |
1772 | } | 1778 | } |
1773 | if (tok_keywords > 0) | 1779 | if (tok_keywords > 0) |
diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c index cc0111111..2f980520a 100644 --- a/src/fs/gnunet-auto-share.c +++ b/src/fs/gnunet-auto-share.c | |||
@@ -72,7 +72,7 @@ static int ret; | |||
72 | /** | 72 | /** |
73 | * Are we running 'verbosely'? | 73 | * Are we running 'verbosely'? |
74 | */ | 74 | */ |
75 | static int verbose; | 75 | static unsigned int verbose; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Configuration to use. | 78 | * Configuration to use. |
@@ -759,26 +759,38 @@ free_item (void *cls, | |||
759 | int | 759 | int |
760 | main (int argc, char *const *argv) | 760 | main (int argc, char *const *argv) |
761 | { | 761 | { |
762 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 762 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
763 | {'a', "anonymity", "LEVEL", | 763 | |
764 | gettext_noop ("set the desired LEVEL of sender-anonymity"), | 764 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
765 | 1, &GNUNET_GETOPT_set_uint, &anonymity_level}, | 765 | "anonymity", |
766 | {'d', "disable-creation-time", NULL, | 766 | "LEVEL", |
767 | gettext_noop | 767 | gettext_noop ("set the desired LEVEL of sender-anonymity"), |
768 | ("disable adding the creation time to the metadata of the uploaded file"), | 768 | &anonymity_level), |
769 | 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time}, | 769 | |
770 | {'D', "disable-extractor", NULL, | 770 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
771 | gettext_noop ("do not use libextractor to add keywords or metadata"), | 771 | "disable-creation-time", |
772 | 0, &GNUNET_GETOPT_set_one, &disable_extractor}, | 772 | gettext_noop ("disable adding the creation time to the metadata of the uploaded file"), |
773 | {'p', "priority", "PRIORITY", | 773 | &do_disable_creation_time), |
774 | gettext_noop ("specify the priority of the content"), | 774 | |
775 | 1, &GNUNET_GETOPT_set_uint, &content_priority}, | 775 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
776 | {'r', "replication", "LEVEL", | 776 | "disable-extractor", |
777 | gettext_noop ("set the desired replication LEVEL"), | 777 | gettext_noop ("do not use libextractor to add keywords or metadata"), |
778 | 1, &GNUNET_GETOPT_set_uint, &replication_level}, | 778 | &disable_extractor), |
779 | {'V', "verbose", NULL, | 779 | |
780 | gettext_noop ("be verbose (print progress information)"), | 780 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
781 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 781 | "priority", |
782 | "PRIORITY", | ||
783 | gettext_noop ("specify the priority of the content"), | ||
784 | &content_priority), | ||
785 | |||
786 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
787 | "replication", | ||
788 | "LEVEL", | ||
789 | gettext_noop ("set the desired replication LEVEL"), | ||
790 | &replication_level), | ||
791 | |||
792 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
793 | |||
782 | GNUNET_GETOPT_OPTION_END | 794 | GNUNET_GETOPT_OPTION_END |
783 | }; | 795 | }; |
784 | struct WorkItem *wi; | 796 | struct WorkItem *wi; |
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index 6d9adb8ab..4d6f30587 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | static int ret; | 31 | static int ret; |
32 | 32 | ||
33 | static int verbose; | 33 | static unsigned int verbose; |
34 | 34 | ||
35 | static int delete_incomplete; | 35 | static int delete_incomplete; |
36 | 36 | ||
@@ -299,33 +299,51 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
299 | int | 299 | int |
300 | main (int argc, char *const *argv) | 300 | main (int argc, char *const *argv) |
301 | { | 301 | { |
302 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 302 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
303 | {'a', "anonymity", "LEVEL", | 303 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
304 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), | 304 | "anonymity", |
305 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, | 305 | "LEVEL", |
306 | {'D', "delete-incomplete", NULL, | 306 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), |
307 | gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), | 307 | &anonymity), |
308 | 0, &GNUNET_GETOPT_set_one, &delete_incomplete}, | 308 | |
309 | {'n', "no-network", NULL, | 309 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
310 | gettext_noop ("only search the local peer (no P2P network search)"), | 310 | "delete-incomplete", |
311 | 0, &GNUNET_GETOPT_set_one, &local_only}, | 311 | gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), |
312 | {'o', "output", "FILENAME", | 312 | &delete_incomplete), |
313 | gettext_noop ("write the file to FILENAME"), | 313 | |
314 | 1, &GNUNET_GETOPT_set_string, &filename}, | 314 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
315 | {'p', "parallelism", "DOWNLOADS", | 315 | "no-network", |
316 | gettext_noop | 316 | gettext_noop ("only search the local peer (no P2P network search)"), |
317 | ("set the maximum number of parallel downloads that is allowed"), | 317 | &local_only), |
318 | 1, &GNUNET_GETOPT_set_uint, ¶llelism}, | 318 | |
319 | {'r', "request-parallelism", "REQUESTS", | 319 | GNUNET_GETOPT_OPTION_STRING ('o', |
320 | gettext_noop | 320 | "output", |
321 | ("set the maximum number of parallel requests for blocks that is allowed"), | 321 | "FILENAME", |
322 | 1, &GNUNET_GETOPT_set_uint, &request_parallelism}, | 322 | gettext_noop ("write the file to FILENAME"), |
323 | {'R', "recursive", NULL, | 323 | &filename), |
324 | gettext_noop ("download a GNUnet directory recursively"), | 324 | |
325 | 0, &GNUNET_GETOPT_set_one, &do_recursive}, | 325 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
326 | {'V', "verbose", NULL, | 326 | "parallelism", |
327 | gettext_noop ("be verbose (print progress information)"), | 327 | "DOWNLOADS", |
328 | 0, &GNUNET_GETOPT_increment_value, &verbose}, | 328 | gettext_noop ("set the maximum number of parallel downloads that is allowed"), |
329 | ¶llelism), | ||
330 | |||
331 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
332 | "request-parallelism", | ||
333 | "REQUESTS", | ||
334 | gettext_noop ("set the maximum number of parallel requests for blocks that is allowed"), | ||
335 | &request_parallelism), | ||
336 | |||
337 | GNUNET_GETOPT_OPTION_SET_ONE ('R', | ||
338 | "recursive", | ||
339 | gettext_noop ("download a GNUnet directory recursively"), | ||
340 | &do_recursive), | ||
341 | |||
342 | GNUNET_GETOPT_OPTION_INCREMENT_VALUE ('V', | ||
343 | "verbose", | ||
344 | gettext_noop ("be verbose (print progress information)"), | ||
345 | &verbose), | ||
346 | |||
329 | GNUNET_GETOPT_OPTION_END | 347 | GNUNET_GETOPT_OPTION_END |
330 | }; | 348 | }; |
331 | 349 | ||
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c index cfbe57bbd..fb99d8f90 100644 --- a/src/fs/gnunet-fs-profiler.c +++ b/src/fs/gnunet-fs-profiler.c | |||
@@ -203,16 +203,26 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
203 | int | 203 | int |
204 | main (int argc, char *const *argv) | 204 | main (int argc, char *const *argv) |
205 | { | 205 | { |
206 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 206 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
207 | {'n', "num-peers", "COUNT", | 207 | |
208 | gettext_noop ("run the experiment with COUNT peers"), | 208 | GNUNET_GETOPT_OPTION_SET_UINT ('n', |
209 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, | 209 | "num-peers", |
210 | {'H', "hosts", "HOSTFILE", | 210 | "COUNT", |
211 | gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), | 211 | gettext_noop ("run the experiment with COUNT peers"), |
212 | 1, &GNUNET_GETOPT_set_string, &host_filename}, | 212 | &num_peers), |
213 | {'t', "timeout", "DELAY", | 213 | |
214 | gettext_noop ("automatically terminate experiment after DELAY"), | 214 | GNUNET_GETOPT_OPTION_STRING ('H', |
215 | 1, &GNUNET_GETOPT_set_relative_time, &timeout}, | 215 | "hosts", |
216 | "HOSTFILE", | ||
217 | gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), | ||
218 | &host_filename), | ||
219 | |||
220 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', | ||
221 | "timeout", | ||
222 | "DELAY", | ||
223 | gettext_noop ("automatically terminate experiment after DELAY"), | ||
224 | &timeout), | ||
225 | |||
216 | GNUNET_GETOPT_OPTION_END | 226 | GNUNET_GETOPT_OPTION_END |
217 | }; | 227 | }; |
218 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 228 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c index 7c20e025f..2b24b7124 100644 --- a/src/fs/gnunet-fs.c +++ b/src/fs/gnunet-fs.c | |||
@@ -43,7 +43,7 @@ static int list_indexed_files; | |||
43 | /** | 43 | /** |
44 | * Option -v given? | 44 | * Option -v given? |
45 | */ | 45 | */ |
46 | static int verbose; | 46 | static unsigned int verbose; |
47 | 47 | ||
48 | 48 | ||
49 | /** | 49 | /** |
@@ -112,10 +112,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
112 | int | 112 | int |
113 | main (int argc, char *const *argv) | 113 | main (int argc, char *const *argv) |
114 | { | 114 | { |
115 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 115 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
116 | {'i', "list-indexed", NULL, | 116 | |
117 | gettext_noop ("print a list of all indexed files"), 0, | 117 | GNUNET_GETOPT_OPTION_SET_ONE ('i', |
118 | &GNUNET_GETOPT_set_one, &list_indexed_files}, | 118 | "list-indexed", |
119 | gettext_noop ("print a list of all indexed files"), | ||
120 | &list_indexed_files), | ||
121 | |||
119 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | 122 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), |
120 | GNUNET_GETOPT_OPTION_END | 123 | GNUNET_GETOPT_OPTION_END |
121 | }; | 124 | }; |
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index 55836e772..72a656de1 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c | |||
@@ -480,7 +480,7 @@ make_dev_zero (int fd, | |||
480 | GNUNET_assert (-1 != z); | 480 | GNUNET_assert (-1 != z); |
481 | if (z == fd) | 481 | if (z == fd) |
482 | return; | 482 | return; |
483 | dup2 (z, fd); | 483 | GNUNET_break (fd == dup2 (z, fd)); |
484 | GNUNET_assert (0 == close (z)); | 484 | GNUNET_assert (0 == close (z)); |
485 | } | 485 | } |
486 | 486 | ||
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index a563d7b7a..2229e45e7 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -37,7 +37,7 @@ static int ret; | |||
37 | /** | 37 | /** |
38 | * Command line option 'verbose' set | 38 | * Command line option 'verbose' set |
39 | */ | 39 | */ |
40 | static int verbose; | 40 | static unsigned int verbose; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Handle to our configuration. | 43 | * Handle to our configuration. |
@@ -893,63 +893,98 @@ run (void *cls, | |||
893 | int | 893 | int |
894 | main (int argc, char *const *argv) | 894 | main (int argc, char *const *argv) |
895 | { | 895 | { |
896 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 896 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
897 | {'a', "anonymity", "LEVEL", | 897 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
898 | gettext_noop ("set the desired LEVEL of sender-anonymity"), | 898 | "anonymity", |
899 | 1, &GNUNET_GETOPT_set_uint, &bo.anonymity_level}, | 899 | "LEVEL", |
900 | {'d', "disable-creation-time", NULL, | 900 | gettext_noop ("set the desired LEVEL of sender-anonymity"), |
901 | gettext_noop | 901 | &bo.anonymity_level), |
902 | ("disable adding the creation time to the metadata of the uploaded file"), | 902 | |
903 | 0, &GNUNET_GETOPT_set_one, &do_disable_creation_time}, | 903 | GNUNET_GETOPT_OPTION_SET_ONE ('d', |
904 | {'D', "disable-extractor", NULL, | 904 | "disable-creation-time", |
905 | gettext_noop ("do not use libextractor to add keywords or metadata"), | 905 | gettext_noop ("disable adding the creation time to the " |
906 | 0, &GNUNET_GETOPT_set_one, &disable_extractor}, | 906 | "metadata of the uploaded file"), |
907 | {'e', "extract", NULL, | 907 | &do_disable_creation_time), |
908 | gettext_noop | 908 | |
909 | ("print list of extracted keywords that would be used, but do not perform upload"), | 909 | GNUNET_GETOPT_OPTION_SET_ONE ('D', |
910 | 0, &GNUNET_GETOPT_set_one, &extract_only}, | 910 | "disable-extractor", |
911 | {'k', "key", "KEYWORD", | 911 | gettext_noop ("do not use libextractor to add keywords or metadata"), |
912 | gettext_noop | 912 | &disable_extractor), |
913 | ("add an additional keyword for the top-level file or directory" | 913 | |
914 | " (this option can be specified multiple times)"), | 914 | GNUNET_GETOPT_OPTION_SET_ONE ('e', |
915 | 1, &GNUNET_FS_getopt_set_keywords, &topKeywords}, | 915 | "extract", |
916 | {'m', "meta", "TYPE:VALUE", | 916 | gettext_noop ("print list of extracted keywords that would " |
917 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), | 917 | "be used, but do not perform upload"), |
918 | 1, &GNUNET_FS_getopt_set_metadata, &meta}, | 918 | &extract_only), |
919 | {'n', "noindex", NULL, | 919 | |
920 | gettext_noop ("do not index, perform full insertion (stores entire " | 920 | GNUNET_FS_GETOPT_KEYWORDS ('k', |
921 | "file in encrypted form in GNUnet database)"), | 921 | "key", |
922 | 0, &GNUNET_GETOPT_set_one, &do_insert}, | 922 | "KEYWORD", |
923 | {'N', "next", "ID", | 923 | gettext_noop ("add an additional keyword for the top-level " |
924 | gettext_noop | 924 | "file or directory (this option can be specified multiple times)"), |
925 | ("specify ID of an updated version to be published in the future" | 925 | &topKeywords), |
926 | " (for namespace insertions only)"), | 926 | |
927 | 1, &GNUNET_GETOPT_set_string, &next_id}, | 927 | GNUNET_FS_GETOPT_METADATA ('m', |
928 | {'p', "priority", "PRIORITY", | 928 | "meta", |
929 | gettext_noop ("specify the priority of the content"), | 929 | "TYPE:VALUE", |
930 | 1, &GNUNET_GETOPT_set_uint, &bo.content_priority}, | 930 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), |
931 | {'P', "pseudonym", "NAME", | 931 | &meta), |
932 | gettext_noop | 932 | |
933 | ("publish the files under the pseudonym NAME (place file into namespace)"), | 933 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
934 | 1, &GNUNET_GETOPT_set_string, &pseudonym}, | 934 | "noindex", |
935 | {'r', "replication", "LEVEL", | 935 | gettext_noop ("do not index, perform full insertion (stores " |
936 | gettext_noop ("set the desired replication LEVEL"), | 936 | "entire file in encrypted form in GNUnet database)"), |
937 | 1, &GNUNET_GETOPT_set_uint, &bo.replication_level}, | 937 | &do_insert), |
938 | {'s', "simulate-only", NULL, | 938 | |
939 | gettext_noop ("only simulate the process but do not do any " | 939 | GNUNET_GETOPT_OPTION_STRING ('N', |
940 | "actual publishing (useful to compute URIs)"), | 940 | "next", |
941 | 0, &GNUNET_GETOPT_set_one, &do_simulate}, | 941 | "ID", |
942 | {'t', "this", "ID", | 942 | gettext_noop ("specify ID of an updated version to be " |
943 | gettext_noop ("set the ID of this version of the publication" | 943 | "published in the future (for namespace insertions only)"), |
944 | " (for namespace insertions only)"), | 944 | &next_id), |
945 | 1, &GNUNET_GETOPT_set_string, &this_id}, | 945 | |
946 | {'u', "uri", "URI", | 946 | GNUNET_GETOPT_OPTION_SET_UINT ('p', |
947 | gettext_noop ("URI to be published (can be used instead of passing a " | 947 | "priority", |
948 | "file to add keywords to the file with the respective URI)"), | 948 | "PRIORITY", |
949 | 1, &GNUNET_GETOPT_set_string, &uri_string}, | 949 | gettext_noop ("specify the priority of the content"), |
950 | {'V', "verbose", NULL, | 950 | &bo.content_priority), |
951 | gettext_noop ("be verbose (print progress information)"), | 951 | |
952 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 952 | GNUNET_GETOPT_OPTION_STRING ('P', |
953 | "pseudonym", | ||
954 | "NAME", | ||
955 | gettext_noop ("publish the files under the pseudonym " | ||
956 | "NAME (place file into namespace)"), | ||
957 | &pseudonym), | ||
958 | |||
959 | GNUNET_GETOPT_OPTION_SET_UINT ('r', | ||
960 | "replication", | ||
961 | "LEVEL", | ||
962 | gettext_noop ("set the desired replication LEVEL"), | ||
963 | &bo.replication_level), | ||
964 | |||
965 | |||
966 | GNUNET_GETOPT_OPTION_SET_ONE ('s', | ||
967 | "simulate-only", | ||
968 | gettext_noop ("only simulate the process but do not do " | ||
969 | "any actual publishing (useful to compute URIs)"), | ||
970 | &do_simulate), | ||
971 | |||
972 | GNUNET_GETOPT_OPTION_STRING ('t', | ||
973 | "this", | ||
974 | "ID", | ||
975 | gettext_noop ("set the ID of this version of the publication " | ||
976 | "(for namespace insertions only)"), | ||
977 | &this_id), | ||
978 | |||
979 | GNUNET_GETOPT_OPTION_STRING ('u', | ||
980 | "uri", | ||
981 | "URI", | ||
982 | gettext_noop ("URI to be published (can be used instead of passing a " | ||
983 | "file to add keywords to the file with the respective URI)"), | ||
984 | &uri_string), | ||
985 | |||
986 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
987 | |||
953 | GNUNET_GETOPT_OPTION_END | 988 | GNUNET_GETOPT_OPTION_END |
954 | }; | 989 | }; |
955 | bo.expiration_time = | 990 | bo.expiration_time = |
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c index dfe6d0e75..22e790cf3 100644 --- a/src/fs/gnunet-search.c +++ b/src/fs/gnunet-search.c | |||
@@ -51,7 +51,7 @@ static unsigned int results_limit; | |||
51 | 51 | ||
52 | static unsigned int results; | 52 | static unsigned int results; |
53 | 53 | ||
54 | static int verbose; | 54 | static unsigned int verbose; |
55 | 55 | ||
56 | static int local_only; | 56 | static int local_only; |
57 | 57 | ||
@@ -305,26 +305,42 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
305 | int | 305 | int |
306 | main (int argc, char *const *argv) | 306 | main (int argc, char *const *argv) |
307 | { | 307 | { |
308 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 308 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
309 | {'a', "anonymity", "LEVEL", | 309 | |
310 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), | 310 | GNUNET_GETOPT_OPTION_SET_UINT ('a', |
311 | 1, &GNUNET_GETOPT_set_uint, &anonymity}, | 311 | "anonymity", |
312 | {'n', "no-network", NULL, | 312 | "LEVEL", |
313 | gettext_noop ("only search the local peer (no P2P network search)"), | 313 | gettext_noop ("set the desired LEVEL of receiver-anonymity"), |
314 | 0, &GNUNET_GETOPT_set_one, &local_only}, | 314 | &anonymity), |
315 | {'o', "output", "PREFIX", | 315 | |
316 | gettext_noop ("write search results to file starting with PREFIX"), | 316 | |
317 | 1, &GNUNET_GETOPT_set_string, &output_filename}, | 317 | GNUNET_GETOPT_OPTION_SET_ONE ('n', |
318 | {'t', "timeout", "DELAY", | 318 | "no-network", |
319 | gettext_noop ("automatically terminate search after DELAY"), | 319 | gettext_noop ("only search the local peer (no P2P network search)"), |
320 | 1, &GNUNET_GETOPT_set_relative_time, &timeout}, | 320 | &local_only), |
321 | {'V', "verbose", NULL, | 321 | |
322 | gettext_noop ("be verbose (print progress information)"), | 322 | GNUNET_GETOPT_OPTION_STRING ('o', |
323 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 323 | "output", |
324 | {'N', "results", "VALUE", | 324 | "PREFIX", |
325 | gettext_noop | 325 | gettext_noop ("write search results to file starting with PREFIX"), |
326 | ("automatically terminate search after VALUE results are found"), | 326 | &output_filename), |
327 | 1, &GNUNET_GETOPT_set_uint, &results_limit}, | 327 | |
328 | GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME ('t', | ||
329 | "timeout", | ||
330 | "DELAY", | ||
331 | gettext_noop ("automatically terminate search after DELAY"), | ||
332 | &timeout), | ||
333 | |||
334 | |||
335 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), | ||
336 | |||
337 | GNUNET_GETOPT_OPTION_SET_UINT ('N', | ||
338 | "results", | ||
339 | "VALUE", | ||
340 | gettext_noop ("automatically terminate search " | ||
341 | "after VALUE results are found"), | ||
342 | &results_limit), | ||
343 | |||
328 | GNUNET_GETOPT_OPTION_END | 344 | GNUNET_GETOPT_OPTION_END |
329 | }; | 345 | }; |
330 | 346 | ||
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 256d0c2b8..09b1e05d8 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
39 | #include "gnunet-service-fs_cp.h" | 39 | #include "gnunet-service-fs_cp.h" |
40 | #include "gnunet-service-fs_indexing.h" | 40 | #include "gnunet-service-fs_indexing.h" |
41 | #include "gnunet-service-fs_lc.h" | ||
42 | #include "gnunet-service-fs_pe.h" | 41 | #include "gnunet-service-fs_pe.h" |
43 | #include "gnunet-service-fs_pr.h" | 42 | #include "gnunet-service-fs_pr.h" |
44 | #include "gnunet-service-fs_push.h" | 43 | #include "gnunet-service-fs_push.h" |
diff --git a/src/fs/gnunet-service-fs_cadet_client.c b/src/fs/gnunet-service-fs_cadet_client.c index 55e0cbc24..c729ebe41 100644 --- a/src/fs/gnunet-service-fs_cadet_client.c +++ b/src/fs/gnunet-service-fs_cadet_client.c | |||
@@ -487,7 +487,7 @@ reset_cadet (struct CadetHandle *mh) | |||
487 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, | 487 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, |
488 | strlen (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), | 488 | strlen (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), |
489 | &port); | 489 | &port); |
490 | mh->channel = GNUNET_CADET_channel_creatE (cadet_handle, | 490 | mh->channel = GNUNET_CADET_channel_create (cadet_handle, |
491 | mh, | 491 | mh, |
492 | &mh->target, | 492 | &mh->target, |
493 | &port, | 493 | &port, |
@@ -627,7 +627,7 @@ get_cadet (const struct GNUNET_PeerIdentity *target) | |||
627 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, | 627 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, |
628 | strlen (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), | 628 | strlen (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), |
629 | &port); | 629 | &port); |
630 | mh->channel = GNUNET_CADET_channel_creatE (cadet_handle, | 630 | mh->channel = GNUNET_CADET_channel_create (cadet_handle, |
631 | mh, | 631 | mh, |
632 | &mh->target, | 632 | &mh->target, |
633 | &port, | 633 | &port, |
diff --git a/src/fs/gnunet-service-fs_cadet_server.c b/src/fs/gnunet-service-fs_cadet_server.c index adbce1154..f8619b812 100644 --- a/src/fs/gnunet-service-fs_cadet_server.c +++ b/src/fs/gnunet-service-fs_cadet_server.c | |||
@@ -289,7 +289,7 @@ handle_datastore_reply (void *cls, | |||
289 | } | 289 | } |
290 | return; | 290 | return; |
291 | } | 291 | } |
292 | if (msize > GNUNET_SERVER_MAX_MESSAGE_SIZE) | 292 | if (msize > GNUNET_MAX_MESSAGE_SIZE) |
293 | { | 293 | { |
294 | GNUNET_break (0); | 294 | GNUNET_break (0); |
295 | continue_writing (sc); | 295 | continue_writing (sc); |
@@ -345,12 +345,13 @@ handle_request (void *cls, | |||
345 | GNUNET_NO); | 345 | GNUNET_NO); |
346 | refresh_timeout_task (sc); | 346 | refresh_timeout_task (sc); |
347 | sc->qe = GNUNET_DATASTORE_get_key (GSF_dsh, | 347 | sc->qe = GNUNET_DATASTORE_get_key (GSF_dsh, |
348 | 0, | 348 | 0 /* next_uid */, |
349 | &sqm->query, | 349 | false /* random */, |
350 | ntohl (sqm->type), | 350 | &sqm->query, |
351 | 0 /* priority */, | 351 | ntohl (sqm->type), |
352 | GSF_datastore_queue_size, | 352 | 0 /* priority */, |
353 | &handle_datastore_reply, | 353 | GSF_datastore_queue_size, |
354 | &handle_datastore_reply, | ||
354 | sc); | 355 | sc); |
355 | if (NULL == sc->qe) | 356 | if (NULL == sc->qe) |
356 | { | 357 | { |
@@ -499,12 +500,12 @@ GSF_cadet_start_server () | |||
499 | "Initializing cadet FS server with a limit of %llu connections\n", | 500 | "Initializing cadet FS server with a limit of %llu connections\n", |
500 | sc_count_max); | 501 | sc_count_max); |
501 | cadet_map = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); | 502 | cadet_map = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES); |
502 | cadet_handle = GNUNET_CADET_connecT (GSF_cfg); | 503 | cadet_handle = GNUNET_CADET_connect (GSF_cfg); |
503 | GNUNET_assert (NULL != cadet_handle); | 504 | GNUNET_assert (NULL != cadet_handle); |
504 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, | 505 | GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER, |
505 | strlen (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), | 506 | strlen (GNUNET_APPLICATION_PORT_FS_BLOCK_TRANSFER), |
506 | &port); | 507 | &port); |
507 | cadet_port = GNUNET_CADET_open_porT (cadet_handle, | 508 | cadet_port = GNUNET_CADET_open_port (cadet_handle, |
508 | &port, | 509 | &port, |
509 | &connect_cb, | 510 | &connect_cb, |
510 | NULL, | 511 | NULL, |
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 3f7783ded..817aed257 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -859,7 +859,7 @@ handle_p2p_reply (void *cls, | |||
859 | size_t msize; | 859 | size_t msize; |
860 | 860 | ||
861 | GNUNET_assert (data_len + sizeof (struct PutMessage) < | 861 | GNUNET_assert (data_len + sizeof (struct PutMessage) < |
862 | GNUNET_SERVER_MAX_MESSAGE_SIZE); | 862 | GNUNET_MAX_MESSAGE_SIZE); |
863 | GNUNET_assert (peerreq->pr == pr); | 863 | GNUNET_assert (peerreq->pr == pr); |
864 | prd = GSF_pending_request_get_data_ (pr); | 864 | prd = GSF_pending_request_get_data_ (pr); |
865 | if (NULL == data) | 865 | if (NULL == data) |
@@ -883,7 +883,7 @@ handle_p2p_reply (void *cls, | |||
883 | gettext_noop ("# replies received for other peers"), | 883 | gettext_noop ("# replies received for other peers"), |
884 | 1, GNUNET_NO); | 884 | 1, GNUNET_NO); |
885 | msize = sizeof (struct PutMessage) + data_len; | 885 | msize = sizeof (struct PutMessage) + data_len; |
886 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 886 | if (msize >= GNUNET_MAX_MESSAGE_SIZE) |
887 | { | 887 | { |
888 | GNUNET_break (0); | 888 | GNUNET_break (0); |
889 | return; | 889 | return; |
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 3ce68f487..ce6bcec41 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c | |||
@@ -438,7 +438,7 @@ GNUNET_FS_indexing_send_list (struct GNUNET_MQ_Handle *mq) | |||
438 | fn = pos->filename; | 438 | fn = pos->filename; |
439 | slen = strlen (fn) + 1; | 439 | slen = strlen (fn) + 1; |
440 | if (slen + sizeof (struct IndexInfoMessage) >= | 440 | if (slen + sizeof (struct IndexInfoMessage) >= |
441 | GNUNET_SERVER_MAX_MESSAGE_SIZE) | 441 | GNUNET_MAX_MESSAGE_SIZE) |
442 | { | 442 | { |
443 | GNUNET_break (0); | 443 | GNUNET_break (0); |
444 | break; | 444 | break; |
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c deleted file mode 100644 index 9ffd6cadd..000000000 --- a/src/fs/gnunet-service-fs_lc.c +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2011 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file fs/gnunet-service-fs_lc.c | ||
22 | * @brief API to handle 'local clients' | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet-service-fs.h" | ||
27 | #include "gnunet-service-fs_lc.h" | ||
28 | #include "gnunet-service-fs_cp.h" | ||
29 | #include "gnunet-service-fs_pr.h" | ||
30 | |||
31 | |||
32 | |||
33 | /* end of gnunet-service-fs_lc.c */ | ||
diff --git a/src/fs/gnunet-service-fs_lc.h b/src/fs/gnunet-service-fs_lc.h deleted file mode 100644 index 6671ed33c..000000000 --- a/src/fs/gnunet-service-fs_lc.h +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2011 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file fs/gnunet-service-fs_lc.h | ||
23 | * @brief API to handle 'local clients' | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_FS_LC_H | ||
27 | #define GNUNET_SERVICE_FS_LC_H | ||
28 | |||
29 | #include "gnunet-service-fs.h" | ||
30 | |||
31 | |||
32 | #endif | ||
33 | /* end of gnunet-service-fs_lc.h */ | ||
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index b0fda24b5..b736b49c2 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -160,20 +160,27 @@ struct GSF_PendingRequest | |||
160 | struct GNUNET_SCHEDULER_Task * warn_task; | 160 | struct GNUNET_SCHEDULER_Task * warn_task; |
161 | 161 | ||
162 | /** | 162 | /** |
163 | * Current offset for querying our local datastore for results. | 163 | * Do we have a first UID yet? |
164 | * Starts at a random value, incremented until we get the same | 164 | */ |
165 | * UID again (detected using 'first_uid'), which is then used | 165 | bool have_first_uid; |
166 | * to termiante the iteration. | 166 | |
167 | /** | ||
168 | * Have we seen a NULL result yet? | ||
167 | */ | 169 | */ |
168 | uint64_t local_result_offset; | 170 | bool seen_null; |
169 | 171 | ||
170 | /** | 172 | /** |
171 | * Unique ID of the first result from the local datastore; | 173 | * Unique ID of the first result from the local datastore; |
172 | * used to detect wrap-around of the offset. | 174 | * used to terminate the loop. |
173 | */ | 175 | */ |
174 | uint64_t first_uid; | 176 | uint64_t first_uid; |
175 | 177 | ||
176 | /** | 178 | /** |
179 | * Result count. | ||
180 | */ | ||
181 | size_t result_count; | ||
182 | |||
183 | /** | ||
177 | * How often have we retried this request via 'cadet'? | 184 | * How often have we retried this request via 'cadet'? |
178 | * (used to bound overall retries). | 185 | * (used to bound overall retries). |
179 | */ | 186 | */ |
@@ -189,11 +196,6 @@ struct GSF_PendingRequest | |||
189 | */ | 196 | */ |
190 | unsigned int replies_seen_size; | 197 | unsigned int replies_seen_size; |
191 | 198 | ||
192 | /** | ||
193 | * Do we have a first UID yet? | ||
194 | */ | ||
195 | unsigned int have_first_uid; | ||
196 | |||
197 | }; | 199 | }; |
198 | 200 | ||
199 | 201 | ||
@@ -332,8 +334,6 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, | |||
332 | if (NULL != target) | 334 | if (NULL != target) |
333 | extra += sizeof (struct GNUNET_PeerIdentity); | 335 | extra += sizeof (struct GNUNET_PeerIdentity); |
334 | pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest) + extra); | 336 | pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest) + extra); |
335 | pr->local_result_offset = | ||
336 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); | ||
337 | pr->public_data.query = *query; | 337 | pr->public_data.query = *query; |
338 | eptr = (struct GNUNET_HashCode *) &pr[1]; | 338 | eptr = (struct GNUNET_HashCode *) &pr[1]; |
339 | if (NULL != target) | 339 | if (NULL != target) |
@@ -1340,6 +1340,123 @@ odc_warn_delay_task (void *cls) | |||
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | 1342 | ||
1343 | /* Call our continuation (if we have any) */ | ||
1344 | static void | ||
1345 | call_continuation (struct GSF_PendingRequest *pr) | ||
1346 | { | ||
1347 | GSF_LocalLookupContinuation cont = pr->llc_cont; | ||
1348 | |||
1349 | GNUNET_assert (NULL == pr->qe); | ||
1350 | if (NULL != pr->warn_task) | ||
1351 | { | ||
1352 | GNUNET_SCHEDULER_cancel (pr->warn_task); | ||
1353 | pr->warn_task = NULL; | ||
1354 | } | ||
1355 | if (NULL == cont) | ||
1356 | return; /* no continuation */ | ||
1357 | pr->llc_cont = NULL; | ||
1358 | if (0 != (GSF_PRO_LOCAL_ONLY & pr->public_data.options)) | ||
1359 | { | ||
1360 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != pr->local_result) | ||
1361 | { | ||
1362 | /* Signal that we are done and that there won't be any | ||
1363 | additional results to allow client to clean up state. */ | ||
1364 | pr->rh (pr->rh_cls, | ||
1365 | GNUNET_BLOCK_EVALUATION_OK_LAST, | ||
1366 | pr, | ||
1367 | UINT32_MAX, | ||
1368 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
1369 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
1370 | GNUNET_BLOCK_TYPE_ANY, | ||
1371 | NULL, | ||
1372 | 0); | ||
1373 | } | ||
1374 | /* Finally, call our continuation to signal that we are | ||
1375 | done with local processing of this request; i.e. to | ||
1376 | start reading again from the client. */ | ||
1377 | cont (pr->llc_cont_cls, NULL, GNUNET_BLOCK_EVALUATION_OK_LAST); | ||
1378 | return; | ||
1379 | } | ||
1380 | |||
1381 | cont (pr->llc_cont_cls, pr, pr->local_result); | ||
1382 | } | ||
1383 | |||
1384 | |||
1385 | /* Update stats and call continuation */ | ||
1386 | static void | ||
1387 | no_more_local_results (struct GSF_PendingRequest *pr) | ||
1388 | { | ||
1389 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | ||
1390 | "No further local responses available.\n"); | ||
1391 | #if INSANE_STATISTICS | ||
1392 | if ( (GNUNET_BLOCK_TYPE_FS_DBLOCK == pr->public_data.type) || | ||
1393 | (GNUNET_BLOCK_TYPE_FS_IBLOCK == pr->public_data.type) ) | ||
1394 | GNUNET_STATISTICS_update (GSF_stats, | ||
1395 | gettext_noop ("# requested DBLOCK or IBLOCK not found"), | ||
1396 | 1, | ||
1397 | GNUNET_NO); | ||
1398 | #endif | ||
1399 | call_continuation (pr); | ||
1400 | } | ||
1401 | |||
1402 | |||
1403 | /* forward declaration */ | ||
1404 | static void | ||
1405 | process_local_reply (void *cls, | ||
1406 | const struct GNUNET_HashCode *key, | ||
1407 | size_t size, | ||
1408 | const void *data, | ||
1409 | enum GNUNET_BLOCK_Type type, | ||
1410 | uint32_t priority, | ||
1411 | uint32_t anonymity, | ||
1412 | struct GNUNET_TIME_Absolute expiration, | ||
1413 | uint64_t uid); | ||
1414 | |||
1415 | |||
1416 | /* Start a local query */ | ||
1417 | static void | ||
1418 | start_local_query (struct GSF_PendingRequest *pr, | ||
1419 | uint64_t next_uid, | ||
1420 | bool random) | ||
1421 | { | ||
1422 | pr->qe_start = GNUNET_TIME_absolute_get (); | ||
1423 | pr->warn_task = | ||
1424 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | ||
1425 | &warn_delay_task, | ||
1426 | pr); | ||
1427 | pr->qe = | ||
1428 | GNUNET_DATASTORE_get_key (GSF_dsh, | ||
1429 | next_uid, | ||
1430 | random, | ||
1431 | &pr->public_data.query, | ||
1432 | pr->public_data.type == | ||
1433 | GNUNET_BLOCK_TYPE_FS_DBLOCK ? | ||
1434 | GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, | ||
1435 | (0 != | ||
1436 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | ||
1437 | public_data.options)) ? UINT_MAX : 1 | ||
1438 | /* queue priority */ , | ||
1439 | (0 != | ||
1440 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | ||
1441 | public_data.options)) ? UINT_MAX : | ||
1442 | GSF_datastore_queue_size | ||
1443 | /* max queue size */ , | ||
1444 | &process_local_reply, pr); | ||
1445 | if (NULL != pr->qe) | ||
1446 | return; | ||
1447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1448 | "ERROR Requesting `%s' of type %d with next_uid %llu from datastore.\n", | ||
1449 | GNUNET_h2s (&pr->public_data.query), | ||
1450 | pr->public_data.type, | ||
1451 | (unsigned long long) next_uid); | ||
1452 | GNUNET_STATISTICS_update (GSF_stats, | ||
1453 | gettext_noop ("# Datastore lookups concluded (error queueing)"), | ||
1454 | 1, | ||
1455 | GNUNET_NO); | ||
1456 | call_continuation (pr); | ||
1457 | } | ||
1458 | |||
1459 | |||
1343 | /** | 1460 | /** |
1344 | * We're processing (local) results for a search request | 1461 | * We're processing (local) results for a search request |
1345 | * from another peer. Pass applicable results to the | 1462 | * from another peer. Pass applicable results to the |
@@ -1369,69 +1486,71 @@ process_local_reply (void *cls, | |||
1369 | uint64_t uid) | 1486 | uint64_t uid) |
1370 | { | 1487 | { |
1371 | struct GSF_PendingRequest *pr = cls; | 1488 | struct GSF_PendingRequest *pr = cls; |
1372 | GSF_LocalLookupContinuation cont; | ||
1373 | struct ProcessReplyClosure prq; | 1489 | struct ProcessReplyClosure prq; |
1374 | struct GNUNET_HashCode query; | 1490 | struct GNUNET_HashCode query; |
1375 | unsigned int old_rf; | 1491 | unsigned int old_rf; |
1376 | 1492 | ||
1377 | GNUNET_SCHEDULER_cancel (pr->warn_task); | 1493 | GNUNET_SCHEDULER_cancel (pr->warn_task); |
1378 | pr->warn_task = NULL; | 1494 | pr->warn_task = NULL; |
1379 | if (NULL != pr->qe) | 1495 | if (NULL == pr->qe) |
1496 | goto called_from_on_demand; | ||
1497 | pr->qe = NULL; | ||
1498 | if ( (NULL == key) && | ||
1499 | pr->seen_null && | ||
1500 | !pr->have_first_uid) /* We have hit the end for the 2nd time with no results */ | ||
1380 | { | 1501 | { |
1381 | pr->qe = NULL; | 1502 | /* No results */ |
1382 | if (NULL == key) | ||
1383 | { | ||
1384 | #if INSANE_STATISTICS | 1503 | #if INSANE_STATISTICS |
1385 | GNUNET_STATISTICS_update (GSF_stats, | 1504 | GNUNET_STATISTICS_update (GSF_stats, |
1386 | gettext_noop | 1505 | gettext_noop |
1387 | ("# Datastore lookups concluded (no results)"), | 1506 | ("# Datastore lookups concluded (no results)"), |
1388 | 1, GNUNET_NO); | 1507 | 1, GNUNET_NO); |
1389 | #endif | 1508 | #endif |
1390 | } | 1509 | no_more_local_results (pr); |
1391 | if (GNUNET_NO == pr->have_first_uid) | 1510 | return; |
1392 | { | 1511 | } |
1393 | pr->first_uid = uid; | 1512 | if ( ( (NULL == key) && |
1394 | pr->have_first_uid = 1; | 1513 | pr->seen_null ) || /* We have hit the end for the 2nd time OR */ |
1395 | } | 1514 | ( pr->seen_null && |
1396 | else | 1515 | pr->have_first_uid && |
1397 | { | 1516 | (uid >= pr->first_uid) ) ) /* We have hit the end and past first UID */ |
1398 | if ((uid == pr->first_uid) && (key != NULL)) | 1517 | { |
1399 | { | 1518 | /* Seen all results */ |
1400 | GNUNET_STATISTICS_update (GSF_stats, | 1519 | GNUNET_STATISTICS_update (GSF_stats, |
1401 | gettext_noop | 1520 | gettext_noop |
1402 | ("# Datastore lookups concluded (seen all)"), | 1521 | ("# Datastore lookups concluded (seen all)"), |
1403 | 1, GNUNET_NO); | 1522 | 1, GNUNET_NO); |
1404 | key = NULL; /* all replies seen! */ | 1523 | no_more_local_results (pr); |
1405 | } | 1524 | return; |
1406 | pr->have_first_uid++; | ||
1407 | if ((pr->have_first_uid > MAX_RESULTS) && (key != NULL)) | ||
1408 | { | ||
1409 | GNUNET_STATISTICS_update (GSF_stats, | ||
1410 | gettext_noop | ||
1411 | ("# Datastore lookups aborted (more than MAX_RESULTS)"), | ||
1412 | 1, GNUNET_NO); | ||
1413 | key = NULL; /* all replies seen! */ | ||
1414 | } | ||
1415 | } | ||
1416 | } | 1525 | } |
1417 | if (NULL == key) | 1526 | if (NULL == key) |
1418 | { | 1527 | { |
1419 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 1528 | GNUNET_assert (!pr->seen_null); |
1420 | "No further local responses available.\n"); | 1529 | pr->seen_null = true; |
1421 | #if INSANE_STATISTICS | 1530 | start_local_query (pr, |
1422 | if ((pr->public_data.type == GNUNET_BLOCK_TYPE_FS_DBLOCK) || | 1531 | 0 /* next_uid */, |
1423 | (pr->public_data.type == GNUNET_BLOCK_TYPE_FS_IBLOCK)) | 1532 | false /* random */); |
1424 | GNUNET_STATISTICS_update (GSF_stats, | 1533 | return; |
1425 | gettext_noop | 1534 | } |
1426 | ("# requested DBLOCK or IBLOCK not found"), 1, | 1535 | if (!pr->have_first_uid) |
1427 | GNUNET_NO); | 1536 | { |
1428 | #endif | 1537 | pr->first_uid = uid; |
1429 | goto check_error_and_continue; | 1538 | pr->have_first_uid = true; |
1539 | } | ||
1540 | pr->result_count++; | ||
1541 | if (pr->result_count > MAX_RESULTS) | ||
1542 | { | ||
1543 | GNUNET_STATISTICS_update (GSF_stats, | ||
1544 | gettext_noop | ||
1545 | ("# Datastore lookups aborted (more than MAX_RESULTS)"), | ||
1546 | 1, GNUNET_NO); | ||
1547 | no_more_local_results (pr); | ||
1548 | return; | ||
1430 | } | 1549 | } |
1431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1550 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1432 | "Received reply for `%s' of type %d with UID %llu from datastore.\n", | 1551 | "Received reply for `%s' of type %d with UID %llu from datastore.\n", |
1433 | GNUNET_h2s (key), type, (unsigned long long) uid); | 1552 | GNUNET_h2s (key), type, (unsigned long long) uid); |
1434 | if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND) | 1553 | if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type) |
1435 | { | 1554 | { |
1436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1437 | "Found ONDEMAND block, performing on-demand encoding\n"); | 1556 | "Found ONDEMAND block, performing on-demand encoding\n"); |
@@ -1458,33 +1577,12 @@ process_local_reply (void *cls, | |||
1458 | gettext_noop ("# on-demand lookups failed"), 1, | 1577 | gettext_noop ("# on-demand lookups failed"), 1, |
1459 | GNUNET_NO); | 1578 | GNUNET_NO); |
1460 | GNUNET_SCHEDULER_cancel (pr->warn_task); | 1579 | GNUNET_SCHEDULER_cancel (pr->warn_task); |
1461 | pr->warn_task = | 1580 | start_local_query (pr, |
1462 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 1581 | uid + 1 /* next_uid */, |
1463 | &warn_delay_task, pr); | 1582 | false /* random */); |
1464 | pr->qe = | 1583 | return; |
1465 | GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1, | ||
1466 | &pr->public_data.query, | ||
1467 | pr->public_data.type == | ||
1468 | GNUNET_BLOCK_TYPE_FS_DBLOCK ? | ||
1469 | GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, | ||
1470 | (0 != | ||
1471 | (GSF_PRO_PRIORITY_UNLIMITED & | ||
1472 | pr->public_data.options)) ? UINT_MAX : 1 | ||
1473 | /* queue priority */ , | ||
1474 | (0 != | ||
1475 | (GSF_PRO_PRIORITY_UNLIMITED & | ||
1476 | pr->public_data.options)) ? UINT_MAX : | ||
1477 | GSF_datastore_queue_size | ||
1478 | /* max queue size */ , | ||
1479 | &process_local_reply, pr); | ||
1480 | if (NULL != pr->qe) | ||
1481 | return; /* we're done */ | ||
1482 | GNUNET_STATISTICS_update (GSF_stats, | ||
1483 | gettext_noop | ||
1484 | ("# Datastore lookups concluded (error queueing)"), | ||
1485 | 1, GNUNET_NO); | ||
1486 | goto check_error_and_continue; | ||
1487 | } | 1584 | } |
1585 | called_from_on_demand: | ||
1488 | old_rf = pr->public_data.results_found; | 1586 | old_rf = pr->public_data.results_found; |
1489 | memset (&prq, 0, sizeof (prq)); | 1587 | memset (&prq, 0, sizeof (prq)); |
1490 | prq.data = data; | 1588 | prq.data = data; |
@@ -1496,34 +1594,9 @@ process_local_reply (void *cls, | |||
1496 | GNUNET_break (0); | 1594 | GNUNET_break (0); |
1497 | GNUNET_DATASTORE_remove (GSF_dsh, key, size, data, -1, -1, | 1595 | GNUNET_DATASTORE_remove (GSF_dsh, key, size, data, -1, -1, |
1498 | NULL, NULL); | 1596 | NULL, NULL); |
1499 | pr->qe_start = GNUNET_TIME_absolute_get (); | 1597 | start_local_query (pr, |
1500 | pr->warn_task = | 1598 | uid + 1 /* next_uid */, |
1501 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | 1599 | false /* random */); |
1502 | &warn_delay_task, pr); | ||
1503 | pr->qe = | ||
1504 | GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset - 1, | ||
1505 | &pr->public_data.query, | ||
1506 | pr->public_data.type == | ||
1507 | GNUNET_BLOCK_TYPE_FS_DBLOCK ? | ||
1508 | GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, | ||
1509 | (0 != | ||
1510 | (GSF_PRO_PRIORITY_UNLIMITED & | ||
1511 | pr->public_data.options)) ? UINT_MAX : 1 | ||
1512 | /* queue priority */ , | ||
1513 | (0 != | ||
1514 | (GSF_PRO_PRIORITY_UNLIMITED & | ||
1515 | pr->public_data.options)) ? UINT_MAX : | ||
1516 | GSF_datastore_queue_size | ||
1517 | /* max queue size */ , | ||
1518 | &process_local_reply, pr); | ||
1519 | if (NULL == pr->qe) | ||
1520 | { | ||
1521 | GNUNET_STATISTICS_update (GSF_stats, | ||
1522 | gettext_noop | ||
1523 | ("# Datastore lookups concluded (error queueing)"), | ||
1524 | 1, GNUNET_NO); | ||
1525 | goto check_error_and_continue; | ||
1526 | } | ||
1527 | return; | 1600 | return; |
1528 | } | 1601 | } |
1529 | prq.type = type; | 1602 | prq.type = type; |
@@ -1535,14 +1608,15 @@ process_local_reply (void *cls, | |||
1535 | prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO; | 1608 | prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO; |
1536 | process_reply (&prq, key, pr); | 1609 | process_reply (&prq, key, pr); |
1537 | pr->local_result = prq.eval; | 1610 | pr->local_result = prq.eval; |
1538 | if (prq.eval == GNUNET_BLOCK_EVALUATION_OK_LAST) | 1611 | if (GNUNET_BLOCK_EVALUATION_OK_LAST == prq.eval) |
1539 | { | 1612 | { |
1540 | GNUNET_STATISTICS_update (GSF_stats, | 1613 | GNUNET_STATISTICS_update (GSF_stats, |
1541 | gettext_noop | 1614 | gettext_noop |
1542 | ("# Datastore lookups concluded (found last result)"), | 1615 | ("# Datastore lookups concluded (found last result)"), |
1543 | 1, | 1616 | 1, |
1544 | GNUNET_NO); | 1617 | GNUNET_NO); |
1545 | goto check_error_and_continue; | 1618 | call_continuation (pr); |
1619 | return; | ||
1546 | } | 1620 | } |
1547 | if ((0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) && | 1621 | if ((0 == (GSF_PRO_PRIORITY_UNLIMITED & pr->public_data.options)) && |
1548 | ((GNUNET_YES == GSF_test_get_load_too_high_ (0)) || | 1622 | ((GNUNET_YES == GSF_test_get_load_too_high_ (0)) || |
@@ -1554,66 +1628,12 @@ process_local_reply (void *cls, | |||
1554 | gettext_noop ("# Datastore lookups concluded (load too high)"), | 1628 | gettext_noop ("# Datastore lookups concluded (load too high)"), |
1555 | 1, | 1629 | 1, |
1556 | GNUNET_NO); | 1630 | GNUNET_NO); |
1557 | goto check_error_and_continue; | 1631 | call_continuation (pr); |
1558 | } | ||
1559 | pr->qe_start = GNUNET_TIME_absolute_get (); | ||
1560 | pr->warn_task = | ||
1561 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | ||
1562 | &warn_delay_task, | ||
1563 | pr); | ||
1564 | pr->qe = | ||
1565 | GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++, | ||
1566 | &pr->public_data.query, | ||
1567 | pr->public_data.type == | ||
1568 | GNUNET_BLOCK_TYPE_FS_DBLOCK ? | ||
1569 | GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, | ||
1570 | (0 != | ||
1571 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | ||
1572 | public_data.options)) ? UINT_MAX : 1 | ||
1573 | /* queue priority */ , | ||
1574 | (0 != | ||
1575 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | ||
1576 | public_data.options)) ? UINT_MAX : | ||
1577 | GSF_datastore_queue_size | ||
1578 | /* max queue size */ , | ||
1579 | &process_local_reply, pr); | ||
1580 | /* check if we successfully queued another datastore request; | ||
1581 | * if so, return, otherwise call our continuation (if we have | ||
1582 | * any) */ | ||
1583 | check_error_and_continue: | ||
1584 | if (NULL != pr->qe) | ||
1585 | return; | 1632 | return; |
1586 | if (NULL != pr->warn_task) | ||
1587 | { | ||
1588 | GNUNET_SCHEDULER_cancel (pr->warn_task); | ||
1589 | pr->warn_task = NULL; | ||
1590 | } | 1633 | } |
1591 | if (NULL == (cont = pr->llc_cont)) | 1634 | start_local_query (pr, |
1592 | return; /* no continuation */ | 1635 | uid + 1 /* next_uid */, |
1593 | pr->llc_cont = NULL; | 1636 | false /* random */); |
1594 | if (0 != (GSF_PRO_LOCAL_ONLY & pr->public_data.options)) | ||
1595 | { | ||
1596 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != pr->local_result) | ||
1597 | { | ||
1598 | /* Signal that we are done and that there won't be any | ||
1599 | additional results to allow client to clean up state. */ | ||
1600 | pr->rh (pr->rh_cls, | ||
1601 | GNUNET_BLOCK_EVALUATION_OK_LAST, | ||
1602 | pr, | ||
1603 | UINT32_MAX, | ||
1604 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
1605 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
1606 | GNUNET_BLOCK_TYPE_ANY, | ||
1607 | NULL, 0); | ||
1608 | } | ||
1609 | /* Finally, call our continuation to signal that we are | ||
1610 | done with local processing of this request; i.e. to | ||
1611 | start reading again from the client. */ | ||
1612 | cont (pr->llc_cont_cls, NULL, GNUNET_BLOCK_EVALUATION_OK_LAST); | ||
1613 | return; | ||
1614 | } | ||
1615 | |||
1616 | cont (pr->llc_cont_cls, pr, pr->local_result); | ||
1617 | } | 1637 | } |
1618 | 1638 | ||
1619 | 1639 | ||
@@ -1657,43 +1677,14 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr, | |||
1657 | GNUNET_assert (NULL == pr->llc_cont); | 1677 | GNUNET_assert (NULL == pr->llc_cont); |
1658 | pr->llc_cont = cont; | 1678 | pr->llc_cont = cont; |
1659 | pr->llc_cont_cls = cont_cls; | 1679 | pr->llc_cont_cls = cont_cls; |
1660 | pr->qe_start = GNUNET_TIME_absolute_get (); | ||
1661 | pr->warn_task = | ||
1662 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, | ||
1663 | &warn_delay_task, | ||
1664 | pr); | ||
1665 | #if INSANE_STATISTICS | 1680 | #if INSANE_STATISTICS |
1666 | GNUNET_STATISTICS_update (GSF_stats, | 1681 | GNUNET_STATISTICS_update (GSF_stats, |
1667 | gettext_noop ("# Datastore lookups initiated"), 1, | 1682 | gettext_noop ("# Datastore lookups initiated"), 1, |
1668 | GNUNET_NO); | 1683 | GNUNET_NO); |
1669 | #endif | 1684 | #endif |
1670 | pr->qe = | 1685 | start_local_query(pr, |
1671 | GNUNET_DATASTORE_get_key (GSF_dsh, pr->local_result_offset++, | 1686 | 0 /* next_uid */, |
1672 | &pr->public_data.query, | 1687 | true /* random */); |
1673 | pr->public_data.type == | ||
1674 | GNUNET_BLOCK_TYPE_FS_DBLOCK ? | ||
1675 | GNUNET_BLOCK_TYPE_ANY : pr->public_data.type, | ||
1676 | (0 != | ||
1677 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | ||
1678 | public_data.options)) ? UINT_MAX : 1 | ||
1679 | /* queue priority */ , | ||
1680 | (0 != | ||
1681 | (GSF_PRO_PRIORITY_UNLIMITED & pr-> | ||
1682 | public_data.options)) ? UINT_MAX : | ||
1683 | GSF_datastore_queue_size | ||
1684 | /* max queue size */ , | ||
1685 | &process_local_reply, pr); | ||
1686 | if (NULL != pr->qe) | ||
1687 | return; | ||
1688 | GNUNET_STATISTICS_update (GSF_stats, | ||
1689 | gettext_noop | ||
1690 | ("# Datastore lookups concluded (error queueing)"), | ||
1691 | 1, GNUNET_NO); | ||
1692 | GNUNET_SCHEDULER_cancel (pr->warn_task); | ||
1693 | pr->warn_task = NULL; | ||
1694 | pr->llc_cont = NULL; | ||
1695 | if (NULL != cont) | ||
1696 | cont (cont_cls, pr, pr->local_result); | ||
1697 | } | 1688 | } |
1698 | 1689 | ||
1699 | 1690 | ||
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c index bb4cb4ecb..cd062bf2b 100644 --- a/src/fs/gnunet-service-fs_put.c +++ b/src/fs/gnunet-service-fs_put.c | |||
@@ -72,9 +72,14 @@ struct PutOperator | |||
72 | uint64_t zero_anonymity_count_estimate; | 72 | uint64_t zero_anonymity_count_estimate; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Current offset when iterating the database. | 75 | * Count of results received from the database. |
76 | */ | 76 | */ |
77 | uint64_t current_offset; | 77 | uint64_t result_count; |
78 | |||
79 | /** | ||
80 | * Next UID to request when iterating the database. | ||
81 | */ | ||
82 | uint64_t next_uid; | ||
78 | }; | 83 | }; |
79 | 84 | ||
80 | 85 | ||
@@ -177,37 +182,43 @@ delay_dht_put_task (void *cls) | |||
177 | */ | 182 | */ |
178 | static void | 183 | static void |
179 | process_dht_put_content (void *cls, | 184 | process_dht_put_content (void *cls, |
180 | const struct GNUNET_HashCode * key, | 185 | const struct GNUNET_HashCode * key, |
181 | size_t size, | 186 | size_t size, |
182 | const void *data, | 187 | const void *data, |
183 | enum GNUNET_BLOCK_Type type, | 188 | enum GNUNET_BLOCK_Type type, |
184 | uint32_t priority, uint32_t anonymity, | 189 | uint32_t priority, |
185 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 190 | uint32_t anonymity, |
191 | struct GNUNET_TIME_Absolute expiration, | ||
192 | uint64_t uid) | ||
186 | { | 193 | { |
187 | struct PutOperator *po = cls; | 194 | struct PutOperator *po = cls; |
188 | 195 | ||
189 | po->dht_qe = NULL; | 196 | po->dht_qe = NULL; |
190 | if (key == NULL) | 197 | if (key == NULL) |
191 | { | 198 | { |
192 | po->zero_anonymity_count_estimate = po->current_offset - 1; | 199 | po->zero_anonymity_count_estimate = po->result_count; |
193 | po->current_offset = 0; | 200 | po->result_count = 0; |
201 | po->next_uid = 0; | ||
194 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); | 202 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); |
195 | return; | 203 | return; |
196 | } | 204 | } |
205 | po->result_count++; | ||
206 | po->next_uid = uid + 1; | ||
197 | po->zero_anonymity_count_estimate = | 207 | po->zero_anonymity_count_estimate = |
198 | GNUNET_MAX (po->current_offset, po->zero_anonymity_count_estimate); | 208 | GNUNET_MAX (po->result_count, po->zero_anonymity_count_estimate); |
199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
200 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), | 210 | "Retrieved block `%s' of type %u for DHT PUT\n", GNUNET_h2s (key), |
201 | type); | 211 | type); |
202 | po->dht_put = GNUNET_DHT_put (GSF_dht, | 212 | po->dht_put = GNUNET_DHT_put (GSF_dht, |
203 | key, | 213 | key, |
204 | DEFAULT_PUT_REPLICATION, | 214 | DEFAULT_PUT_REPLICATION, |
205 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 215 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
206 | type, | 216 | type, |
207 | size, | 217 | size, |
208 | data, | 218 | data, |
209 | expiration, | 219 | expiration, |
210 | &delay_dht_put_blocks, po); | 220 | &delay_dht_put_blocks, |
221 | po); | ||
211 | } | 222 | } |
212 | 223 | ||
213 | 224 | ||
@@ -223,10 +234,13 @@ gather_dht_put_blocks (void *cls) | |||
223 | 234 | ||
224 | po->dht_task = NULL; | 235 | po->dht_task = NULL; |
225 | po->dht_qe = | 236 | po->dht_qe = |
226 | GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0, | 237 | GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, |
238 | po->next_uid, | ||
239 | 0, | ||
227 | UINT_MAX, | 240 | UINT_MAX, |
228 | po->dht_put_type, | 241 | po->dht_put_type, |
229 | &process_dht_put_content, po); | 242 | &process_dht_put_content, |
243 | po); | ||
230 | if (NULL == po->dht_qe) | 244 | if (NULL == po->dht_qe) |
231 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); | 245 | po->dht_task = GNUNET_SCHEDULER_add_now (&delay_dht_put_task, po); |
232 | } | 246 | } |
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index 40fa13b62..c53a85fb4 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | static int ret; | 31 | static int ret; |
32 | 32 | ||
33 | static int verbose; | 33 | static unsigned int verbose; |
34 | 34 | ||
35 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 35 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
36 | 36 | ||
@@ -162,10 +162,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
162 | int | 162 | int |
163 | main (int argc, char *const *argv) | 163 | main (int argc, char *const *argv) |
164 | { | 164 | { |
165 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 165 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
166 | {'V', "verbose", NULL, | 166 | |
167 | gettext_noop ("be verbose (print progress information)"), | 167 | GNUNET_GETOPT_OPTION_VERBOSE (&verbose), |
168 | 0, &GNUNET_GETOPT_set_one, &verbose}, | 168 | |
169 | GNUNET_GETOPT_OPTION_END | 169 | GNUNET_GETOPT_OPTION_END |
170 | }; | 170 | }; |
171 | 171 | ||