gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r34116 - gnunet/src/dht
Date: Wed, 6 Aug 2014 16:15:17 +0200

Author: supriti
Date: 2014-08-06 16:15:17 +0200 (Wed, 06 Aug 2014)
New Revision: 34116

Modified:
   gnunet/src/dht/gnunet-service-xdht_neighbours.c
   gnunet/src/dht/gnunet-service-xdht_routing.c
Log:
xvine: fixes


Modified: gnunet/src/dht/gnunet-service-xdht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-06 11:07:42 UTC 
(rev 34115)
+++ gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-06 14:15:17 UTC 
(rev 34116)
@@ -1431,7 +1431,7 @@
     GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# P2P messages dropped 
due to full queue"),
                                1, GNUNET_NO);
   }
-
+  
   pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
   pending->importance = 0;    /* FIXME */
   pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
@@ -3051,7 +3051,25 @@
   return new_trail;
 }
 
+#if 0
+/* Store the successor for path tracking */
+  if (track_topology &&  (NULL != GDS_stats))
+  {
+    char *my_id_str;
+    char *succ_id_str;
+    char *key;
 
+    my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity));
+    succ_id_str = GNUNET_strdup (GNUNET_i2s
+                                 (&successor->finger_identity));
+    GNUNET_asprintf (&key, "XDHT:0:%.4s:%.4s", my_id_str, succ_id_str);
+    GNUNET_free (my_id_str);
+    GNUNET_free (succ_id_str);
+    GNUNET_STATISTICS_update (GDS_stats, "key", 1, 0);
+    GNUNET_free (key);
+  }
+#endif
+
 /**
  * Periodic task to verify current successor. There can be multiple trails to 
reach
  * to successor, choose the shortest one and send verify successor message
@@ -3083,26 +3101,16 @@
                                     NULL);
 
   successor = &finger_table[0];
-  i = 0;
-  trail = &successor->trail_list[i];
-
-  /* Store the successor for path tracking */
-  if (track_topology &&  (NULL != GDS_stats))
+  for (i = 0; i < successor->trails_count; i++)
   {
-    char *my_id_str;
-    char *succ_id_str;
-    char *key;
-
-    my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity));
-    succ_id_str = GNUNET_strdup (GNUNET_i2s
-                                 (&successor->finger_identity));
-    GNUNET_asprintf (&key, "XDHT:0:%.4s:%.4s", my_id_str, succ_id_str);
-    GNUNET_free (my_id_str);
-    GNUNET_free (succ_id_str);
-    GNUNET_STATISTICS_update (GDS_stats, "key", 1, 0);
-    GNUNET_free (key);
+    trail = &successor->trail_list[i];
+    if(GNUNET_YES == trail->is_present)
+      break;
   }
-
+  
+  if (i == successor->trails_count)
+    return;
+  
   GNUNET_assert(0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity,
                                                       
&successor->finger_identity));
 
@@ -4202,7 +4210,6 @@
 
   /*TODO:URGENT Check if I am already present in the trail. If yes then its an 
error,
    as in trail setup we ensure that it should never happen. */
-
   /* Am I the one who initiated the query? */
   if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity)))
   {
@@ -4377,7 +4384,7 @@
       if(0 != GNUNET_CRYPTO_cmp_peer_identity (&trail_1[i],&trail_2[j]))
         continue;
       
-      *joined_trail_len = i + (trail_2_len - j);
+      *joined_trail_len = i + (trail_2_len - j) + 1;
       joined_trail = GNUNET_malloc (*joined_trail_len * 
                                     sizeof(struct GNUNET_PeerIdentity));
       
@@ -4679,8 +4686,7 @@
    * the trail. */
   if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity)))
   {
-    next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST);
-    
+    next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST);   
 
     if (NULL == next_hop)
     {
       GNUNET_break_op (0);
@@ -4706,15 +4712,39 @@
    * it.  */
   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)))
   {
-    trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer,
-                                                         trail,
-                                                         trail_length,
-                                                         
&trail_src_to_curr_pred_len);
+    /* Check if trail contains current_predecessor. */
+    unsigned int i;
+    for (i = 0; i < trail_length; i++)
+    {
+      if(0 != GNUNET_CRYPTO_cmp_peer_identity(&trail[i],
+                                              
&current_predecessor.finger_identity))
+        continue;
+      
+      flag = 1;
+      trail_src_to_curr_pred_len = i;
+      trail_src_to_curr_pred = GNUNET_malloc (trail_src_to_curr_pred_len *
+                                              sizeof(struct 
GNUNET_PeerIdentity));
+      unsigned int k = 0;
+      
+      while(k < i)
+      {
+        trail_src_to_curr_pred[k] = trail[k];
+        k++;
+      }
+    }
+ 
+    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);
+    }
   }
   else
   {
@@ -4979,6 +5009,7 @@
   trail_id = vsrm->trail_id;
   probable_successor = vsrm->probable_successor;
   current_successor = vsrm->current_successor;
+ 
 
   /* I am the querying_peer. */
   if(0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity)))
@@ -5050,13 +5081,18 @@
   source  = nsm->source_peer;
   new_successor = nsm->new_successor;
   trail_id = nsm->trail_id;
+  
 
   //FIXME: add a check to make sure peer is correct.
 
   /* I am the new_successor to source_peer. */
   if ( 0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &new_successor))
   {
-    GDS_ROUTING_add (trail_id, *peer, my_identity);
+    if(trail_length > 0)
+      GNUNET_assert(0 == GNUNET_CRYPTO_cmp_peer_identity(&trail[trail_length - 
1],
+                                                          peer));
+    else 
+      GNUNET_assert(0 == GNUNET_CRYPTO_cmp_peer_identity(&source, peer));
     compare_and_update_predecessor (source, trail, trail_length);
     return GNUNET_OK;
   }
@@ -5078,7 +5114,6 @@
 
   /* Add an entry in routing table for trail from source to its new successor. 
*/
   GNUNET_assert (GNUNET_OK == GDS_ROUTING_add (trail_id, *peer, next_hop));
-
   GNUNET_assert (NULL !=
                 (target_friend =
                  GNUNET_CONTAINER_multipeermap_get (friend_peermap, 
&next_hop)));

Modified: gnunet/src/dht/gnunet-service-xdht_routing.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_routing.c        2014-08-06 11:07:42 UTC 
(rev 34115)
+++ gnunet/src/dht/gnunet-service-xdht_routing.c        2014-08-06 14:15:17 UTC 
(rev 34116)
@@ -220,6 +220,7 @@
                                             disconnected_peer))
   {
     my_identity = GDS_NEIGHBOURS_get_my_id ();
+
     if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, 
                                               &remove_trail->next_hop))
     {




reply via email to

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