gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r34451 - gnunet/src/set
Date: Sun, 30 Nov 2014 01:21:42 +0100

Author: grothoff
Date: 2014-11-30 01:21:42 +0100 (Sun, 30 Nov 2014)
New Revision: 34451

Modified:
   gnunet/src/set/gnunet-service-set.c
   gnunet/src/set/gnunet-service-set_intersection.c
   gnunet/src/set/set_api.c
   gnunet/src/set/test_set.conf
   gnunet/src/set/test_set_intersection_result_full.c
Log:
-misc fixes, in particular actually build bf

Modified: gnunet/src/set/gnunet-service-set.c
===================================================================
--- gnunet/src/set/gnunet-service-set.c 2014-11-29 23:20:26 UTC (rev 34450)
+++ gnunet/src/set/gnunet-service-set.c 2014-11-30 00:21:42 UTC (rev 34451)
@@ -719,7 +719,7 @@
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Iterating union set with %u elements\n",
+              "Iterating set with %u elements\n",
               GNUNET_CONTAINER_multihashmap_size (set->elements));
   GNUNET_SERVER_receive_done (client,
                               GNUNET_OK);
@@ -748,7 +748,7 @@
   msg = (const struct GNUNET_SET_CreateMessage *) m;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Client created new set (operation %u)\n",
-              ntohs (msg->operation));
+              ntohl (msg->operation));
   if (NULL != set_get (client))
   {
     /* There can only be one set per client */

Modified: gnunet/src/set/gnunet-service-set_intersection.c
===================================================================
--- gnunet/src/set/gnunet-service-set_intersection.c    2014-11-29 23:20:26 UTC 
(rev 34450)
+++ gnunet/src/set/gnunet-service-set_intersection.c    2014-11-30 00:21:42 UTC 
(rev 34451)
@@ -37,15 +37,21 @@
 enum IntersectionOperationPhase
 {
   /**
-   * Alices has suggested an operation to bob,
-   * and is waiting for a bf or session end.
+   * We are just starting.
    */
   PHASE_INITIAL,
 
   /**
-   * Bob has accepted the operation, Bob and Alice are now exchanging bfs
-   * until one notices the their element hashes are equal.
+   * We have send the number of our elements to the other
+   * peer, but did not setup our element set yet.
    */
+  PHASE_COUNT_SENT,
+
+  /**
+   * We have initialized our set and are now reducing it by exchanging
+   * Bloom filters until one party notices the their element hashes
+   * are equal.
+   */
   PHASE_BF_EXCHANGE,
 
   /**
@@ -227,14 +233,30 @@
   struct ElementEntry *ee = value;
   struct GNUNET_HashCode mutated_hash;
 
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "FIMA called for %s:%u\n",
+              GNUNET_h2s (&ee->element_hash),
+              ee->element.size);
+
   if ( (op->generation_created < ee->generation_removed) &&
        (op->generation_created >= ee->generation_added) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Reduced initialization, not starting with %s:%u (wrong 
generation)\n",
+                GNUNET_h2s (&ee->element_hash),
+                ee->element.size);
     return GNUNET_YES; /* element not valid in our operation's generation */
+  }
 
-  /* Test if element is in Bob's bloomfilter */
+  /* Test if element is in other peer's bloomfilter */
   GNUNET_BLOCK_mingle_hash (&ee->element_hash,
                             op->state->salt,
                             &mutated_hash);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Testing mingled hash %s with salt %u\n",
+              GNUNET_h2s (&mutated_hash),
+              op->state->salt);
   if (GNUNET_NO ==
       GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf,
                                          &mutated_hash))
@@ -242,12 +264,20 @@
     /* remove this element */
     send_client_removed_element (op,
                                  &ee->element);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Reduced initialization, not starting with %s:%u\n",
+                GNUNET_h2s (&ee->element_hash),
+                ee->element.size);
     return GNUNET_YES;
   }
   op->state->my_element_count++;
   GNUNET_CRYPTO_hash_xor (&op->state->my_xor,
                           &ee->element_hash,
                           &op->state->my_xor);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Filtered initialization of my_elements, adding %s:%u\n",
+              GNUNET_h2s (&ee->element_hash),
+              ee->element.size);
   GNUNET_break (GNUNET_YES ==
                 GNUNET_CONTAINER_multihashmap_put (op->state->my_elements,
                                                    &ee->element_hash,
@@ -279,6 +309,10 @@
   GNUNET_BLOCK_mingle_hash (&ee->element_hash,
                             op->state->salt,
                             &mutated_hash);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Testing mingled hash %s with salt %u\n",
+              GNUNET_h2s (&mutated_hash),
+              op->state->salt);
   if (GNUNET_NO ==
       GNUNET_CONTAINER_bloomfilter_test (op->state->remote_bf,
                                          &mutated_hash))
@@ -288,6 +322,10 @@
     GNUNET_CRYPTO_hash_xor (&op->state->my_xor,
                             &ee->element_hash,
                             &op->state->my_xor);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Bloom filter reduction of my_elements, removing %s:%u\n",
+                GNUNET_h2s (&ee->element_hash),
+                ee->element.size);
     GNUNET_assert (GNUNET_YES ==
                    GNUNET_CONTAINER_multihashmap_remove 
(op->state->my_elements,
                                                          &ee->element_hash,
@@ -295,6 +333,13 @@
     send_client_removed_element (op,
                                  &ee->element);
   }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Bloom filter reduction of my_elements, keeping %s:%u\n",
+                GNUNET_h2s (&ee->element_hash),
+                ee->element.size);
+  }
   return GNUNET_YES;
 }
 
