diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-11 18:33:09 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-11 18:33:09 +0100 |
commit | 538d7fde8cb1c0d079f01f2290aa3e3e2744beff (patch) | |
tree | 7e479adbbaa54b309ab64051413b9283a36877e8 /src/set/gnunet-service-set_union.c | |
parent | abdec5e11ff11bb10d32c013e11344a54786f80f (diff) | |
download | gnunet-538d7fde8cb1c0d079f01f2290aa3e3e2744beff.tar.gz gnunet-538d7fde8cb1c0d079f01f2290aa3e3e2744beff.zip |
fix logging, immediately switch to full set transmission if other peer has 0 elements
Diffstat (limited to 'src/set/gnunet-service-set_union.c')
-rw-r--r-- | src/set/gnunet-service-set_union.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index 200bd4b8e..1ff3d7716 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -787,11 +787,18 @@ send_element_iterator (void *cls, | |||
787 | struct GNUNET_SET_Element *el = &ee->element; | 787 | struct GNUNET_SET_Element *el = &ee->element; |
788 | struct GNUNET_MQ_Envelope *ev; | 788 | struct GNUNET_MQ_Envelope *ev; |
789 | 789 | ||
790 | 790 | LOG (GNUNET_ERROR_TYPE_INFO, | |
791 | ev = GNUNET_MQ_msg_extra (emsg, el->size, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT); | 791 | "Sending element %s\n", |
792 | GNUNET_h2s (key)); | ||
793 | ev = GNUNET_MQ_msg_extra (emsg, | ||
794 | el->size, | ||
795 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT); | ||
792 | emsg->element_type = htons (el->element_type); | 796 | emsg->element_type = htons (el->element_type); |
793 | GNUNET_memcpy (&emsg[1], el->data, el->size); | 797 | GNUNET_memcpy (&emsg[1], |
794 | GNUNET_MQ_send (op->mq, ev); | 798 | el->data, |
799 | el->size); | ||
800 | GNUNET_MQ_send (op->mq, | ||
801 | ev); | ||
795 | return GNUNET_YES; | 802 | return GNUNET_YES; |
796 | } | 803 | } |
797 | 804 | ||
@@ -802,11 +809,14 @@ send_full_set (struct Operation *op) | |||
802 | struct GNUNET_MQ_Envelope *ev; | 809 | struct GNUNET_MQ_Envelope *ev; |
803 | 810 | ||
804 | op->state->phase = PHASE_FULL_SENDING; | 811 | op->state->phase = PHASE_FULL_SENDING; |
805 | 812 | /* FIXME: use a more memory-friendly way of doing this with an | |
813 | iterator, just as we do in the non-full case! */ | ||
806 | (void) GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->content->elements, | 814 | (void) GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->content->elements, |
807 | &send_element_iterator, op); | 815 | &send_element_iterator, |
816 | op); | ||
808 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE); | 817 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE); |
809 | GNUNET_MQ_send (op->mq, ev); | 818 | GNUNET_MQ_send (op->mq, |
819 | ev); | ||
810 | } | 820 | } |
811 | 821 | ||
812 | 822 | ||
@@ -922,17 +932,19 @@ handle_union_p2p_strata_estimator (void *cls, | |||
922 | } | 932 | } |
923 | 933 | ||
924 | if ( (GNUNET_YES == op->spec->force_full) || | 934 | if ( (GNUNET_YES == op->spec->force_full) || |
925 | (diff > op->state->initial_size / 4)) | 935 | (diff > op->state->initial_size / 4) || |
936 | (0 == other_size) ) | ||
926 | { | 937 | { |
927 | LOG (GNUNET_ERROR_TYPE_INFO, | 938 | LOG (GNUNET_ERROR_TYPE_INFO, |
928 | "Sending full set (diff=%d, own set=%u)\n", | 939 | "Deciding to go for full set transmission (diff=%d, own set=%u)\n", |
929 | diff, | 940 | diff, |
930 | op->state->initial_size); | 941 | op->state->initial_size); |
931 | GNUNET_STATISTICS_update (_GSS_statistics, | 942 | GNUNET_STATISTICS_update (_GSS_statistics, |
932 | "# of full sends", | 943 | "# of full sends", |
933 | 1, | 944 | 1, |
934 | GNUNET_NO); | 945 | GNUNET_NO); |
935 | if (op->state->initial_size <= other_size) | 946 | if ( (op->state->initial_size <= other_size) || |
947 | (0 == other_size) ) | ||
936 | { | 948 | { |
937 | send_full_set (op); | 949 | send_full_set (op); |
938 | } | 950 | } |
@@ -940,9 +952,12 @@ handle_union_p2p_strata_estimator (void *cls, | |||
940 | { | 952 | { |
941 | struct GNUNET_MQ_Envelope *ev; | 953 | struct GNUNET_MQ_Envelope *ev; |
942 | 954 | ||
955 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
956 | "Telling other peer that we expect its full set\n"); | ||
943 | op->state->phase = PHASE_EXPECT_IBF; | 957 | op->state->phase = PHASE_EXPECT_IBF; |
944 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL); | 958 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL); |
945 | GNUNET_MQ_send (op->mq, ev); | 959 | GNUNET_MQ_send (op->mq, |
960 | ev); | ||
946 | } | 961 | } |
947 | } | 962 | } |
948 | else | 963 | else |
@@ -1773,6 +1788,8 @@ handle_union_p2p_request_full (void *cls, | |||
1773 | { | 1788 | { |
1774 | struct Operation *op = cls; | 1789 | struct Operation *op = cls; |
1775 | 1790 | ||
1791 | LOG (GNUNET_ERROR_TYPE_INFO, | ||
1792 | "Received request for full set transmission\n"); | ||
1776 | if (OT_UNION != op->type) | 1793 | if (OT_UNION != op->type) |
1777 | { | 1794 | { |
1778 | GNUNET_break_op (0); | 1795 | GNUNET_break_op (0); |