gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28255 - gnunet/src/set


From: gnunet
Subject: [GNUnet-SVN] r28255 - gnunet/src/set
Date: Mon, 22 Jul 2013 20:15:20 +0200

Author: dold
Date: 2013-07-22 20:15:20 +0200 (Mon, 22 Jul 2013)
New Revision: 28255

Modified:
   gnunet/src/set/gnunet-service-set.c
   gnunet/src/set/gnunet-service-set_union.c
   gnunet/src/set/strata_estimator.c
Log:
- handle cyclic IBFs and SEs correctly


Modified: gnunet/src/set/gnunet-service-set.c
===================================================================
--- gnunet/src/set/gnunet-service-set.c 2013-07-22 17:52:42 UTC (rev 28254)
+++ gnunet/src/set/gnunet-service-set.c 2013-07-22 18:15:20 UTC (rev 28255)
@@ -310,12 +310,14 @@
   {
     set->client = NULL;
     set_destroy (set);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(client's set destroyed)\n");
   }
   listener = listener_get (client);
   if (NULL != listener)
   {
     listener->client = NULL;
     listener_destroy (listener);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "(client's listener destroyed)\n");
   }
 }
 
@@ -908,9 +910,11 @@
   struct TunnelContext *tc = *tunnel_ctx;
   int ret;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dispatching mesh message\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dispatching mesh message (type: %u)\n",
+              ntohs (message->type));
   ret = tc->vt->msg_handler (tc->op, message);
   GNUNET_MESH_receive_done (tunnel);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled mesh message\n");
 
   return ret;
 }

Modified: gnunet/src/set/gnunet-service-set_union.c
===================================================================
--- gnunet/src/set/gnunet-service-set_union.c   2013-07-22 17:52:42 UTC (rev 
28254)
+++ gnunet/src/set/gnunet-service-set_union.c   2013-07-22 18:15:20 UTC (rev 
28255)
@@ -745,7 +745,6 @@
   struct StrataEstimator *remote_se;
   int diff;
 
-
   if (eo->phase != PHASE_EXPECT_SE)
   {
     fail_union_operation (eo);
@@ -756,8 +755,9 @@
                                        SE_IBF_HASH_NUM);
   strata_estimator_read (&mh[1], remote_se);
   GNUNET_assert (NULL != eo->se);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got se, calculating diff\n");
   diff = strata_estimator_difference (remote_se, eo->se);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got se, diff=%d\n", diff);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "se diff=%d\n", diff);
   strata_estimator_destroy (remote_se);
   strata_estimator_destroy (eo->se);
   eo->se = NULL;
@@ -800,7 +800,7 @@
       continue;
     }
     memcpy (&mh[1], element->data, element->size);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element to client\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending element to peer\n");
     GNUNET_MQ_send (eo->mq, ev);
     ke = ke->next_colliding;
   }
@@ -837,6 +837,7 @@
 {
   struct IBF_Key key;
   int side;
+  unsigned int num_decoded;
   struct InvertibleBloomFilter *diff_ibf;
 
   GNUNET_assert (PHASE_EXPECT_ELEMENTS == eo->phase);
@@ -848,12 +849,18 @@
   ibf_destroy (eo->remote_ibf);
   eo->remote_ibf = NULL;
 
+  num_decoded = 0;
+
   while (1)
   {
     int res;
 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "decoding IBF for elements\n");
     res = ibf_decode (diff_ibf, &side, &key);
-    if (GNUNET_SYSERR == res)
+    num_decoded += 1;
+    if (num_decoded > diff_ibf->size)
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "detected cyclic ibf\n");
+    if ((GNUNET_SYSERR == res) || (num_decoded > diff_ibf->size))
     {
       int next_order;
       next_order = 0;

Modified: gnunet/src/set/strata_estimator.c
===================================================================
--- gnunet/src/set/strata_estimator.c   2013-07-22 17:52:42 UTC (rev 28254)
+++ gnunet/src/set/strata_estimator.c   2013-07-22 18:15:20 UTC (rev 28255)
@@ -109,25 +109,26 @@
     struct InvertibleBloomFilter *diff;
     /* number of keys decoded from the ibf */
     int ibf_count;
-    int more;
-    ibf_count = 0;
     /* FIXME: implement this without always allocating new IBFs */
     diff = ibf_dup (se1->strata[i]);
     ibf_subtract (diff, se2->strata[i]);
-    for (;;)
+    for (ibf_count = 0; GNUNET_YES; ibf_count++)
     {
+      int more;
+
       more = ibf_decode (diff, NULL, NULL);
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "decoding\n");
       if (GNUNET_NO == more)
       {
         count += ibf_count;
         break;
       }
-      if (GNUNET_SYSERR == more)
+      /* Estimate if decoding fails or would not terminate */
+      if ((GNUNET_SYSERR == more) || (ibf_count > diff->size))
       {
         ibf_destroy (diff);
         return count * (1 << (i + 1));
       }
-      ibf_count++;
     }
     ibf_destroy (diff);
   }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]