diff options
Diffstat (limited to 'src/fs/fs_unindex.c')
-rw-r--r-- | src/fs/fs_unindex.c | 58 |
1 files changed, 18 insertions, 40 deletions
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index ad1499f00..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 | } |
@@ -486,34 +483,15 @@ process_kblock_for_unindex (void *cls, | |||
486 | const struct UBlock *ub; | 483 | const struct UBlock *ub; |
487 | struct GNUNET_FS_Uri *chk_uri; | 484 | struct GNUNET_FS_Uri *chk_uri; |
488 | struct GNUNET_HashCode query; | 485 | struct GNUNET_HashCode query; |
489 | struct GNUNET_HashCode dh; | ||
490 | 486 | ||
491 | uc->dqe = NULL; | 487 | uc->dqe = NULL; |
492 | if (NULL == data) | 488 | if (NULL == data) |
493 | { | 489 | { |
494 | /* no result */ | 490 | /* no result */ |
495 | GNUNET_CONTAINER_multihashmap_clear (uc->seen_dh); | ||
496 | uc->ksk_offset++; | 491 | uc->ksk_offset++; |
497 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); | 492 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); |
498 | return; | 493 | return; |
499 | } | 494 | } |
500 | GNUNET_CRYPTO_hash (data, | ||
501 | size, | ||
502 | &dh); | ||
503 | if (GNUNET_YES == | ||
504 | GNUNET_CONTAINER_multihashmap_contains (uc->seen_dh, | ||
505 | &dh)) | ||
506 | { | ||
507 | GNUNET_CONTAINER_multihashmap_clear (uc->seen_dh); | ||
508 | uc->ksk_offset++; | ||
509 | GNUNET_FS_unindex_do_remove_kblocks_ (uc); | ||
510 | return; | ||
511 | } | ||
512 | GNUNET_assert (GNUNET_OK == | ||
513 | GNUNET_CONTAINER_multihashmap_put (uc->seen_dh, | ||
514 | &dh, | ||
515 | uc, | ||
516 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
517 | GNUNET_assert (GNUNET_BLOCK_TYPE_FS_UBLOCK == type); | 495 | GNUNET_assert (GNUNET_BLOCK_TYPE_FS_UBLOCK == type); |
518 | if (size < sizeof (struct UBlock)) | 496 | if (size < sizeof (struct UBlock)) |
519 | { | 497 | { |
@@ -566,23 +544,24 @@ process_kblock_for_unindex (void *cls, | |||
566 | GNUNET_FS_uri_destroy (chk_uri); | 544 | GNUNET_FS_uri_destroy (chk_uri); |
567 | /* matches! */ | 545 | /* matches! */ |
568 | uc->dqe = GNUNET_DATASTORE_remove (uc->dsh, | 546 | uc->dqe = GNUNET_DATASTORE_remove (uc->dsh, |
569 | key, | 547 | key, |
570 | size, | 548 | size, |
571 | data, | 549 | data, |
572 | 0 /* priority */, | 550 | 0 /* priority */, |
573 | 1 /* queue size */, | 551 | 1 /* queue size */, |
574 | &continue_after_remove, | 552 | &continue_after_remove, |
575 | uc); | 553 | uc); |
576 | return; | 554 | return; |
577 | get_next: | 555 | get_next: |
578 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, | 556 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, |
579 | uc->roff++, | 557 | uid + 1 /* next_uid */, |
580 | &uc->uquery, | 558 | false /* random */, |
581 | GNUNET_BLOCK_TYPE_FS_UBLOCK, | 559 | &uc->uquery, |
582 | 0 /* priority */, | 560 | GNUNET_BLOCK_TYPE_FS_UBLOCK, |
561 | 0 /* priority */, | ||
583 | 1 /* queue size */, | 562 | 1 /* queue size */, |
584 | &process_kblock_for_unindex, | 563 | &process_kblock_for_unindex, |
585 | uc); | 564 | uc); |
586 | } | 565 | } |
587 | 566 | ||
588 | 567 | ||
@@ -627,13 +606,14 @@ GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) | |||
627 | sizeof (dpub), | 606 | sizeof (dpub), |
628 | &uc->uquery); | 607 | &uc->uquery); |
629 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, | 608 | uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, |
630 | uc->roff++, | 609 | 0 /* next_uid */, |
631 | &uc->uquery, | 610 | false /* random */, |
632 | GNUNET_BLOCK_TYPE_FS_UBLOCK, | 611 | &uc->uquery, |
633 | 0 /* priority */, | 612 | GNUNET_BLOCK_TYPE_FS_UBLOCK, |
613 | 0 /* priority */, | ||
634 | 1 /* queue size */, | 614 | 1 /* queue size */, |
635 | &process_kblock_for_unindex, | 615 | &process_kblock_for_unindex, |
636 | uc); | 616 | uc); |
637 | } | 617 | } |
638 | 618 | ||
639 | 619 | ||
@@ -826,8 +806,6 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, | |||
826 | uc->start_time = GNUNET_TIME_absolute_get (); | 806 | uc->start_time = GNUNET_TIME_absolute_get (); |
827 | uc->file_size = size; | 807 | uc->file_size = size; |
828 | uc->client_info = cctx; | 808 | uc->client_info = cctx; |
829 | uc->seen_dh = GNUNET_CONTAINER_multihashmap_create (4, | ||
830 | GNUNET_NO); | ||
831 | GNUNET_FS_unindex_sync_ (uc); | 809 | GNUNET_FS_unindex_sync_ (uc); |
832 | pi.status = GNUNET_FS_STATUS_UNINDEX_START; | 810 | pi.status = GNUNET_FS_STATUS_UNINDEX_START; |
833 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; | 811 | pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL; |