diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-09-18 04:58:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-09-18 04:58:35 +0000 |
commit | 76da475c98bb993807a475deeeee3507769edca4 (patch) | |
tree | fd91819759dbb8434047a27ddedb5577bd105290 /src | |
parent | 80e2d4cacefb32af3466f6aae0d14e20b2135401 (diff) | |
download | gnunet-76da475c98bb993807a475deeeee3507769edca4.tar.gz gnunet-76da475c98bb993807a475deeeee3507769edca4.zip |
code simplification
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 185 |
1 files changed, 44 insertions, 141 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 72d89c726..5831cf26a 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -2565,11 +2565,19 @@ process_reply (void *cls, | |||
2565 | GNUNET_SERVER_client_keep (pr->client_request_list->client_list->client); | 2565 | GNUNET_SERVER_client_keep (pr->client_request_list->client_list->client); |
2566 | } | 2566 | } |
2567 | } | 2567 | } |
2568 | switch (prq->type) | 2568 | eval = GNUNET_BLOCK_evaluate (block_ctx, |
2569 | prq->type, | ||
2570 | key, | ||
2571 | &pr->bf, | ||
2572 | pr->mingle, | ||
2573 | pr->namespace, (pr->namespace != NULL) ? sizeof (GNUNET_HashCode) : 0, | ||
2574 | prq->data, | ||
2575 | prq->size); | ||
2576 | switch (eval) | ||
2569 | { | 2577 | { |
2570 | case GNUNET_BLOCK_TYPE_DBLOCK: | 2578 | case GNUNET_BLOCK_EVALUATION_OK_MORE: |
2571 | case GNUNET_BLOCK_TYPE_IBLOCK: | 2579 | break; |
2572 | /* only possible reply, stop requesting! */ | 2580 | case GNUNET_BLOCK_EVALUATION_OK_LAST: |
2573 | while (NULL != pr->pending_head) | 2581 | while (NULL != pr->pending_head) |
2574 | destroy_pending_message_list_entry (pr->pending_head); | 2582 | destroy_pending_message_list_entry (pr->pending_head); |
2575 | if (pr->qe != NULL) | 2583 | if (pr->qe != NULL) |
@@ -2577,7 +2585,7 @@ process_reply (void *cls, | |||
2577 | if (pr->client_request_list != NULL) | 2585 | if (pr->client_request_list != NULL) |
2578 | GNUNET_SERVER_receive_done (pr->client_request_list->client_list->client, | 2586 | GNUNET_SERVER_receive_done (pr->client_request_list->client_list->client, |
2579 | GNUNET_YES); | 2587 | GNUNET_YES); |
2580 | GNUNET_DATASTORE_cancel (pr->qe); | 2588 | GNUNET_DATASTORE_cancel (pr->qe); |
2581 | pr->qe = NULL; | 2589 | pr->qe = NULL; |
2582 | } | 2590 | } |
2583 | pr->do_remove = GNUNET_YES; | 2591 | pr->do_remove = GNUNET_YES; |
@@ -2592,118 +2600,41 @@ process_reply (void *cls, | |||
2592 | key, | 2600 | key, |
2593 | pr)); | 2601 | pr)); |
2594 | break; | 2602 | break; |
2595 | case GNUNET_BLOCK_TYPE_SBLOCK: | 2603 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: |
2596 | if (pr->namespace == NULL) | 2604 | GNUNET_STATISTICS_update (stats, |
2597 | { | 2605 | gettext_noop ("# duplicate replies discarded (bloomfilter)"), |
2598 | GNUNET_break (0); | 2606 | 1, |
2599 | return GNUNET_YES; | 2607 | GNUNET_NO); |
2600 | } | ||
2601 | eval = GNUNET_BLOCK_evaluate (block_ctx, | ||
2602 | prq->type, | ||
2603 | key, | ||
2604 | &pr->bf, | ||
2605 | pr->mingle, | ||
2606 | pr->namespace, sizeof (GNUNET_HashCode), | ||
2607 | prq->data, | ||
2608 | prq->size); | ||
2609 | switch (eval) | ||
2610 | { | ||
2611 | case GNUNET_BLOCK_EVALUATION_OK_MORE: | ||
2612 | break; | ||
2613 | case GNUNET_BLOCK_EVALUATION_OK_LAST: | ||
2614 | break; | ||
2615 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: | ||
2616 | GNUNET_STATISTICS_update (stats, | ||
2617 | gettext_noop ("# duplicate replies discarded (bloomfilter)"), | ||
2618 | 1, | ||
2619 | GNUNET_NO); | ||
2620 | #if DEBUG_FS | ||
2621 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2622 | "Duplicate response `%s', discarding.\n", | ||
2623 | GNUNET_h2s (&mhash)); | ||
2624 | #endif | ||
2625 | return GNUNET_YES; /* duplicate */ | ||
2626 | case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: | ||
2627 | return GNUNET_YES; /* wrong namespace */ | ||
2628 | case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: | ||
2629 | GNUNET_break (0); | ||
2630 | return GNUNET_YES; | ||
2631 | case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: | ||
2632 | GNUNET_break (0); | ||
2633 | return GNUNET_YES; | ||
2634 | case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: | ||
2635 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2636 | _("Block library does not support FS blocks\n")); | ||
2637 | return GNUNET_NO; | ||
2638 | } | ||
2639 | if (pr->client_request_list != NULL) | ||
2640 | { | ||
2641 | if (pr->replies_seen_size == pr->replies_seen_off) | ||
2642 | GNUNET_array_grow (pr->replies_seen, | ||
2643 | pr->replies_seen_size, | ||
2644 | pr->replies_seen_size * 2 + 4); | ||
2645 | GNUNET_CRYPTO_hash (prq->data, | ||
2646 | prq->size, | ||
2647 | &pr->replies_seen[pr->replies_seen_off++]); | ||
2648 | refresh_bloomfilter (pr); | ||
2649 | } | ||
2650 | break; | ||
2651 | case GNUNET_BLOCK_TYPE_KBLOCK: | ||
2652 | case GNUNET_BLOCK_TYPE_NBLOCK: | ||
2653 | eval = GNUNET_BLOCK_evaluate (block_ctx, | ||
2654 | prq->type, | ||
2655 | key, | ||
2656 | &pr->bf, | ||
2657 | pr->mingle, | ||
2658 | NULL, 0, | ||
2659 | prq->data, | ||
2660 | prq->size); | ||
2661 | switch (eval) | ||
2662 | { | ||
2663 | case GNUNET_BLOCK_EVALUATION_OK_MORE: | ||
2664 | break; | ||
2665 | case GNUNET_BLOCK_EVALUATION_OK_LAST: | ||
2666 | break; | ||
2667 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: | ||
2668 | GNUNET_STATISTICS_update (stats, | ||
2669 | gettext_noop ("# duplicate replies discarded (bloomfilter)"), | ||
2670 | 1, | ||
2671 | GNUNET_NO); | ||
2672 | #if DEBUG_FS | 2608 | #if DEBUG_FS |
2673 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2609 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2674 | "Duplicate response `%s', discarding.\n", | 2610 | "Duplicate response `%s', discarding.\n", |
2675 | GNUNET_h2s (&mhash)); | 2611 | GNUNET_h2s (&mhash)); |
2676 | #endif | 2612 | #endif |
2677 | return GNUNET_YES; /* duplicate */ | 2613 | return GNUNET_YES; /* duplicate */ |
2678 | case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: | 2614 | case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: |
2679 | GNUNET_break_op (0); | 2615 | return GNUNET_YES; /* wrong namespace */ |
2680 | return GNUNET_YES; | 2616 | case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: |
2681 | case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: | ||
2682 | GNUNET_break (0); | ||
2683 | return GNUNET_YES; | ||
2684 | case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: | ||
2685 | GNUNET_break (0); | ||
2686 | return GNUNET_YES; | ||
2687 | case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: | ||
2688 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2689 | _("Block library does not support FS blocks\n")); | ||
2690 | return GNUNET_NO; | ||
2691 | } | ||
2692 | if (pr->client_request_list != NULL) | ||
2693 | { | ||
2694 | if (pr->replies_seen_size == pr->replies_seen_off) | ||
2695 | GNUNET_array_grow (pr->replies_seen, | ||
2696 | pr->replies_seen_size, | ||
2697 | pr->replies_seen_size * 2 + 4); | ||
2698 | GNUNET_CRYPTO_hash (prq->data, | ||
2699 | prq->size, | ||
2700 | &pr->replies_seen[pr->replies_seen_off++]); | ||
2701 | refresh_bloomfilter (pr); | ||
2702 | } | ||
2703 | break; | ||
2704 | default: | ||
2705 | GNUNET_break (0); | 2617 | GNUNET_break (0); |
2706 | return GNUNET_YES; | 2618 | return GNUNET_YES; |
2619 | case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: | ||
2620 | GNUNET_break (0); | ||
2621 | return GNUNET_YES; | ||
2622 | case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: | ||
2623 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2624 | _("Unsupported block type %u\n"), | ||
2625 | prq->type); | ||
2626 | return GNUNET_NO; | ||
2627 | } | ||
2628 | if (pr->client_request_list != NULL) | ||
2629 | { | ||
2630 | if (pr->replies_seen_size == pr->replies_seen_off) | ||
2631 | GNUNET_array_grow (pr->replies_seen, | ||
2632 | pr->replies_seen_size, | ||
2633 | pr->replies_seen_size * 2 + 4); | ||
2634 | GNUNET_CRYPTO_hash (prq->data, | ||
2635 | prq->size, | ||
2636 | &pr->replies_seen[pr->replies_seen_off++]); | ||
2637 | refresh_bloomfilter (pr); | ||
2707 | } | 2638 | } |
2708 | prq->priority += pr->remaining_priority; | 2639 | prq->priority += pr->remaining_priority; |
2709 | pr->remaining_priority = 0; | 2640 | pr->remaining_priority = 0; |
@@ -3262,18 +3193,6 @@ handle_p2p_get (void *cls, | |||
3262 | } | 3193 | } |
3263 | gm = (const struct GetMessage*) message; | 3194 | gm = (const struct GetMessage*) message; |
3264 | type = ntohl (gm->type); | 3195 | type = ntohl (gm->type); |
3265 | switch (type) | ||
3266 | { | ||
3267 | case GNUNET_BLOCK_TYPE_ANY: | ||
3268 | case GNUNET_BLOCK_TYPE_DBLOCK: | ||
3269 | case GNUNET_BLOCK_TYPE_IBLOCK: | ||
3270 | case GNUNET_BLOCK_TYPE_KBLOCK: | ||
3271 | case GNUNET_BLOCK_TYPE_SBLOCK: | ||
3272 | break; | ||
3273 | default: | ||
3274 | GNUNET_break_op (0); | ||
3275 | return GNUNET_SYSERR; | ||
3276 | } | ||
3277 | bm = ntohl (gm->hash_bitmap); | 3196 | bm = ntohl (gm->hash_bitmap); |
3278 | bits = 0; | 3197 | bits = 0; |
3279 | while (bm > 0) | 3198 | while (bm > 0) |
@@ -3565,22 +3484,6 @@ handle_start_search (void *cls, | |||
3565 | GNUNET_h2s (&sm->query), | 3484 | GNUNET_h2s (&sm->query), |
3566 | (unsigned int) type); | 3485 | (unsigned int) type); |
3567 | #endif | 3486 | #endif |
3568 | switch (type) | ||
3569 | { | ||
3570 | case GNUNET_BLOCK_TYPE_ANY: | ||
3571 | case GNUNET_BLOCK_TYPE_DBLOCK: | ||
3572 | case GNUNET_BLOCK_TYPE_IBLOCK: | ||
3573 | case GNUNET_BLOCK_TYPE_KBLOCK: | ||
3574 | case GNUNET_BLOCK_TYPE_SBLOCK: | ||
3575 | case GNUNET_BLOCK_TYPE_NBLOCK: | ||
3576 | break; | ||
3577 | default: | ||
3578 | GNUNET_break (0); | ||
3579 | GNUNET_SERVER_receive_done (client, | ||
3580 | GNUNET_SYSERR); | ||
3581 | return; | ||
3582 | } | ||
3583 | |||
3584 | cl = client_list; | 3487 | cl = client_list; |
3585 | while ( (cl != NULL) && | 3488 | while ( (cl != NULL) && |
3586 | (cl->client != client) ) | 3489 | (cl->client != client) ) |