gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34119 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r34119 - gnunet/src/dht
Date: Thu, 7 Aug 2014 00:37:44 +0200

Author: supriti
Date: 2014-08-07 00:37:44 +0200 (Thu, 07 Aug 2014)
New Revision: 34119

Modified:
   gnunet/src/dht/gnunet-service-xdht_neighbours.c
   gnunet/src/dht/gnunet_dht_profiler.c
Log:
X-Vine:Fixes


Modified: gnunet/src/dht/gnunet-service-xdht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-06 19:41:51 UTC 
(rev 34118)
+++ gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-06 22:37:44 UTC 
(rev 34119)
@@ -4358,12 +4358,13 @@
 /**
  * Check if trail_1 and trail_2 have any common element. If yes then join 
  * them at common element. trail_1 always preceeds trail_2 in joined trail. 
- * @param trail_1
- * @param trail_1_len
- * @param trail_2
- * @param trail_2_len
- * @param joined_trail_len
- * @return 
+ * @param trail_1 Trail from source to me, NOT including endpoints.
+ * @param trail_1_len Total number of peers @a trail_1
+ * @param trail_2 Trail from me to current predecessor, NOT including 
endpoints.
+ * @param trail_2_len Total number of peers @a trail_2
+ * @param joined_trail_len Total number of peers in combined trail of trail_1
+ *                          trail_2.
+ * @return Joined trail.
  */
 static struct GNUNET_PeerIdentity *
 check_for_duplicate_entries (const struct GNUNET_PeerIdentity *trail_1,
@@ -4458,13 +4459,14 @@
   trail_me_to_curr_pred = get_shortest_trail (current_predecessor,
                                               &trail_me_to_curr_pred_length);
 
+  /* If there is only on element in the trail, and that element is source.*/
   if ((trail_me_to_curr_pred_length == 1) && 
      (0 == GNUNET_CRYPTO_cmp_peer_identity (&source_peer,
                                             &trail_me_to_curr_pred[0])))
   {
     *trail_src_to_curr_pred_length = 0;
     GNUNET_free_non_null(trail_me_to_curr_pred);
-     return NULL;
+    return NULL;
   }
   
   /* Check if trail_me_to_curr_pred contains source. */
@@ -4476,6 +4478,7 @@
                                                &trail_me_to_curr_pred[i]))
         continue;
 
+       /* Source is NOT part of trail. */
        i = i+1;
 
       /* Source is the last element in the trail to reach to my pred.
@@ -4486,7 +4489,6 @@
         return NULL;
       }
       
-      
       *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - i;
       trail_src_to_curr_pred = GNUNET_malloc (sizeof (struct 
GNUNET_PeerIdentity)*
                                               *trail_src_to_curr_pred_length);
@@ -4497,6 +4499,21 @@
       GNUNET_free_non_null(trail_me_to_curr_pred);
       return trail_src_to_curr_pred;
     }
+    /* Is first element source? Then exclude first element and copy rest of the
+     trail. */
+    if(0 == GNUNET_CRYPTO_cmp_peer_identity (&source_peer,
+                                             &trail_me_to_curr_pred[0]))
+    {
+      *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - 1;
+      trail_src_to_curr_pred = GNUNET_malloc(sizeof(struct 
GNUNET_PeerIdentity)*
+                                             *trail_src_to_curr_pred_length);
+      unsigned int j;
+      for(j=0; j < *trail_src_to_curr_pred_length;j++)
+      {
+        trail_src_to_curr_pred[j] = trail_me_to_curr_pred[j+1];
+      }
+      return trail_src_to_curr_pred;
+    }
   }
   
   unsigned int len;
@@ -4504,7 +4521,7 @@
                                                         trail_src_to_me_len,
                                                         trail_me_to_curr_pred,
                                                         
trail_me_to_curr_pred_length,
-                                                        &len);
+                                                        &len); 
   *trail_src_to_curr_pred_length = len;
   GNUNET_free_non_null(trail_me_to_curr_pred);
   return trail_src_to_curr_pred;
@@ -4547,6 +4564,9 @@
   {
     /* Invert the trail to get the trail from me to finger, NOT including the
        endpoints.*/
+    GNUNET_assert(NULL != GNUNET_CONTAINER_multipeermap_get(friend_peermap,
+                                                            
&trail[trail_length-1]));
+  
     trail_to_new_predecessor = invert_trail (trail, trail_length);
     
     /* Add an entry in your routing table. */
@@ -4607,9 +4627,7 @@
     update_predecessor (finger, trail, trail_length);
     return;
   }