@@ -319,6 +364,10 @@
   GNUNET_BLOCK_mingle_hash (&ee->element_hash,
                             op->state->salt,
                             &mutated_hash);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Initializing BF with hash %s with salt %u\n",
+              GNUNET_h2s (&mutated_hash),
+              op->state->salt);
   GNUNET_CONTAINER_bloomfilter_add (op->state->local_bf,
                                     &mutated_hash);
   return GNUNET_YES;
@@ -370,7 +419,6 @@
   uint32_t bf_size;
   uint32_t bf_elementbits;
   uint32_t chunk_size;
-  struct GNUNET_CONTAINER_BloomFilter *local_bf;
   char *bf_data;
   uint32_t offset;
 
@@ -387,11 +435,12 @@
   bf_size = ceil ((double) (op->state->my_element_count
                             * bf_elementbits / log(2)));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Sending bf of size %u\n",
+              "Sending Bloom filter (%u) of size %u bytes\n",
+              (unsigned int) bf_elementbits,
               (unsigned int) bf_size);
-  local_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
-                                                bf_size,
-                                                bf_elementbits);
+  op->state->local_bf = GNUNET_CONTAINER_bloomfilter_init (NULL,
+                                                           bf_size,
+                                                           bf_elementbits);
   op->state->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
                                               UINT32_MAX);
   GNUNET_CONTAINER_multihashmap_iterate (op->state->my_elements,
@@ -408,7 +457,7 @@
                               chunk_size,
                               GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF);
     GNUNET_assert (GNUNET_SYSERR !=
-                   GNUNET_CONTAINER_bloomfilter_get_raw_data (local_bf,
+                   GNUNET_CONTAINER_bloomfilter_get_raw_data 
(op->state->local_bf,
                                                               (char*) &msg[1],
                                                               bf_size));
     msg->sender_element_count = htonl (op->state->my_element_count);
@@ -423,7 +472,7 @@
     /* multipart */
     bf_data = GNUNET_malloc (bf_size);
     GNUNET_assert (GNUNET_SYSERR !=
-                   GNUNET_CONTAINER_bloomfilter_get_raw_data (local_bf,
+                   GNUNET_CONTAINER_bloomfilter_get_raw_data 
(op->state->local_bf,
                                                               bf_data,
                                                               bf_size));
     offset = 0;
@@ -447,7 +496,8 @@
     }
     GNUNET_free (bf_data);
   }
-  GNUNET_CONTAINER_bloomfilter_free (local_bf);
+  GNUNET_CONTAINER_bloomfilter_free (op->state->local_bf);
+  op->state->local_bf = NULL;
 }
 
 
@@ -560,15 +610,25 @@
 static void
 process_bf (struct Operation *op)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received BF in phase %u, foreign count is %u, my element count 
is %u/%u\n",
+              op->state->phase,
+              op->spec->remote_element_count,
+              op->state->my_element_count,
+              GNUNET_CONTAINER_multihashmap_size (op->spec->set->elements));
   switch (op->state->phase)
   {
   case PHASE_INITIAL:
+    GNUNET_break_op (0);
+    fail_intersection_operation(op);
+    return;
+  case PHASE_COUNT_SENT:
     /* This is the first BF being sent, build our initial map with
        filtering in place */
     op->state->my_elements
       = GNUNET_CONTAINER_multihashmap_create (op->spec->remote_element_count,
                                               GNUNET_YES);
-    GNUNET_break (0 == op->state->my_element_count);
+    op->state->my_element_count = 0;
     GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->elements,
                                            &filtered_map_initialization,
                                            op);
@@ -633,6 +693,7 @@
     GNUNET_break_op (0);
     fail_intersection_operation (op);
     break;
+  case PHASE_COUNT_SENT:
   case PHASE_BF_EXCHANGE:
     bf_size = ntohl (msg->bloomfilter_total_length);
     bf_bits_per_element = ntohl (msg->bits_per_element);
@@ -652,6 +713,7 @@
                                              bf_size,
                                              bf_bits_per_element);
       op->state->salt = ntohl (msg->sender_mutator);
+      op->spec->remote_element_count = ntohl (msg->sender_element_count);
       process_bf (op);
       return;
     }
@@ -728,6 +790,10 @@
   GNUNET_CRYPTO_hash_xor (&op->state->my_xor,
                           &ee->element_hash,
                           &op->state->my_xor);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Initial full initialization of my_elements, adding %s:%u\n",
