diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-11-27 14:22:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-11-27 14:22:03 +0000 |
commit | 1dc3a88ad71d1ca99bed5d38977d69f88de3d253 (patch) | |
tree | b552f9555d927249eb91c8866e403f87debabe9b /src/set | |
parent | f83842231c719b5397110c5819e08b4f2a02c1ca (diff) | |
download | gnunet-1dc3a88ad71d1ca99bed5d38977d69f88de3d253.tar.gz gnunet-1dc3a88ad71d1ca99bed5d38977d69f88de3d253.zip |
-stylistic fixes
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set_union.c | 180 |
1 files changed, 119 insertions, 61 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index ea750f174..b1f65ddcf 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -75,9 +75,9 @@ enum UnionOperationPhase | |||
75 | 75 | ||
76 | /** | 76 | /** |
77 | * We sent the strata estimator, and expect an IBF. This phase is entered once | 77 | * We sent the strata estimator, and expect an IBF. This phase is entered once |
78 | * upon initialization and later via PHASE_EXPECT_ELEMENTS_AND_REQUESTS. | 78 | * upon initialization and later via #PHASE_EXPECT_ELEMENTS_AND_REQUESTS. |
79 | * | 79 | * |
80 | * After receiving the complete IBF, we enter PHASE_EXPECT_ELEMENTS | 80 | * After receiving the complete IBF, we enter #PHASE_EXPECT_ELEMENTS |
81 | */ | 81 | */ |
82 | PHASE_EXPECT_IBF, | 82 | PHASE_EXPECT_IBF, |
83 | 83 | ||
@@ -92,7 +92,7 @@ enum UnionOperationPhase | |||
92 | * | 92 | * |
93 | * We are currently decoding an IBF until it can no longer be decoded, | 93 | * We are currently decoding an IBF until it can no longer be decoded, |
94 | * we currently send requests and expect elements | 94 | * we currently send requests and expect elements |
95 | * The remote peer is in PHASE_EXPECT_ELEMENTS_AND_REQUESTS | 95 | * The remote peer is in #PHASE_EXPECT_ELEMENTS_AND_REQUESTS |
96 | */ | 96 | */ |
97 | PHASE_EXPECT_ELEMENTS, | 97 | PHASE_EXPECT_ELEMENTS, |
98 | 98 | ||
@@ -102,10 +102,10 @@ enum UnionOperationPhase | |||
102 | * | 102 | * |
103 | * We are in this phase if we have SENT an IBF for the remote peer to decode. | 103 | * We are in this phase if we have SENT an IBF for the remote peer to decode. |
104 | * We expect requests, send elements or could receive an new IBF, which takes | 104 | * We expect requests, send elements or could receive an new IBF, which takes |
105 | * us via PHASE_EXPECT_IBF to phase PHASE_EXPECT_ELEMENTS | 105 | * us via #PHASE_EXPECT_IBF to phase #PHASE_EXPECT_ELEMENTS |
106 | * | 106 | * |
107 | * The remote peer is thus in: | 107 | * The remote peer is thus in: |
108 | * PHASE_EXPECT_ELEMENTS | 108 | * #PHASE_EXPECT_ELEMENTS |
109 | */ | 109 | */ |
110 | PHASE_EXPECT_ELEMENTS_AND_REQUESTS, | 110 | PHASE_EXPECT_ELEMENTS_AND_REQUESTS, |
111 | 111 | ||
@@ -229,7 +229,8 @@ struct SetState | |||
229 | 229 | ||
230 | 230 | ||
231 | /** | 231 | /** |
232 | * Iterator over hash map entries. | 232 | * Iterator over hash map entries, called to |
233 | * destroy the linked list of colliding ibf key entries. | ||
233 | * | 234 | * |
234 | * @param cls closure | 235 | * @param cls closure |
235 | * @param key current key code | 236 | * @param key current key code |
@@ -244,7 +245,7 @@ destroy_key_to_element_iter (void *cls, | |||
244 | void *value) | 245 | void *value) |
245 | { | 246 | { |
246 | struct KeyEntry *k = value; | 247 | struct KeyEntry *k = value; |
247 | /* destroy the linked list of colliding ibf key entries */ | 248 | |
248 | while (NULL != k) | 249 | while (NULL != k) |
249 | { | 250 | { |
250 | struct KeyEntry *k_tmp = k; | 251 | struct KeyEntry *k_tmp = k; |
@@ -261,14 +262,16 @@ destroy_key_to_element_iter (void *cls, | |||
261 | 262 | ||
262 | 263 | ||
263 | /** | 264 | /** |
264 | * Destroy the union operation. Only things specific to the union operation are destroyed. | 265 | * Destroy the union operation. Only things specific to the union |
266 | * operation are destroyed. | ||
265 | * | 267 | * |
266 | * @param op union operation to destroy | 268 | * @param op union operation to destroy |
267 | */ | 269 | */ |
268 | static void | 270 | static void |
269 | union_op_cancel (struct Operation *op) | 271 | union_op_cancel (struct Operation *op) |
270 | { | 272 | { |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying union op\n"); | 273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
274 | "destroying union op\n"); | ||
272 | /* check if the op was canceled twice */ | 275 | /* check if the op was canceled twice */ |
273 | GNUNET_assert (NULL != op->state); | 276 | GNUNET_assert (NULL != op->state); |
274 | if (NULL != op->state->remote_ibf) | 277 | if (NULL != op->state->remote_ibf) |
@@ -288,13 +291,16 @@ union_op_cancel (struct Operation *op) | |||
288 | } | 291 | } |
289 | if (NULL != op->state->key_to_element) | 292 | if (NULL != op->state->key_to_element) |
290 | { | 293 | { |
291 | GNUNET_CONTAINER_multihashmap32_iterate (op->state->key_to_element, destroy_key_to_element_iter, NULL); | 294 | GNUNET_CONTAINER_multihashmap32_iterate (op->state->key_to_element, |
295 | &destroy_key_to_element_iter, | ||
296 | NULL); | ||
292 | GNUNET_CONTAINER_multihashmap32_destroy (op->state->key_to_element); | 297 | GNUNET_CONTAINER_multihashmap32_destroy (op->state->key_to_element); |
293 | op->state->key_to_element = NULL; | 298 | op->state->key_to_element = NULL; |
294 | } | 299 | } |
295 | GNUNET_free (op->state); | 300 | GNUNET_free (op->state); |
296 | op->state = NULL; | 301 | op->state = NULL; |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying union op done\n"); | 302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
303 | "destroying union op done\n"); | ||
298 | } | 304 | } |
299 | 305 | ||
300 | 306 | ||
@@ -330,7 +336,8 @@ fail_union_operation (struct Operation *op) | |||
330 | * @return the derived IBF key | 336 | * @return the derived IBF key |
331 | */ | 337 | */ |
332 | static struct IBF_Key | 338 | static struct IBF_Key |
333 | get_ibf_key (const struct GNUNET_HashCode *src, uint16_t salt) | 339 | get_ibf_key (const struct GNUNET_HashCode *src, |
340 | uint16_t salt) | ||
334 | { | 341 | { |
335 | struct IBF_Key key; | 342 | struct IBF_Key key; |
336 | 343 | ||
@@ -415,7 +422,8 @@ op_has_element_iterator (void *cls, | |||
415 | * @return #GNUNET_YES if the element has been found, #GNUNET_NO otherwise | 422 | * @return #GNUNET_YES if the element has been found, #GNUNET_NO otherwise |
416 | */ | 423 | */ |
417 | static int | 424 | static int |
418 | op_has_element (struct Operation *op, const struct GNUNET_HashCode *element_hash) | 425 | op_has_element (struct Operation *op, |
426 | const struct GNUNET_HashCode *element_hash) | ||
419 | { | 427 | { |
420 | int ret; | 428 | int ret; |
421 | struct IBF_Key ibf_key; | 429 | struct IBF_Key ibf_key; |
@@ -423,7 +431,8 @@ op_has_element (struct Operation *op, const struct GNUNET_HashCode *element_hash | |||
423 | ibf_key = get_ibf_key (element_hash, op->spec->salt); | 431 | ibf_key = get_ibf_key (element_hash, op->spec->salt); |
424 | ret = GNUNET_CONTAINER_multihashmap32_get_multiple (op->state->key_to_element, | 432 | ret = GNUNET_CONTAINER_multihashmap32_get_multiple (op->state->key_to_element, |
425 | (uint32_t) ibf_key.key_val, | 433 | (uint32_t) ibf_key.key_val, |
426 | op_has_element_iterator, (void *) element_hash); | 434 | op_has_element_iterator, |
435 | (void *) element_hash); | ||
427 | 436 | ||
428 | /* was the iteration aborted because we found the element? */ | 437 | /* was the iteration aborted because we found the element? */ |
429 | if (GNUNET_SYSERR == ret) | 438 | if (GNUNET_SYSERR == ret) |
@@ -457,13 +466,15 @@ op_register_element (struct Operation *op, | |||
457 | k->ibf_key = ibf_key; | 466 | k->ibf_key = ibf_key; |
458 | ret = GNUNET_CONTAINER_multihashmap32_get_multiple (op->state->key_to_element, | 467 | ret = GNUNET_CONTAINER_multihashmap32_get_multiple (op->state->key_to_element, |
459 | (uint32_t) ibf_key.key_val, | 468 | (uint32_t) ibf_key.key_val, |
460 | op_register_element_iterator, k); | 469 | op_register_element_iterator, |
470 | k); | ||
461 | 471 | ||
462 | /* was the element inserted into a colliding bucket? */ | 472 | /* was the element inserted into a colliding bucket? */ |
463 | if (GNUNET_SYSERR == ret) | 473 | if (GNUNET_SYSERR == ret) |
464 | return; | 474 | return; |
465 | 475 | GNUNET_CONTAINER_multihashmap32_put (op->state->key_to_element, | |
466 | GNUNET_CONTAINER_multihashmap32_put (op->state->key_to_element, (uint32_t) ibf_key.key_val, k, | 476 | (uint32_t) ibf_key.key_val, |
477 | k, | ||
467 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 478 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
468 | } | 479 | } |
469 | 480 | ||
@@ -483,8 +494,9 @@ prepare_ibf_iterator (void *cls, | |||
483 | struct InvertibleBloomFilter *ibf = cls; | 494 | struct InvertibleBloomFilter *ibf = cls; |
484 | struct KeyEntry *ke = value; | 495 | struct KeyEntry *ke = value; |
485 | 496 | ||
486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "inserting %x into ibf\n", ke->ibf_key.key_val); | 497 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
487 | 498 | "inserting %x into ibf\n", | |
499 | ke->ibf_key.key_val); | ||
488 | ibf_insert (ibf, ke->ibf_key); | 500 | ibf_insert (ibf, ke->ibf_key); |
489 | return GNUNET_YES; | 501 | return GNUNET_YES; |
490 | } | 502 | } |
@@ -563,7 +575,9 @@ send_ibf (struct Operation *op, uint16_t ibf_order) | |||
563 | 575 | ||
564 | prepare_ibf (op, 1<<ibf_order); | 576 | prepare_ibf (op, 1<<ibf_order); |
565 | 577 | ||
566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending ibf of size %u\n", 1<<ibf_order); | 578 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
579 | "sending ibf of size %u\n", | ||
580 | 1<<ibf_order); | ||
567 | 581 | ||
568 | ibf = op->state->local_ibf; | 582 | ibf = op->state->local_ibf; |
569 | 583 | ||
@@ -586,8 +600,11 @@ send_ibf (struct Operation *op, uint16_t ibf_order) | |||
586 | ibf_write_slice (ibf, buckets_sent, | 600 | ibf_write_slice (ibf, buckets_sent, |
587 | buckets_in_message, &msg[1]); | 601 | buckets_in_message, &msg[1]); |
588 | buckets_sent += buckets_in_message; | 602 | buckets_sent += buckets_in_message; |
589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ibf chunk size %u, %u/%u sent\n", | 603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
590 | buckets_in_message, buckets_sent, 1<<ibf_order); | 604 | "ibf chunk size %u, %u/%u sent\n", |
605 | buckets_in_message, | ||
606 | buckets_sent, | ||
607 | 1<<ibf_order); | ||
591 | GNUNET_MQ_send (op->mq, ev); | 608 | GNUNET_MQ_send (op->mq, ev); |
592 | } | 609 | } |
593 | 610 | ||
@@ -612,7 +629,8 @@ send_strata_estimator (struct Operation *op) | |||
612 | strata_estimator_write (op->state->se, &strata_msg[1]); | 629 | strata_estimator_write (op->state->se, &strata_msg[1]); |
613 | GNUNET_MQ_send (op->mq, ev); | 630 | GNUNET_MQ_send (op->mq, ev); |
614 | op->state->phase = PHASE_EXPECT_IBF; | 631 | op->state->phase = PHASE_EXPECT_IBF; |
615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent SE, expecting IBF\n"); | 632 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
633 | "sent SE, expecting IBF\n"); | ||
616 | } | 634 | } |
617 | 635 | ||
618 | 636 | ||
@@ -664,9 +682,12 @@ handle_p2p_strata_estimator (void *cls, const struct GNUNET_MessageHeader *mh) | |||
664 | strata_estimator_destroy (remote_se); | 682 | strata_estimator_destroy (remote_se); |
665 | strata_estimator_destroy (op->state->se); | 683 | strata_estimator_destroy (op->state->se); |
666 | op->state->se = NULL; | 684 | op->state->se = NULL; |
667 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got se diff=%d, using ibf size %d\n", | 685 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
668 | diff, 1<<get_order_from_difference (diff)); | 686 | "got se diff=%d, using ibf size %d\n", |
669 | send_ibf (op, get_order_from_difference (diff)); | 687 | diff, |
688 | 1<<get_order_from_difference (diff)); | ||
689 | send_ibf (op, | ||
690 | get_order_from_difference (diff)); | ||
670 | } | 691 | } |
671 | 692 | ||
672 | 693 | ||
@@ -697,15 +718,20 @@ send_element_iterator (void *cls, | |||
697 | struct GNUNET_MessageHeader *mh; | 718 | struct GNUNET_MessageHeader *mh; |
698 | 719 | ||
699 | GNUNET_assert (ke->ibf_key.key_val == ibf_key.key_val); | 720 | GNUNET_assert (ke->ibf_key.key_val == ibf_key.key_val); |
700 | ev = GNUNET_MQ_msg_header_extra (mh, element->size, GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS); | 721 | ev = GNUNET_MQ_msg_header_extra (mh, |
722 | element->size, | ||
723 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS); | ||
701 | if (NULL == ev) | 724 | if (NULL == ev) |
702 | { | 725 | { |
703 | /* element too large */ | 726 | /* element too large */ |
704 | GNUNET_break (0); | 727 | GNUNET_break (0); |
705 | continue; | 728 | continue; |
706 | } | 729 | } |
707 | memcpy (&mh[1], element->data, element->size); | 730 | memcpy (&mh[1], |
708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element (%s) to peer\n", | 731 | element->data, |
732 | element->size); | ||
733 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
734 | "sending element (%s) to peer\n", | ||
709 | GNUNET_h2s (&ke->element->element_hash)); | 735 | GNUNET_h2s (&ke->element->element_hash)); |
710 | GNUNET_MQ_send (op->mq, ev); | 736 | GNUNET_MQ_send (op->mq, ev); |
711 | ke = ke->next_colliding; | 737 | ke = ke->next_colliding; |
@@ -713,6 +739,7 @@ send_element_iterator (void *cls, | |||
713 | return GNUNET_NO; | 739 | return GNUNET_NO; |
714 | } | 740 | } |
715 | 741 | ||
742 | |||
716 | /** | 743 | /** |
717 | * Send all elements that have the specified IBF key | 744 | * Send all elements that have the specified IBF key |
718 | * to the remote peer of the union operation | 745 | * to the remote peer of the union operation |
@@ -757,7 +784,9 @@ decode_and_send (struct Operation *op) | |||
757 | ibf_destroy (op->state->remote_ibf); | 784 | ibf_destroy (op->state->remote_ibf); |
758 | op->state->remote_ibf = NULL; | 785 | op->state->remote_ibf = NULL; |
759 | 786 | ||
760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "decoding IBF (size=%u)\n", diff_ibf->size); | 787 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
788 | "decoding IBF (size=%u)\n", | ||
789 | diff_ibf->size); | ||
761 | 790 | ||
762 | num_decoded = 0; | 791 | num_decoded = 0; |
763 | last_key.key_val = 0; | 792 | last_key.key_val = 0; |
@@ -772,17 +801,22 @@ decode_and_send (struct Operation *op) | |||
772 | res = ibf_decode (diff_ibf, &side, &key); | 801 | res = ibf_decode (diff_ibf, &side, &key); |
773 | if (res == GNUNET_OK) | 802 | if (res == GNUNET_OK) |
774 | { | 803 | { |
775 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "decoded ibf key %lx\n", | 804 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
805 | "decoded ibf key %lx\n", | ||
776 | key.key_val); | 806 | key.key_val); |
777 | num_decoded += 1; | 807 | num_decoded += 1; |
778 | if (num_decoded > diff_ibf->size || (num_decoded > 1 && last_key.key_val == key.key_val)) | 808 | if ( (num_decoded > diff_ibf->size) || |
809 | (num_decoded > 1 && last_key.key_val == key.key_val) ) | ||
779 | { | 810 | { |
780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "detected cyclic ibf (decoded %u/%u)\n", | 811 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
781 | num_decoded, diff_ibf->size); | 812 | "detected cyclic ibf (decoded %u/%u)\n", |
813 | num_decoded, | ||
814 | diff_ibf->size); | ||
782 | cycle_detected = GNUNET_YES; | 815 | cycle_detected = GNUNET_YES; |
783 | } | 816 | } |
784 | } | 817 | } |
785 | if ((GNUNET_SYSERR == res) || (GNUNET_YES == cycle_detected)) | 818 | if ( (GNUNET_SYSERR == res) || |
819 | (GNUNET_YES == cycle_detected) ) | ||
786 | { | 820 | { |
787 | int next_order; | 821 | int next_order; |
788 | next_order = 0; | 822 | next_order = 0; |
@@ -807,7 +841,8 @@ decode_and_send (struct Operation *op) | |||
807 | { | 841 | { |
808 | struct GNUNET_MQ_Envelope *ev; | 842 | struct GNUNET_MQ_Envelope *ev; |
809 | 843 | ||
810 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transmitted all values, sending DONE\n"); | 844 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
845 | "transmitted all values, sending DONE\n"); | ||
811 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_P2P_DONE); | 846 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_P2P_DONE); |
812 | GNUNET_MQ_send (op->mq, ev); | 847 | GNUNET_MQ_send (op->mq, ev); |
813 | break; | 848 | break; |
@@ -827,7 +862,8 @@ decode_and_send (struct Operation *op) | |||
827 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS); | 862 | GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS); |
828 | 863 | ||
829 | *(struct IBF_Key *) &msg[1] = key; | 864 | *(struct IBF_Key *) &msg[1] = key; |
830 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element request\n"); | 865 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
866 | "sending element request\n"); | ||
831 | GNUNET_MQ_send (op->mq, ev); | 867 | GNUNET_MQ_send (op->mq, ev); |
832 | } | 868 | } |
833 | else | 869 | else |
@@ -857,7 +893,9 @@ handle_p2p_ibf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
857 | { | 893 | { |
858 | op->state->phase = PHASE_EXPECT_IBF_CONT; | 894 | op->state->phase = PHASE_EXPECT_IBF_CONT; |
859 | GNUNET_assert (NULL == op->state->remote_ibf); | 895 | GNUNET_assert (NULL == op->state->remote_ibf); |
860 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "creating new ibf of size %u\n", 1<<msg->order); | 896 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
897 | "creating new ibf of size %u\n", | ||
898 | 1<<msg->order); | ||
861 | op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM); | 899 | op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM); |
862 | op->state->ibf_buckets_received = 0; | 900 | op->state->ibf_buckets_received = 0; |
863 | if (0 != ntohs (msg->offset)) | 901 | if (0 != ntohs (msg->offset)) |
@@ -894,12 +932,16 @@ handle_p2p_ibf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
894 | return; | 932 | return; |
895 | } | 933 | } |
896 | 934 | ||
897 | ibf_read_slice (&msg[1], op->state->ibf_buckets_received, buckets_in_message, op->state->remote_ibf); | 935 | ibf_read_slice (&msg[1], |
936 | op->state->ibf_buckets_received, | ||
937 | buckets_in_message, | ||
938 | op->state->remote_ibf); | ||
898 | op->state->ibf_buckets_received += buckets_in_message; | 939 | op->state->ibf_buckets_received += buckets_in_message; |
899 | 940 | ||
900 | if (op->state->ibf_buckets_received == op->state->remote_ibf->size) | 941 | if (op->state->ibf_buckets_received == op->state->remote_ibf->size) |
901 | { | 942 | { |
902 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received full ibf\n"); | 943 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
944 | "received full ibf\n"); | ||
903 | op->state->phase = PHASE_EXPECT_ELEMENTS; | 945 | op->state->phase = PHASE_EXPECT_ELEMENTS; |
904 | decode_and_send (op); | 946 | decode_and_send (op); |
905 | } | 947 | } |
@@ -920,7 +962,9 @@ send_client_element (struct Operation *op, | |||
920 | struct GNUNET_MQ_Envelope *ev; | 962 | struct GNUNET_MQ_Envelope *ev; |
921 | struct GNUNET_SET_ResultMessage *rm; | 963 | struct GNUNET_SET_ResultMessage *rm; |
922 | 964 | ||
923 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element (size %u) to client\n", element->size); | 965 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
966 | "sending element (size %u) to client\n", | ||
967 | element->size); | ||
924 | GNUNET_assert (0 != op->spec->client_request_id); | 968 | GNUNET_assert (0 != op->spec->client_request_id); |
925 | ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); | 969 | ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); |
926 | if (NULL == ev) | 970 | if (NULL == ev) |
@@ -974,16 +1018,18 @@ send_remaining_elements (void *cls) | |||
974 | struct KeyEntry *ke; | 1018 | struct KeyEntry *ke; |
975 | int res; | 1019 | int res; |
976 | 1020 | ||
977 | res = GNUNET_CONTAINER_multihashmap32_iterator_next (op->state->full_result_iter, NULL, (const void **) &ke); | 1021 | res = GNUNET_CONTAINER_multihashmap32_iterator_next (op->state->full_result_iter, |
1022 | NULL, | ||
1023 | (const void **) &ke); | ||
978 | if (GNUNET_NO == res) | 1024 | if (GNUNET_NO == res) |
979 | { | 1025 | { |
980 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending done and destroy because iterator ran out\n"); | 1026 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1027 | "sending done and destroy because iterator ran out\n"); | ||
981 | send_done_and_destroy (op); | 1028 | send_done_and_destroy (op); |
982 | return; | 1029 | return; |
983 | } | 1030 | } |
984 | 1031 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending elements from key entry\n"); | 1032 | "sending elements from key entry\n"); |
986 | |||
987 | while (1) | 1033 | while (1) |
988 | { | 1034 | { |
989 | struct GNUNET_MQ_Envelope *ev; | 1035 | struct GNUNET_MQ_Envelope *ev; |
@@ -991,7 +1037,9 @@ send_remaining_elements (void *cls) | |||
991 | struct GNUNET_SET_Element *element; | 1037 | struct GNUNET_SET_Element *element; |
992 | element = &ke->element->element; | 1038 | element = &ke->element->element; |
993 | 1039 | ||
994 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element (size %u) to client (full set)\n", element->size); | 1040 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1041 | "sending element (size %u) to client (full set)\n", | ||
1042 | element->size); | ||
995 | GNUNET_assert (0 != op->spec->client_request_id); | 1043 | GNUNET_assert (0 != op->spec->client_request_id); |
996 | ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); | 1044 | ev = GNUNET_MQ_msg_extra (rm, element->size, GNUNET_MESSAGE_TYPE_SET_RESULT); |
997 | if (NULL == ev) | 1045 | if (NULL == ev) |
@@ -1004,7 +1052,7 @@ send_remaining_elements (void *cls) | |||
1004 | rm->request_id = htonl (op->spec->client_request_id); | 1052 | rm->request_id = htonl (op->spec->client_request_id); |
1005 | rm->element_type = element->element_type; | 1053 | rm->element_type = element->element_type; |
1006 | memcpy (&rm[1], element->data, element->size); | 1054 | memcpy (&rm[1], element->data, element->size); |
1007 | if (ke->next_colliding == NULL) | 1055 | if (NULL == ke->next_colliding) |
1008 | { | 1056 | { |
1009 | GNUNET_MQ_notify_sent (ev, send_remaining_elements, op); | 1057 | GNUNET_MQ_notify_sent (ev, send_remaining_elements, op); |
1010 | GNUNET_MQ_send (op->spec->set->client_mq, ev); | 1058 | GNUNET_MQ_send (op->spec->set->client_mq, ev); |
@@ -1033,7 +1081,8 @@ finish_and_destroy (struct Operation *op) | |||
1033 | { | 1081 | { |
1034 | /* prevent that the op is free'd by the tunnel end handler */ | 1082 | /* prevent that the op is free'd by the tunnel end handler */ |
1035 | op->keep = GNUNET_YES; | 1083 | op->keep = GNUNET_YES; |
1036 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending full result set\n"); | 1084 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1085 | "sending full result set\n"); | ||
1037 | GNUNET_assert (NULL == op->state->full_result_iter); | 1086 | GNUNET_assert (NULL == op->state->full_result_iter); |
1038 | op->state->full_result_iter = | 1087 | op->state->full_result_iter = |
1039 | GNUNET_CONTAINER_multihashmap32_iterator_create (op->state->key_to_element); | 1088 | GNUNET_CONTAINER_multihashmap32_iterator_create (op->state->key_to_element); |
@@ -1051,7 +1100,8 @@ finish_and_destroy (struct Operation *op) | |||
1051 | * @param mh the message | 1100 | * @param mh the message |
1052 | */ | 1101 | */ |
1053 | static void | 1102 | static void |
1054 | handle_p2p_elements (void *cls, const struct GNUNET_MessageHeader *mh) | 1103 | handle_p2p_elements (void *cls, |
1104 | const struct GNUNET_MessageHeader *mh) | ||
1055 | { | 1105 | { |
1056 | struct Operation *op = cls; | 1106 | struct Operation *op = cls; |
1057 | struct ElementEntry *ee; | 1107 | struct ElementEntry *ee; |
@@ -1148,7 +1198,8 @@ handle_p2p_done (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1148 | { | 1198 | { |
1149 | /* we got all requests, but still have to send our elements as response */ | 1199 | /* we got all requests, but still have to send our elements as response */ |
1150 | 1200 | ||
1151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got DONE, sending final DONE after elements\n"); | 1201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1202 | "got DONE, sending final DONE after elements\n"); | ||
1152 | op->state->phase = PHASE_FINISHED; | 1203 | op->state->phase = PHASE_FINISHED; |
1153 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_P2P_DONE); | 1204 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_P2P_DONE); |
1154 | GNUNET_MQ_send (op->mq, ev); | 1205 | GNUNET_MQ_send (op->mq, ev); |
@@ -1156,7 +1207,8 @@ handle_p2p_done (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1156 | } | 1207 | } |
1157 | if (op->state->phase == PHASE_EXPECT_ELEMENTS) | 1208 | if (op->state->phase == PHASE_EXPECT_ELEMENTS) |
1158 | { | 1209 | { |
1159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got final DONE\n"); | 1210 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1211 | "got final DONE\n"); | ||
1160 | op->state->phase = PHASE_FINISHED; | 1212 | op->state->phase = PHASE_FINISHED; |
1161 | finish_and_destroy (op); | 1213 | finish_and_destroy (op); |
1162 | return; | 1214 | return; |
@@ -1220,7 +1272,8 @@ union_evaluate (struct Operation *op, | |||
1220 | static void | 1272 | static void |
1221 | union_accept (struct Operation *op) | 1273 | union_accept (struct Operation *op) |
1222 | { | 1274 | { |
1223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "accepting set union operation\n"); | 1275 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1276 | "accepting set union operation\n"); | ||
1224 | op->state = GNUNET_new (struct OperationState); | 1277 | op->state = GNUNET_new (struct OperationState); |
1225 | op->state->se = strata_estimator_dup (op->spec->set->state->se); | 1278 | op->state->se = strata_estimator_dup (op->spec->set->state->se); |
1226 | /* kick off the operation */ | 1279 | /* kick off the operation */ |
@@ -1241,11 +1294,11 @@ union_set_create (void) | |||
1241 | { | 1294 | { |
1242 | struct SetState *set_state; | 1295 | struct SetState *set_state; |
1243 | 1296 | ||
1244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "union set created\n"); | 1297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1245 | 1298 | "union set created\n"); | |
1246 | set_state = GNUNET_new (struct SetState); | 1299 | set_state = GNUNET_new (struct SetState); |
1247 | set_state->se = strata_estimator_create (SE_STRATA_COUNT, | 1300 | set_state->se = strata_estimator_create (SE_STRATA_COUNT, |
1248 | SE_IBF_SIZE, SE_IBF_HASH_NUM); | 1301 | SE_IBF_SIZE, SE_IBF_HASH_NUM); |
1249 | return set_state; | 1302 | return set_state; |
1250 | } | 1303 | } |
1251 | 1304 | ||
@@ -1259,7 +1312,8 @@ union_set_create (void) | |||
1259 | static void | 1312 | static void |
1260 | union_add (struct SetState *set_state, struct ElementEntry *ee) | 1313 | union_add (struct SetState *set_state, struct ElementEntry *ee) |
1261 | { | 1314 | { |
1262 | strata_estimator_insert (set_state->se, get_ibf_key (&ee->element_hash, 0)); | 1315 | strata_estimator_insert (set_state->se, |
1316 | get_ibf_key (&ee->element_hash, 0)); | ||
1263 | } | 1317 | } |
1264 | 1318 | ||
1265 | 1319 | ||
@@ -1273,7 +1327,8 @@ union_add (struct SetState *set_state, struct ElementEntry *ee) | |||
1273 | static void | 1327 | static void |
1274 | union_remove (struct SetState *set_state, struct ElementEntry *ee) | 1328 | union_remove (struct SetState *set_state, struct ElementEntry *ee) |
1275 | { | 1329 | { |
1276 | strata_estimator_remove (set_state->se, get_ibf_key (&ee->element_hash, 0)); | 1330 | strata_estimator_remove (set_state->se, |
1331 | get_ibf_key (&ee->element_hash, 0)); | ||
1277 | } | 1332 | } |
1278 | 1333 | ||
1279 | 1334 | ||
@@ -1306,8 +1361,10 @@ int | |||
1306 | union_handle_p2p_message (struct Operation *op, | 1361 | union_handle_p2p_message (struct Operation *op, |
1307 | const struct GNUNET_MessageHeader *mh) | 1362 | const struct GNUNET_MessageHeader *mh) |
1308 | { | 1363 | { |
1309 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received p2p message (t: %u, s: %u)\n", | 1364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1310 | ntohs (mh->type), ntohs (mh->size)); | 1365 | "received p2p message (t: %u, s: %u)\n", |
1366 | ntohs (mh->type), | ||
1367 | ntohs (mh->size)); | ||
1311 | switch (ntohs (mh->type)) | 1368 | switch (ntohs (mh->type)) |
1312 | { | 1369 | { |
1313 | case GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF: | 1370 | case GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF: |
@@ -1357,7 +1414,8 @@ union_peer_disconnect (struct Operation *op) | |||
1357 | return; | 1414 | return; |
1358 | } | 1415 | } |
1359 | // else: the session has already been concluded | 1416 | // else: the session has already been concluded |
1360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "other peer disconnected (finished)\n"); | 1417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1418 | "other peer disconnected (finished)\n"); | ||
1361 | if (GNUNET_NO == op->state->client_done_sent) | 1419 | if (GNUNET_NO == op->state->client_done_sent) |
1362 | finish_and_destroy (op); | 1420 | finish_and_destroy (op); |
1363 | } | 1421 | } |