fix logging, immediately switch to full set transmission if other peer has 0 elements
authorChristian Grothoff <christian@grothoff.org>
Sat, 11 Mar 2017 17:33:09 +0000 (18:33 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sat, 11 Mar 2017 17:33:09 +0000 (18:33 +0100)
src/revocation/test_revocation.c
src/set/gnunet-service-set_union.c

index d3bbb879a80e44331575d0008f953b98b3928404..8d55936941f58676303cc397d1573e8b1e6e753d 100644 (file)
@@ -104,8 +104,8 @@ revocation_remote_cb (void *cls,
 
   if (GNUNET_NO == is_valid)
   {
-    fprintf (stderr,
-             "Local revocation successful\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Local revocation successful\n");
     ok = 0;
     GNUNET_SCHEDULER_shutdown ();
     return;
@@ -118,8 +118,8 @@ revocation_remote_cb (void *cls,
                                   NULL);
     return;
   }
-  fprintf (stderr,
-           "Flooding of revocation failed\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "Flooding of revocation failed\n");
   ok = 2;
   GNUNET_SCHEDULER_shutdown ();
 }
@@ -141,8 +141,8 @@ revocation_cb (void *cls,
   testpeers[1].revok_handle = NULL;
   if (GNUNET_NO == is_valid)
   {
-    fprintf (stderr,
-             "Revocation successful\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Revocation successful\n");
     check_revocation (NULL);
   }
 }
@@ -386,8 +386,8 @@ test_connection (void *cls,
    /* We are generating a CLIQUE */
   if (NUM_TEST_PEERS * (NUM_TEST_PEERS -1) == links_succeeded)
   {
-    fprintf (stderr,
-             "Testbed connected peers, initializing test\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Testbed connected peers, initializing test\n");
     for (c = 0; c < num_peers; c++)
     {
       testpeers[c].p = peers[c];
@@ -403,8 +403,8 @@ test_connection (void *cls,
   }
   else
   {
-    fprintf (stderr,
-             "Testbed failed to connect peers\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Testbed failed to connect peers\n");
     ok = 5;
     GNUNET_SCHEDULER_shutdown ();
     return;
index 200bd4b8ec5db43f4e6d67f1dce49007cf64d55c..1ff3d77164a20502327aa61fda27c83e32b30990 100644 (file)
@@ -787,11 +787,18 @@ send_element_iterator (void *cls,
   struct GNUNET_SET_Element *el = &ee->element;
   struct GNUNET_MQ_Envelope *ev;
 
-
-  ev = GNUNET_MQ_msg_extra (emsg, el->size, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT);
+  LOG (GNUNET_ERROR_TYPE_INFO,
+       "Sending element %s\n",
+       GNUNET_h2s (key));
+  ev = GNUNET_MQ_msg_extra (emsg,
+                            el->size,
+                            GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT);
   emsg->element_type = htons (el->element_type);
-  GNUNET_memcpy (&emsg[1], el->data, el->size);
-  GNUNET_MQ_send (op->mq, ev);
+  GNUNET_memcpy (&emsg[1],
+                 el->data,
+                 el->size);
+  GNUNET_MQ_send (op->mq,
+                  ev);
   return GNUNET_YES;
 }
 
@@ -802,11 +809,14 @@ send_full_set (struct Operation *op)
   struct GNUNET_MQ_Envelope *ev;
 
   op->state->phase = PHASE_FULL_SENDING;
-
+  /* FIXME: use a more memory-friendly way of doing this with an
+     iterator, just as we do in the non-full case! */
   (void) GNUNET_CONTAINER_multihashmap_iterate (op->spec->set->content->elements,
-                                                &send_element_iterator, op);
+                                                &send_element_iterator,
+                                                op);
   ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE);
-  GNUNET_MQ_send (op->mq, ev);
+  GNUNET_MQ_send (op->mq,
+                  ev);
 }
 
 
@@ -922,17 +932,19 @@ handle_union_p2p_strata_estimator (void *cls,
   }
 
   if ( (GNUNET_YES == op->spec->force_full) ||
-       (diff > op->state->initial_size / 4))
+       (diff > op->state->initial_size / 4) ||
+       (0 == other_size) )
   {
     LOG (GNUNET_ERROR_TYPE_INFO,
-         "Sending full set (diff=%d, own set=%u)\n",
+         "Deciding to go for full set transmission (diff=%d, own set=%u)\n",
          diff,
          op->state->initial_size);
     GNUNET_STATISTICS_update (_GSS_statistics,
                               "# of full sends",
                               1,
                               GNUNET_NO);
-    if (op->state->initial_size <= other_size)
+    if ( (op->state->initial_size <= other_size) ||
+         (0 == other_size) )
     {
       send_full_set (op);
     }
@@ -940,9 +952,12 @@ handle_union_p2p_strata_estimator (void *cls,
     {
       struct GNUNET_MQ_Envelope *ev;
 
+      LOG (GNUNET_ERROR_TYPE_INFO,
+           "Telling other peer that we expect its full set\n");
       op->state->phase = PHASE_EXPECT_IBF;
       ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL);
-      GNUNET_MQ_send (op->mq, ev);
+      GNUNET_MQ_send (op->mq,
+                      ev);
     }
   }
   else
@@ -1773,6 +1788,8 @@ handle_union_p2p_request_full (void *cls,
 {
   struct Operation *op = cls;
 
+  LOG (GNUNET_ERROR_TYPE_INFO,
+       "Received request for full set transmission\n");
   if (OT_UNION != op->type)
   {
     GNUNET_break_op (0);