+              GNUNET_h2s (&ee->element_hash),
+              ee->element.size);
   GNUNET_break (GNUNET_YES ==
                 GNUNET_CONTAINER_multihashmap_put (op->state->my_elements,
                                                    &ee->element_hash,
@@ -750,7 +816,8 @@
   struct IntersectionElementInfoMessage *msg;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Sending our element count (bf_msg)\n");
+              "Sending our element count (%u)\n",
+              op->state->my_element_count);
   ev = GNUNET_MQ_msg (msg,
                       GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO);
   msg->sender_element_count = htonl (op->state->my_element_count);
@@ -767,7 +834,6 @@
 static void
 begin_bf_exchange (struct Operation *op)
 {
-  GNUNET_break (PHASE_INITIAL == op->state->phase);
   op->state->phase = PHASE_BF_EXCHANGE;
   op->state->my_elements
     = GNUNET_CONTAINER_multihashmap_create (op->state->my_element_count,
@@ -801,7 +867,12 @@
   }
   msg = (const struct IntersectionElementInfoMessage *) mh;
   op->spec->remote_element_count = ntohl (msg->sender_element_count);
-  if ( (PHASE_INITIAL != op->state->phase) ||
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received remote element count (%u), I have %u\n",
+              op->spec->remote_element_count,
+              op->state->my_element_count);
+  if ( ( (PHASE_INITIAL != op->state->phase) &&
+         (PHASE_COUNT_SENT != op->state->phase) ) ||
        (op->state->my_element_count > op->spec->remote_element_count) ||
        (0 == op->state->my_element_count) ||
        (0 == op->spec->remote_element_count) )
@@ -861,6 +932,10 @@
   GNUNET_CRYPTO_hash_xor (&op->state->my_xor,
                           &ee->element_hash,
                           &op->state->my_xor);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Final reduction of my_elements, removing %s:%u\n",
+              GNUNET_h2s (&ee->element_hash),
+              ee->element.size);
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multihashmap_remove (op->state->my_elements,
                                                        &ee->element_hash,
@@ -945,7 +1020,7 @@
   op->state->my_element_count = 
op->spec->set->state->current_set_element_count;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Initiating intersection operation evaluation");
+              "Initiating intersection operation evaluation\n");
   ev = GNUNET_MQ_msg_nested_mh (msg,
                                 GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST,
                                 opaque_context);
@@ -995,7 +1070,7 @@
     /* If the other peer (Alice) has fewer elements than us (Bob),
        we just send the count as Alice should send the first BF */
     send_element_count (op);
-    op->state->phase = PHASE_BF_EXCHANGE;
+    op->state->phase = PHASE_COUNT_SENT;
     return;
   }
   /* We have fewer elements, so we start with the BF */

Modified: gnunet/src/set/set_api.c
===================================================================
--- gnunet/src/set/set_api.c    2014-11-29 23:20:26 UTC (rev 34450)
+++ gnunet/src/set/set_api.c    2014-11-30 00:21:42 UTC (rev 34451)
@@ -467,6 +467,9 @@
   struct GNUNET_MQ_Envelope *mqm;
   struct GNUNET_SET_CreateMessage *msg;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Creating new set (operation %u)\n",
+              op);
   set = GNUNET_new (struct GNUNET_SET_Handle);
   set->client = GNUNET_CLIENT_connect ("set", cfg);
   if (NULL == set->client)

Modified: gnunet/src/set/test_set.conf
===================================================================
--- gnunet/src/set/test_set.conf        2014-11-29 23:20:26 UTC (rev 34450)
+++ gnunet/src/set/test_set.conf        2014-11-30 00:21:42 UTC (rev 34451)
@@ -2,26 +2,20 @@
 [PATHS]
 GNUNET_TEST_HOME = /tmp/test-gnunet-set/
 
+[arm]
+DEFAULTSERVICES = topology dht nse cadet
+
 [set]
 AUTOSTART = YES
-PORT = 2106
-HOSTNAME = localhost
-BINARY = gnunet-service-set
address@hidden@ PORT = 2106
 #PREFIX = valgrind
-#PREFIX = valgrind -v --leak-check=full 
+#PREFIX = valgrind -v --leak-check=full
 #PREFIX = gdbserver :1234
-ACCEPT_FROM = 127.0.0.1;
-ACCEPT_FROM6 = ::1;
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-set.sock
-UNIX_MATCH_UID = YES
-UNIX_MATCH_GID = YES
-OPTIONS = -L INFO
+#OPTIONS = -L INFO
 
-
 [transport]
 OPTIONS = -LERROR
 
-
 [testbed]
 OVERLAY_TOPOLOGY = CLIQUE
 

Modified: gnunet/src/set/test_set_intersection_result_full.c
===================================================================
--- gnunet/src/set/test_set_intersection_result_full.c  2014-11-29 23:20:26 UTC 
(rev 34450)
+++ gnunet/src/set/test_set_intersection_result_full.c  2014-11-30 00:21:42 UTC 
(rev 34451)
@@ -234,7 +234,7 @@
 {
   config = cfg;
   GNUNET_TESTING_peer_get_identity (peer, &local_id);
-  test_iter ();
+  if (0) test_iter ();
 
   set1 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_INTERSECTION);
   set2 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_INTERSECTION);




reply via email to

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