-  /* FIXME: Here we should first call find_successor and get a locally known
-   predecessor. If locally known predecessor is closest then current or finger,
-   add that as predecessor. */
+  
   if (0 == GNUNET_CRYPTO_cmp_peer_identity 
(&current_predecessor->finger_identity,
                                             &finger))
   {
@@ -4713,6 +4731,7 @@
   compare_and_update_predecessor (source_peer, trail, trail_length);
   current_predecessor = finger_table[PREDECESSOR_FINGER_ID];
   unsigned int flag = 0;
+  
   /* Is source of this message NOT my predecessor. */
   if (0 != (GNUNET_CRYPTO_cmp_peer_identity 
(&current_predecessor.finger_identity,
                                              &source_peer)))
@@ -4736,28 +4755,30 @@
         trail_src_to_curr_pred[k] = trail[k];
         k++;
       }
+      break;
     }
  
     if(0 == flag)
     {
-      trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer,
-                                                           trail,
-                                                           trail_length,
-                                                           
&trail_src_to_curr_pred_len);
+      trail_src_to_curr_pred = 
+              get_trail_src_to_curr_pred (source_peer,
+                                          trail,
+                                          trail_length,
+                                          &trail_src_to_curr_pred_len);
     }
   }
   else
   {
     trail_src_to_curr_pred_len = trail_length;
-    int i;
+    unsigned int i;
 
-    trail_src_to_curr_pred = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)
-                                            *trail_src_to_curr_pred_len);
+    trail_src_to_curr_pred = 
+            GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)
+                           *trail_src_to_curr_pred_len);
     for(i = 0; i < trail_src_to_curr_pred_len; i++)
     {
       trail_src_to_curr_pred[i] = trail[i];
     }
-
   }
  
   GNUNET_assert (NULL !=
@@ -4942,7 +4963,7 @@
     GNUNET_assert (NULL !=
                   (target_friend =
                    GNUNET_CONTAINER_multipeermap_get (friend_peermap,
-                                                       &probable_successor)));
+                                                      &probable_successor)));
   }
 
   add_new_finger (probable_successor, trail_me_to_probable_succ,
@@ -5093,6 +5114,7 @@
                                                           peer));
     else 
       GNUNET_assert(0 == GNUNET_CRYPTO_cmp_peer_identity(&source, peer));
+  
     compare_and_update_predecessor (source, trail, trail_length);
     return GNUNET_OK;
   }

Modified: gnunet/src/dht/gnunet_dht_profiler.c
===================================================================
--- gnunet/src/dht/gnunet_dht_profiler.c        2014-08-06 19:41:51 UTC (rev 
34118)
+++ gnunet/src/dht/gnunet_dht_profiler.c        2014-08-06 22:37:44 UTC (rev 
34119)
@@ -205,6 +205,7 @@
  */
 static unsigned int replication;
 
+#if 0
 /**
  * Testbed Operation (to get stats).
  */
@@ -214,7 +215,7 @@
  * Testbed peer handles.
  */
 static struct GNUNET_TESTBED_Peer **testbed_handles;
-
+#endif
 /**
  * Shutdown task.  Cleanup all resources and operations.
  *
@@ -253,7 +254,7 @@
   GNUNET_free_non_null (a_ac);
 }
 
-
+#if 0
 /**
  * Stats callback. Finish the stats testbed operation and when all stats have
  * been iterated, shutdown the test.
@@ -310,8 +311,8 @@
                                             bandwidth_stats_iterator, 
                                             bandwidth_stats_cont, NULL);
 }
+#endif
 
-
 static void
 summarize ()
 {
@@ -322,7 +323,7 @@
   INFO ("# GETS succeeded: %u\n", n_gets_ok);
   INFO ("# GETS failed: %u\n", n_gets_fail);
   //FIXME: is this the right place to call b/w stats?
-  GNUNET_SCHEDULER_add_now (&collect_bandwidth_stats, NULL);
+  //GNUNET_SCHEDULER_add_now (&collect_bandwidth_stats, NULL);
   GNUNET_SCHEDULER_shutdown (); 
 }
 
@@ -467,6 +468,7 @@
   ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac);
 }
 
+#if 0
 /**
  * Stats callback. Finish the stats testbed operation and when all stats have
  * been iterated, shutdown the test.
@@ -530,8 +532,8 @@
                                             finger_stats_iterator, 
                                             finger_stats_cont, NULL);
 }
+#endif
 
-
 /**
  * Task to do DHT PUTS
  *
@@ -547,7 +549,7 @@
    DHT and check if circle is formed. If yes then go ahead with more puts,
    else wait for 'delay' time. This function does not return anything, so we
    should have some way to notify that circle is done or we need to wait.*/
-  GNUNET_SCHEDULER_add_now(collect_finger_stats,NULL);
+  //GNUNET_SCHEDULER_add_now(collect_finger_stats,NULL);
   
   ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
   /* Generate and DHT PUT some random data */
@@ -800,7 +802,7 @@
 
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;
-  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1); /* 
default delay */
+  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); /* 
default delay */
   timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); /* 
default timeout */
   replication = 1;      /* default replication */
   rc = 0;




reply via email to

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