diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-21 15:39:26 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-21 15:39:26 +0000 |
commit | c1c4555e6aa0a4bfcbd3b8991587609ccdd7a1f4 (patch) | |
tree | 7b38f711cc90681cc269f109110f97f89573a00a /src/set | |
parent | 562b01056819a14344476553d1e8a0c32412b977 (diff) | |
download | gnunet-c1c4555e6aa0a4bfcbd3b8991587609ccdd7a1f4.tar.gz gnunet-c1c4555e6aa0a4bfcbd3b8991587609ccdd7a1f4.zip |
more work on set,
commented out the intersection-change in set.c as the relevant code is not yet done
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set.c | 2 | ||||
-rw-r--r-- | src/set/gnunet-service-set_intersection.c | 162 |
2 files changed, 74 insertions, 90 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index a5f132b41..6020076ec 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -583,7 +583,7 @@ handle_client_create (void *cls, | |||
583 | switch (ntohs (msg->operation)) | 583 | switch (ntohs (msg->operation)) |
584 | { | 584 | { |
585 | case GNUNET_SET_OPERATION_INTERSECTION: | 585 | case GNUNET_SET_OPERATION_INTERSECTION: |
586 | set->vt = _GSS_intersection_vt (); | 586 | // set->vt = _GSS_intersection_vt (); |
587 | break; | 587 | break; |
588 | case GNUNET_SET_OPERATION_UNION: | 588 | case GNUNET_SET_OPERATION_UNION: |
589 | set->vt = _GSS_union_vt (); | 589 | set->vt = _GSS_union_vt (); |
diff --git a/src/set/gnunet-service-set_intersection.c b/src/set/gnunet-service-set_intersection.c index 7e8bd9cbf..a1bc550f6 100644 --- a/src/set/gnunet-service-set_intersection.c +++ b/src/set/gnunet-service-set_intersection.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet-service-set.h" | 28 | #include "gnunet-service-set.h" |
29 | #include "ibf.h" | ||
30 | #include "strata_estimator.h" | 29 | #include "strata_estimator.h" |
31 | #include "set_protocol.h" | 30 | #include "set_protocol.h" |
32 | #include <gcrypt.h> | 31 | #include <gcrypt.h> |
@@ -65,33 +64,18 @@ | |||
65 | 64 | ||
66 | 65 | ||
67 | /** | 66 | /** |
68 | * Current phase we are in for a union operation. | 67 | * Current phase we are in for a intersection operation. |
69 | */ | 68 | */ |
70 | enum IntersectionOperationPhase | 69 | enum IntersectionOperationPhase |
71 | { | 70 | { |
72 | /** | 71 | /** |
73 | * We sent the request message, and expect a strata estimator | 72 | * We sent the request message, and expect a BF |
74 | */ | 73 | */ |
75 | PHASE_EXPECT_SE, | 74 | PHASE_EXPECT_INITIAL, |
76 | /** | 75 | /** |
77 | * We sent the strata estimator, and expect an IBF | 76 | * We sent the request message, and expect a BF |
78 | */ | 77 | */ |
79 | PHASE_EXPECT_IBF, | 78 | PHASE_EXPECT_BF, |
80 | /** | ||
81 | * We know what type of IBF the other peer wants to send us, | ||
82 | * and expect the remaining parts | ||
83 | */ | ||
84 | PHASE_EXPECT_IBF_CONT, | ||
85 | /** | ||
86 | * We are sending request and elements, | ||
87 | * and thus only expect elements from the other peer. | ||
88 | */ | ||
89 | PHASE_EXPECT_ELEMENTS, | ||
90 | /** | ||
91 | * We are expecting elements and requests, and send | ||
92 | * requested elements back to the other peer. | ||
93 | */ | ||
94 | PHASE_EXPECT_ELEMENTS_AND_REQUESTS, | ||
95 | /** | 79 | /** |
96 | * The protocol is over. | 80 | * The protocol is over. |
97 | * Results may still have to be sent to the client. | 81 | * Results may still have to be sent to the client. |
@@ -231,7 +215,7 @@ struct SendElementClosure | |||
231 | 215 | ||
232 | 216 | ||
233 | /** | 217 | /** |
234 | * Extra state required for efficient set union. | 218 | * Extra state required for efficient set intersection. |
235 | */ | 219 | */ |
236 | struct SetState | 220 | struct SetState |
237 | { | 221 | { |
@@ -290,15 +274,15 @@ destroy_key_to_element_iter (void *cls, | |||
290 | 274 | ||
291 | 275 | ||
292 | /** | 276 | /** |
293 | * Destroy a union operation, and free all resources | 277 | * Destroy a intersection operation, and free all resources |
294 | * associated with it. | 278 | * associated with it. |
295 | * | 279 | * |
296 | * @param eo the union operation to destroy | 280 | * @param eo the intersection operation to destroy |
297 | */ | 281 | */ |
298 | static void | 282 | static void |
299 | intersection_operation_destroy (struct OperationState *eo) | 283 | intersection_operation_destroy (struct OperationState *eo) |
300 | { | 284 | { |
301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying union op\n"); | 285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying intersection op\n"); |
302 | GNUNET_CONTAINER_DLL_remove (eo->set->state->ops_head, | 286 | GNUNET_CONTAINER_DLL_remove (eo->set->state->ops_head, |
303 | eo->set->state->ops_tail, | 287 | eo->set->state->ops_tail, |
304 | eo); | 288 | eo); |
@@ -346,17 +330,17 @@ intersection_operation_destroy (struct OperationState *eo) | |||
346 | } | 330 | } |
347 | GNUNET_free (eo); | 331 | GNUNET_free (eo); |
348 | 332 | ||
349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying union op done\n"); | 333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying intersection op done\n"); |
350 | 334 | ||
351 | /* FIXME: do a garbage collection of the set generations */ | 335 | /* FIXME: do a garbage collection of the set generations */ |
352 | } | 336 | } |
353 | 337 | ||
354 | 338 | ||
355 | /** | 339 | /** |
356 | * Inform the client that the union operation has failed, | 340 | * Inform the client that the intersection operation has failed, |
357 | * and proceed to destroy the evaluate operation. | 341 | * and proceed to destroy the evaluate operation. |
358 | * | 342 | * |
359 | * @param eo the union operation to fail | 343 | * @param eo the intersection operation to fail |
360 | */ | 344 | */ |
361 | static void | 345 | static void |
362 | fail_intersection_operation (struct OperationState *eo) | 346 | fail_intersection_operation (struct OperationState *eo) |
@@ -369,7 +353,7 @@ fail_intersection_operation (struct OperationState *eo) | |||
369 | msg->request_id = htonl (eo->spec->client_request_id); | 353 | msg->request_id = htonl (eo->spec->client_request_id); |
370 | msg->element_type = htons (0); | 354 | msg->element_type = htons (0); |
371 | GNUNET_MQ_send (eo->spec->set->client_mq, ev); | 355 | GNUNET_MQ_send (eo->spec->set->client_mq, ev); |
372 | union_operation_destroy (eo); | 356 | intersection_operation_destroy (eo); |
373 | } | 357 | } |
374 | 358 | ||
375 | 359 | ||
@@ -470,14 +454,14 @@ op_register_element_iterator (void *cls, | |||
470 | 454 | ||
471 | 455 | ||
472 | /** | 456 | /** |
473 | * Insert an element into the union operation's | 457 | * Insert an element into the intersection operation's |
474 | * key-to-element mapping. Takes ownership of 'ee'. | 458 | * key-to-element mapping. Takes ownership of 'ee'. |
475 | * Note that this does not insert the element in the set, | 459 | * Note that this does not insert the element in the set, |
476 | * only in the operation's key-element mapping. | 460 | * only in the operation's key-element mapping. |
477 | * This is done to speed up re-tried operations, if some elements | 461 | * This is done to speed up re-tried operations, if some elements |
478 | * were transmitted, and then the IBF fails to decode. | 462 | * were transmitted, and then the IBF fails to decode. |
479 | * | 463 | * |
480 | * @param eo the union operation | 464 | * @param eo the intersection operation |
481 | * @param ee the element entry | 465 | * @param ee the element entry |
482 | */ | 466 | */ |
483 | static void | 467 | static void |
@@ -528,9 +512,9 @@ prepare_ibf_iterator (void *cls, | |||
528 | 512 | ||
529 | /** | 513 | /** |
530 | * Iterator for initializing the | 514 | * Iterator for initializing the |
531 | * key-to-element mapping of a union operation | 515 | * key-to-element mapping of a intersection operation |
532 | * | 516 | * |
533 | * @param cls the union operation | 517 | * @param cls the intersection operation |
534 | * @param key unised | 518 | * @param key unised |
535 | * @param value the element entry to insert | 519 | * @param value the element entry to insert |
536 | * into the key-to-element mapping | 520 | * into the key-to-element mapping |
@@ -563,7 +547,7 @@ init_key_to_element_iterator (void *cls, | |||
563 | * Create an ibf with the operation's elements | 547 | * Create an ibf with the operation's elements |
564 | * of the specified size | 548 | * of the specified size |
565 | * | 549 | * |
566 | * @param eo the union operation | 550 | * @param eo the intersection operation |
567 | * @param size size of the ibf to create | 551 | * @param size size of the ibf to create |
568 | */ | 552 | */ |
569 | static void | 553 | static void |
@@ -588,7 +572,7 @@ prepare_ibf (struct OperationState *eo, uint16_t size) | |||
588 | /** | 572 | /** |
589 | * Send an ibf of appropriate size. | 573 | * Send an ibf of appropriate size. |
590 | * | 574 | * |
591 | * @param eo the union operation | 575 | * @param eo the intersection operation |
592 | * @param ibf_order order of the ibf to send, size=2^order | 576 | * @param ibf_order order of the ibf to send, size=2^order |
593 | */ | 577 | */ |
594 | static void | 578 | static void |
@@ -634,7 +618,7 @@ send_ibf (struct OperationState *eo, uint16_t ibf_order) | |||
634 | /** | 618 | /** |
635 | * Send a strata estimator to the remote peer. | 619 | * Send a strata estimator to the remote peer. |
636 | * | 620 | * |
637 | * @param eo the union operation with the remote peer | 621 | * @param eo the intersection operation with the remote peer |
638 | */ | 622 | */ |
639 | static void | 623 | static void |
640 | send_strata_estimator (struct OperationState *eo) | 624 | send_strata_estimator (struct OperationState *eo) |
@@ -647,7 +631,7 @@ send_strata_estimator (struct OperationState *eo) | |||
647 | GNUNET_MESSAGE_TYPE_SET_P2P_SE); | 631 | GNUNET_MESSAGE_TYPE_SET_P2P_SE); |
648 | strata_estimator_write (eo->set->state->se, &strata_msg[1]); | 632 | strata_estimator_write (eo->set->state->se, &strata_msg[1]); |
649 | GNUNET_MQ_send (eo->mq, ev); | 633 | GNUNET_MQ_send (eo->mq, ev); |
650 | eo->phase = PHASE_EXPECT_IBF; | 634 | eo->phase = PHASE_EXPECT_BF; |
651 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent SE, expecting IBF\n"); | 635 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent SE, expecting IBF\n"); |
652 | } | 636 | } |
653 | 637 | ||
@@ -676,7 +660,7 @@ get_order_from_difference (unsigned int diff) | |||
676 | /** | 660 | /** |
677 | * Handle a strata estimator from a remote peer | 661 | * Handle a strata estimator from a remote peer |
678 | * | 662 | * |
679 | * @param cls the union operation | 663 | * @param cls the intersection operation |
680 | * @param mh the message | 664 | * @param mh the message |
681 | */ | 665 | */ |
682 | static void | 666 | static void |
@@ -688,7 +672,7 @@ handle_p2p_strata_estimator (void *cls, const struct GNUNET_MessageHeader *mh) | |||
688 | 672 | ||
689 | if (eo->phase != PHASE_EXPECT_SE) | 673 | if (eo->phase != PHASE_EXPECT_SE) |
690 | { | 674 | { |
691 | fail_union_operation (eo); | 675 | fail_intersection_operation (eo); |
692 | GNUNET_break (0); | 676 | GNUNET_break (0); |
693 | return; | 677 | return; |
694 | } | 678 | } |
@@ -710,7 +694,7 @@ handle_p2p_strata_estimator (void *cls, const struct GNUNET_MessageHeader *mh) | |||
710 | /** | 694 | /** |
711 | * Iterator to send elements to a remote peer | 695 | * Iterator to send elements to a remote peer |
712 | * | 696 | * |
713 | * @param cls closure with the element key and the union operation | 697 | * @param cls closure with the element key and the intersection operation |
714 | * @param key ignored | 698 | * @param key ignored |
715 | * @param value the key entry | 699 | * @param value the key entry |
716 | */ | 700 | */ |
@@ -751,9 +735,9 @@ send_element_iterator (void *cls, | |||
751 | 735 | ||
752 | /** | 736 | /** |
753 | * Send all elements that have the specified IBF key | 737 | * Send all elements that have the specified IBF key |
754 | * to the remote peer of the union operation | 738 | * to the remote peer of the intersection operation |
755 | * | 739 | * |
756 | * @param eo union operation | 740 | * @param eo intersection operation |
757 | * @param ibf_key IBF key of interest | 741 | * @param ibf_key IBF key of interest |
758 | */ | 742 | */ |
759 | static void | 743 | static void |
@@ -772,7 +756,7 @@ send_elements_for_key (struct OperationState *eo, struct IBF_Key ibf_key) | |||
772 | * Decode which elements are missing on each side, and | 756 | * Decode which elements are missing on each side, and |
773 | * send the appropriate elemens and requests | 757 | * send the appropriate elemens and requests |
774 | * | 758 | * |
775 | * @param eo union operation | 759 | * @param eo intersection operation |
776 | */ | 760 | */ |
777 | static void | 761 | static void |
778 | decode_and_send (struct OperationState *eo) | 762 | decode_and_send (struct OperationState *eo) |
@@ -834,7 +818,7 @@ decode_and_send (struct OperationState *eo) | |||
834 | else | 818 | else |
835 | { | 819 | { |
836 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 820 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
837 | "set union failed: reached ibf limit\n"); | 821 | "set intersection failed: reached ibf limit\n"); |
838 | } | 822 | } |
839 | break; | 823 | break; |
840 | } | 824 | } |
@@ -879,7 +863,7 @@ decode_and_send (struct OperationState *eo) | |||
879 | /** | 863 | /** |
880 | * Handle an IBF message from a remote peer. | 864 | * Handle an IBF message from a remote peer. |
881 | * | 865 | * |
882 | * @param cls the union operation | 866 | * @param cls the intersection operation |
883 | * @param mh the header of the message | 867 | * @param mh the header of the message |
884 | */ | 868 | */ |
885 | static void | 869 | static void |
@@ -890,9 +874,9 @@ handle_p2p_ibf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
890 | unsigned int buckets_in_message; | 874 | unsigned int buckets_in_message; |
891 | 875 | ||
892 | if ( (eo->phase == PHASE_EXPECT_ELEMENTS_AND_REQUESTS) || | 876 | if ( (eo->phase == PHASE_EXPECT_ELEMENTS_AND_REQUESTS) || |
893 | (eo->phase == PHASE_EXPECT_IBF) ) | 877 | (eo->phase == PHASE_EXPECT_BF) ) |
894 | { | 878 | { |
895 | eo->phase = PHASE_EXPECT_IBF_CONT; | 879 | eo->phase = PHASE_EXPECT_BF_CONT; |
896 | GNUNET_assert (NULL == eo->remote_ibf); | 880 | GNUNET_assert (NULL == eo->remote_ibf); |
897 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "creating new ibf of size %u\n", 1<<msg->order); | 881 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "creating new ibf of size %u\n", 1<<msg->order); |
898 | eo->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM); | 882 | eo->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM); |
@@ -900,17 +884,17 @@ handle_p2p_ibf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
900 | if (0 != ntohs (msg->offset)) | 884 | if (0 != ntohs (msg->offset)) |
901 | { | 885 | { |
902 | GNUNET_break (0); | 886 | GNUNET_break (0); |
903 | fail_union_operation (eo); | 887 | fail_intersection_operation (eo); |
904 | return; | 888 | return; |
905 | } | 889 | } |
906 | } | 890 | } |
907 | else if (eo->phase == PHASE_EXPECT_IBF_CONT) | 891 | else if (eo->phase == PHASE_EXPECT_BF_CONT) |
908 | { | 892 | { |
909 | if ( (ntohs (msg->offset) != eo->ibf_buckets_received) || | 893 | if ( (ntohs (msg->offset) != eo->ibf_buckets_received) || |
910 | (1<<msg->order != eo->remote_ibf->size) ) | 894 | (1<<msg->order != eo->remote_ibf->size) ) |
911 | { | 895 | { |
912 | GNUNET_break (0); | 896 | GNUNET_break (0); |
913 | fail_union_operation (eo); | 897 | fail_intersection_operation (eo); |
914 | return; | 898 | return; |
915 | } | 899 | } |
916 | } | 900 | } |
@@ -920,14 +904,14 @@ handle_p2p_ibf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
920 | if (0 == buckets_in_message) | 904 | if (0 == buckets_in_message) |
921 | { | 905 | { |
922 | GNUNET_break_op (0); | 906 | GNUNET_break_op (0); |
923 | fail_union_operation (eo); | 907 | fail_intersection_operation (eo); |
924 | return; | 908 | return; |
925 | } | 909 | } |
926 | 910 | ||
927 | if ((ntohs (msg->header.size) - sizeof *msg) != buckets_in_message * IBF_BUCKET_SIZE) | 911 | if ((ntohs (msg->header.size) - sizeof *msg) != buckets_in_message * IBF_BUCKET_SIZE) |
928 | { | 912 | { |
929 | GNUNET_break (0); | 913 | GNUNET_break (0); |
930 | fail_union_operation (eo); | 914 | fail_intersection_operation (eo); |
931 | return; | 915 | return; |
932 | } | 916 | } |
933 | 917 | ||
@@ -947,7 +931,7 @@ handle_p2p_ibf (void *cls, const struct GNUNET_MessageHeader *mh) | |||
947 | * Send a result message to the client indicating | 931 | * Send a result message to the client indicating |
948 | * that there is a new element. | 932 | * that there is a new element. |
949 | * | 933 | * |
950 | * @param eo union operation | 934 | * @param eo intersection operation |
951 | * @param element element to send | 935 | * @param element element to send |
952 | */ | 936 | */ |
953 | static void | 937 | static void |
@@ -980,7 +964,7 @@ send_client_element (struct OperationState *eo, | |||
980 | * After the result done message has been sent to the client, | 964 | * After the result done message has been sent to the client, |
981 | * destroy the evaluate operation. | 965 | * destroy the evaluate operation. |
982 | * | 966 | * |
983 | * @param eo union operation | 967 | * @param eo intersection operation |
984 | */ | 968 | */ |
985 | static void | 969 | static void |
986 | send_client_done_and_destroy (struct OperationState *eo) | 970 | send_client_done_and_destroy (struct OperationState *eo) |
@@ -998,14 +982,14 @@ send_client_done_and_destroy (struct OperationState *eo) | |||
998 | rm->element_type = htons (0); | 982 | rm->element_type = htons (0); |
999 | GNUNET_MQ_send (eo->spec->set->client_mq, ev); | 983 | GNUNET_MQ_send (eo->spec->set->client_mq, ev); |
1000 | 984 | ||
1001 | union_operation_destroy (eo); | 985 | intersection_operation_destroy (eo); |
1002 | } | 986 | } |
1003 | 987 | ||
1004 | 988 | ||
1005 | /** | 989 | /** |
1006 | * Handle an element message from a remote peer. | 990 | * Handle an element message from a remote peer. |
1007 | * | 991 | * |
1008 | * @param cls the union operation | 992 | * @param cls the intersection operation |
1009 | * @param mh the message | 993 | * @param mh the message |
1010 | */ | 994 | */ |
1011 | static void | 995 | static void |
@@ -1020,7 +1004,7 @@ handle_p2p_elements (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1020 | if ( (eo->phase != PHASE_EXPECT_ELEMENTS) && | 1004 | if ( (eo->phase != PHASE_EXPECT_ELEMENTS) && |
1021 | (eo->phase != PHASE_EXPECT_ELEMENTS_AND_REQUESTS) ) | 1005 | (eo->phase != PHASE_EXPECT_ELEMENTS_AND_REQUESTS) ) |
1022 | { | 1006 | { |
1023 | fail_union_operation (eo); | 1007 | fail_intersection_operation (eo); |
1024 | GNUNET_break (0); | 1008 | GNUNET_break (0); |
1025 | return; | 1009 | return; |
1026 | } | 1010 | } |
@@ -1042,7 +1026,7 @@ handle_p2p_elements (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1042 | /** | 1026 | /** |
1043 | * Handle an element request from a remote peer. | 1027 | * Handle an element request from a remote peer. |
1044 | * | 1028 | * |
1045 | * @param cls the union operation | 1029 | * @param cls the intersection operation |
1046 | * @param mh the message | 1030 | * @param mh the message |
1047 | */ | 1031 | */ |
1048 | static void | 1032 | static void |
@@ -1056,7 +1040,7 @@ handle_p2p_element_requests (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1056 | if (eo->phase != PHASE_EXPECT_ELEMENTS_AND_REQUESTS) | 1040 | if (eo->phase != PHASE_EXPECT_ELEMENTS_AND_REQUESTS) |
1057 | { | 1041 | { |
1058 | GNUNET_break (0); | 1042 | GNUNET_break (0); |
1059 | fail_union_operation (eo); | 1043 | fail_intersection_operation (eo); |
1060 | return; | 1044 | return; |
1061 | } | 1045 | } |
1062 | 1046 | ||
@@ -1065,7 +1049,7 @@ handle_p2p_element_requests (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1065 | if ((ntohs (mh->size) - sizeof *mh) != num_keys * sizeof (struct IBF_Key)) | 1049 | if ((ntohs (mh->size) - sizeof *mh) != num_keys * sizeof (struct IBF_Key)) |
1066 | { | 1050 | { |
1067 | GNUNET_break (0); | 1051 | GNUNET_break (0); |
1068 | fail_union_operation (eo); | 1052 | fail_intersection_operation (eo); |
1069 | return; | 1053 | return; |
1070 | } | 1054 | } |
1071 | 1055 | ||
@@ -1081,7 +1065,7 @@ handle_p2p_element_requests (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1081 | /** | 1065 | /** |
1082 | * Handle a done message from a remote peer | 1066 | * Handle a done message from a remote peer |
1083 | * | 1067 | * |
1084 | * @param cls the union operation | 1068 | * @param cls the intersection operation |
1085 | * @param mh the message | 1069 | * @param mh the message |
1086 | */ | 1070 | */ |
1087 | static void | 1071 | static void |
@@ -1108,18 +1092,18 @@ handle_p2p_done (void *cls, const struct GNUNET_MessageHeader *mh) | |||
1108 | return; | 1092 | return; |
1109 | } | 1093 | } |
1110 | GNUNET_break (0); | 1094 | GNUNET_break (0); |
1111 | fail_union_operation (eo); | 1095 | fail_intersection_operation (eo); |
1112 | } | 1096 | } |
1113 | 1097 | ||
1114 | 1098 | ||
1115 | /** | 1099 | /** |
1116 | * Evaluate a union operation with | 1100 | * Evaluate a intersection operation with |
1117 | * a remote peer. | 1101 | * a remote peer. |
1118 | * | 1102 | * |
1119 | * @param spec specification of the operation the evaluate | 1103 | * @param spec specification of the operation the evaluate |
1120 | * @param tunnel tunnel already connected to the partner peer | 1104 | * @param tunnel tunnel already connected to the partner peer |
1121 | * @param tc tunnel context, passed here so all new incoming | 1105 | * @param tc tunnel context, passed here so all new incoming |
1122 | * messages are directly going to the union operations | 1106 | * messages are directly going to the intersection operations |
1123 | * @return a handle to the operation | 1107 | * @return a handle to the operation |
1124 | */ | 1108 | */ |
1125 | static void | 1109 | static void |
@@ -1130,7 +1114,7 @@ intersection_evaluate (struct OperationSpecification *spec, | |||
1130 | struct OperationState *eo; | 1114 | struct OperationState *eo; |
1131 | 1115 | ||
1132 | eo = GNUNET_new (struct OperationState); | 1116 | eo = GNUNET_new (struct OperationState); |
1133 | tc->vt = _GSS_union_vt (); | 1117 | tc->vt = _GSS_intersection_vt (); |
1134 | tc->op = eo; | 1118 | tc->op = eo; |
1135 | eo->se = strata_estimator_dup (spec->set->state->se); | 1119 | eo->se = strata_estimator_dup (spec->set->state->se); |
1136 | eo->generation_created = spec->set->current_generation++; | 1120 | eo->generation_created = spec->set->current_generation++; |
@@ -1140,7 +1124,7 @@ intersection_evaluate (struct OperationSpecification *spec, | |||
1140 | eo->mq = GNUNET_MESH_mq_create (tunnel); | 1124 | eo->mq = GNUNET_MESH_mq_create (tunnel); |
1141 | 1125 | ||
1142 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1143 | "evaluating union operation, (app %s)\n", | 1127 | "evaluating intersection operation, (app %s)\n", |
1144 | GNUNET_h2s (&eo->spec->app_id)); | 1128 | GNUNET_h2s (&eo->spec->app_id)); |
1145 | 1129 | ||
1146 | /* we started the operation, thus we have to send the operation request */ | 1130 | /* we started the operation, thus we have to send the operation request */ |
@@ -1155,12 +1139,12 @@ intersection_evaluate (struct OperationSpecification *spec, | |||
1155 | 1139 | ||
1156 | 1140 | ||
1157 | /** | 1141 | /** |
1158 | * Accept an union operation request from a remote peer | 1142 | * Accept an intersection operation request from a remote peer |
1159 | * | 1143 | * |
1160 | * @param spec all necessary information about the operation | 1144 | * @param spec all necessary information about the operation |
1161 | * @param tunnel open tunnel to the partner's peer | 1145 | * @param tunnel open tunnel to the partner's peer |
1162 | * @param tc tunnel context, passed here so all new incoming | 1146 | * @param tc tunnel context, passed here so all new incoming |
1163 | * messages are directly going to the union operations | 1147 | * messages are directly going to the intersection operations |
1164 | * @return operation | 1148 | * @return operation |
1165 | */ | 1149 | */ |
1166 | static void | 1150 | static void |
@@ -1170,10 +1154,10 @@ intersection_accept (struct OperationSpecification *spec, | |||
1170 | { | 1154 | { |
1171 | struct OperationState *eo; | 1155 | struct OperationState *eo; |
1172 | 1156 | ||
1173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "accepting set union operation\n"); | 1157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "accepting set intersection operation\n"); |
1174 | 1158 | ||
1175 | eo = GNUNET_new (struct OperationState); | 1159 | eo = GNUNET_new (struct OperationState); |
1176 | tc->vt = _GSS_union_vt (); | 1160 | tc->vt = _GSS_intersection_vt (); |
1177 | tc->op = eo; | 1161 | tc->op = eo; |
1178 | eo->set = spec->set; | 1162 | eo->set = spec->set; |
1179 | eo->generation_created = eo->set->current_generation++; | 1163 | eo->generation_created = eo->set->current_generation++; |
@@ -1191,7 +1175,7 @@ intersection_accept (struct OperationSpecification *spec, | |||
1191 | 1175 | ||
1192 | 1176 | ||
1193 | /** | 1177 | /** |
1194 | * Create a new set supporting the union operation | 1178 | * Create a new set supporting the intersection operation |
1195 | * | 1179 | * |
1196 | * @return the newly created set | 1180 | * @return the newly created set |
1197 | */ | 1181 | */ |
@@ -1200,7 +1184,7 @@ intersection_set_create (void) | |||
1200 | { | 1184 | { |
1201 | struct SetState *set_state; | 1185 | struct SetState *set_state; |
1202 | 1186 | ||
1203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "union set created\n"); | 1187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "intersection set created\n"); |
1204 | 1188 | ||
1205 | set_state = GNUNET_new (struct SetState); | 1189 | set_state = GNUNET_new (struct SetState); |
1206 | set_state->se = strata_estimator_create (SE_STRATA_COUNT, | 1190 | set_state->se = strata_estimator_create (SE_STRATA_COUNT, |
@@ -1223,17 +1207,17 @@ intersection_add (struct SetState *set_state, struct ElementEntry *ee) | |||
1223 | 1207 | ||
1224 | 1208 | ||
1225 | /** | 1209 | /** |
1226 | * Destroy a set that supports the union operation | 1210 | * Destroy a set that supports the intersection operation |
1227 | * | 1211 | * |
1228 | * @param set_state the set to destroy | 1212 | * @param set_state the set to destroy |
1229 | */ | 1213 | */ |
1230 | static void | 1214 | static void |
1231 | intersection_set_destroy (struct SetState *set_state) | 1215 | intersection_set_destroy (struct SetState *set_state) |
1232 | { | 1216 | { |
1233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying union set\n"); | 1217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "destroying intersection set\n"); |
1234 | /* important to destroy operations before the rest of the set */ | 1218 | /* important to destroy operations before the rest of the set */ |
1235 | while (NULL != set_state->ops_head) | 1219 | while (NULL != set_state->ops_head) |
1236 | union_operation_destroy (set_state->ops_head); | 1220 | intersection_operation_destroy (set_state->ops_head); |
1237 | if (NULL != set_state->se) | 1221 | if (NULL != set_state->se) |
1238 | { | 1222 | { |
1239 | strata_estimator_destroy (set_state->se); | 1223 | strata_estimator_destroy (set_state->se); |
@@ -1258,9 +1242,9 @@ intersection_remove (struct SetState *set_state, struct ElementEntry *element) | |||
1258 | 1242 | ||
1259 | 1243 | ||
1260 | /** | 1244 | /** |
1261 | * Dispatch messages for a union operation. | 1245 | * Dispatch messages for a intersection operation. |
1262 | * | 1246 | * |
1263 | * @param eo the state of the union evaluate operation | 1247 | * @param eo the state of the intersection evaluate operation |
1264 | * @param mh the received message | 1248 | * @param mh the received message |
1265 | * @return GNUNET_SYSERR if the tunnel should be disconnected, | 1249 | * @return GNUNET_SYSERR if the tunnel should be disconnected, |
1266 | * GNUNET_OK otherwise | 1250 | * GNUNET_OK otherwise |
@@ -1319,7 +1303,7 @@ intersection_peer_disconnect (struct OperationState *op) | |||
1319 | msg->element_type = htons (0); | 1303 | msg->element_type = htons (0); |
1320 | GNUNET_MQ_send (op->spec->set->client_mq, ev); | 1304 | GNUNET_MQ_send (op->spec->set->client_mq, ev); |
1321 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "other peer disconnected prematurely\n"); | 1305 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "other peer disconnected prematurely\n"); |
1322 | union_operation_destroy (op); | 1306 | intersection_operation_destroy (op); |
1323 | return; | 1307 | return; |
1324 | } | 1308 | } |
1325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "other peer disconnected (finished)\n"); | 1309 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "other peer disconnected (finished)\n"); |
@@ -1338,17 +1322,17 @@ intersection_op_cancel (struct SetState *set_state, uint32_t op_id) | |||
1338 | const struct SetVT * | 1322 | const struct SetVT * |
1339 | _GSS_intersection_vt () | 1323 | _GSS_intersection_vt () |
1340 | { | 1324 | { |
1341 | static const struct SetVT union_vt = { | 1325 | static const struct SetVT intersection_vt = { |
1342 | .create = &union_set_create, | 1326 | .create = &intersection_set_create, |
1343 | .msg_handler = &union_handle_p2p_message, | 1327 | .msg_handler = &intersection_handle_p2p_message, |
1344 | .add = &union_add, | 1328 | .add = &intersection_add, |
1345 | .remove = &union_remove, | 1329 | .remove = &intersection_remove, |
1346 | .destroy_set = &union_set_destroy, | 1330 | .destroy_set = &intersection_set_destroy, |
1347 | .evaluate = &union_evaluate, | 1331 | .evaluate = &intersection_evaluate, |
1348 | .accept = &union_accept, | 1332 | .accept = &intersection_accept, |
1349 | .peer_disconnect = &union_peer_disconnect, | 1333 | .peer_disconnect = &intersection_peer_disconnect, |
1350 | .cancel = &union_op_cancel, | 1334 | .cancel = &intersection_op_cancel, |
1351 | }; | 1335 | }; |
1352 | 1336 | ||
1353 | return &union_vt; | 1337 | return &intersection_vt; |
1354 | } | 1338 | } |