diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-07-22 18:15:20 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-07-22 18:15:20 +0000 |
commit | ee800f69ce6a901d6c16c311fa3662ba8d9d7744 (patch) | |
tree | 90708e74992a7de959e6a30006655f95bd280755 /src/set | |
parent | 45556f34479a5ab80f267ddaacd74b57bde96de6 (diff) | |
download | gnunet-ee800f69ce6a901d6c16c311fa3662ba8d9d7744.tar.gz gnunet-ee800f69ce6a901d6c16c311fa3662ba8d9d7744.zip |
- handle cyclic IBFs and SEs correctly
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set.c | 6 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.c | 15 | ||||
-rw-r--r-- | src/set/strata_estimator.c | 11 |
3 files changed, 22 insertions, 10 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 86624402a..a55c2188e 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -310,12 +310,14 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
310 | { | 310 | { |
311 | set->client = NULL; | 311 | set->client = NULL; |
312 | set_destroy (set); | 312 | set_destroy (set); |
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(client's set destroyed)\n"); | ||
313 | } | 314 | } |
314 | listener = listener_get (client); | 315 | listener = listener_get (client); |
315 | if (NULL != listener) | 316 | if (NULL != listener) |
316 | { | 317 | { |
317 | listener->client = NULL; | 318 | listener->client = NULL; |
318 | listener_destroy (listener); | 319 | listener_destroy (listener); |
320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(client's listener destroyed)\n"); | ||
319 | } | 321 | } |
320 | } | 322 | } |
321 | 323 | ||
@@ -908,9 +910,11 @@ dispatch_p2p_message (void *cls, | |||
908 | struct TunnelContext *tc = *tunnel_ctx; | 910 | struct TunnelContext *tc = *tunnel_ctx; |
909 | int ret; | 911 | int ret; |
910 | 912 | ||
911 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dispatching mesh message\n"); | 913 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dispatching mesh message (type: %u)\n", |
914 | ntohs (message->type)); | ||
912 | ret = tc->vt->msg_handler (tc->op, message); | 915 | ret = tc->vt->msg_handler (tc->op, message); |
913 | GNUNET_MESH_receive_done (tunnel); | 916 | GNUNET_MESH_receive_done (tunnel); |
917 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled mesh message\n"); | ||
914 | 918 | ||
915 | return ret; | 919 | return ret; |
916 | } | 920 | } |
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index 0c57d9414..8a183391e 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -745,7 +745,6 @@ handle_p2p_strata_estimator (void *cls, const struct GNUNET_MessageHeader *mh) | |||
745 | struct StrataEstimator *remote_se; | 745 | struct StrataEstimator *remote_se; |
746 | int diff; | 746 | int diff; |
747 | 747 | ||
748 | |||
749 | if (eo->phase != PHASE_EXPECT_SE) | 748 | if (eo->phase != PHASE_EXPECT_SE) |
750 | { | 749 | { |
751 | fail_union_operation (eo); | 750 | fail_union_operation (eo); |
@@ -756,8 +755,9 @@ handle_p2p_strata_estimator (void *cls, const struct GNUNET_MessageHeader *mh) | |||
756 | SE_IBF_HASH_NUM); | 755 | SE_IBF_HASH_NUM); |
757 | strata_estimator_read (&mh[1], remote_se); | 756 | strata_estimator_read (&mh[1], remote_se); |
758 | GNUNET_assert (NULL != eo->se); | 757 | GNUNET_assert (NULL != eo->se); |
758 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got se, calculating diff\n"); | ||
759 | diff = strata_estimator_difference (remote_se, eo->se); | 759 | diff = strata_estimator_difference (remote_se, eo->se); |
760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got se, diff=%d\n", diff); | 760 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "se diff=%d\n", diff); |
761 | strata_estimator_destroy (remote_se); | 761 | strata_estimator_destroy (remote_se); |
762 | strata_estimator_destroy (eo->se); | 762 | strata_estimator_destroy (eo->se); |
763 | eo->se = NULL; | 763 | eo->se = NULL; |
@@ -800,7 +800,7 @@ send_element_iterator (void *cls, | |||
800 | continue; | 800 | continue; |
801 | } | 801 | } |
802 | memcpy (&mh[1], element->data, element->size); | 802 | memcpy (&mh[1], element->data, element->size); |
803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element to client\n"); | 803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element to peer\n"); |
804 | GNUNET_MQ_send (eo->mq, ev); | 804 | GNUNET_MQ_send (eo->mq, ev); |
805 | ke = ke->next_colliding; | 805 | ke = ke->next_colliding; |
806 | } | 806 | } |
@@ -837,6 +837,7 @@ decode_and_send (struct OperationState *eo) | |||
837 | { | 837 | { |
838 | struct IBF_Key key; | 838 | struct IBF_Key key; |
839 | int side; | 839 | int side; |
840 | unsigned int num_decoded; | ||
840 | struct InvertibleBloomFilter *diff_ibf; | 841 | struct InvertibleBloomFilter *diff_ibf; |
841 | 842 | ||
842 | GNUNET_assert (PHASE_EXPECT_ELEMENTS == eo->phase); | 843 | GNUNET_assert (PHASE_EXPECT_ELEMENTS == eo->phase); |
@@ -848,12 +849,18 @@ decode_and_send (struct OperationState *eo) | |||
848 | ibf_destroy (eo->remote_ibf); | 849 | ibf_destroy (eo->remote_ibf); |
849 | eo->remote_ibf = NULL; | 850 | eo->remote_ibf = NULL; |
850 | 851 | ||
852 | num_decoded = 0; | ||
853 | |||
851 | while (1) | 854 | while (1) |
852 | { | 855 | { |
853 | int res; | 856 | int res; |
854 | 857 | ||
858 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "decoding IBF for elements\n"); | ||
855 | res = ibf_decode (diff_ibf, &side, &key); | 859 | res = ibf_decode (diff_ibf, &side, &key); |
856 | if (GNUNET_SYSERR == res) | 860 | num_decoded += 1; |
861 | if (num_decoded > diff_ibf->size) | ||
862 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "detected cyclic ibf\n"); | ||
863 | if ((GNUNET_SYSERR == res) || (num_decoded > diff_ibf->size)) | ||
857 | { | 864 | { |
858 | int next_order; | 865 | int next_order; |
859 | next_order = 0; | 866 | next_order = 0; |
diff --git a/src/set/strata_estimator.c b/src/set/strata_estimator.c index 18c127cd6..543352331 100644 --- a/src/set/strata_estimator.c +++ b/src/set/strata_estimator.c | |||
@@ -109,25 +109,26 @@ strata_estimator_difference (const struct StrataEstimator *se1, | |||
109 | struct InvertibleBloomFilter *diff; | 109 | struct InvertibleBloomFilter *diff; |
110 | /* number of keys decoded from the ibf */ | 110 | /* number of keys decoded from the ibf */ |
111 | int ibf_count; | 111 | int ibf_count; |
112 | int more; | ||
113 | ibf_count = 0; | ||
114 | /* FIXME: implement this without always allocating new IBFs */ | 112 | /* FIXME: implement this without always allocating new IBFs */ |
115 | diff = ibf_dup (se1->strata[i]); | 113 | diff = ibf_dup (se1->strata[i]); |
116 | ibf_subtract (diff, se2->strata[i]); | 114 | ibf_subtract (diff, se2->strata[i]); |
117 | for (;;) | 115 | for (ibf_count = 0; GNUNET_YES; ibf_count++) |
118 | { | 116 | { |
117 | int more; | ||
118 | |||
119 | more = ibf_decode (diff, NULL, NULL); | 119 | more = ibf_decode (diff, NULL, NULL); |
120 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "decoding\n"); | ||
120 | if (GNUNET_NO == more) | 121 | if (GNUNET_NO == more) |
121 | { | 122 | { |
122 | count += ibf_count; | 123 | count += ibf_count; |
123 | break; | 124 | break; |
124 | } | 125 | } |
125 | if (GNUNET_SYSERR == more) | 126 | /* Estimate if decoding fails or would not terminate */ |
127 | if ((GNUNET_SYSERR == more) || (ibf_count > diff->size)) | ||
126 | { | 128 | { |
127 | ibf_destroy (diff); | 129 | ibf_destroy (diff); |
128 | return count * (1 << (i + 1)); | 130 | return count * (1 << (i + 1)); |
129 | } | 131 | } |
130 | ibf_count++; | ||
131 | } | 132 | } |
132 | ibf_destroy (diff); | 133 | ibf_destroy (diff); |
133 | } | 134 | } |