xvine: fixes
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_neighbours.c
index f42819aa5a6713c947e64a415cdb032e5ec1806e..b13c7bc3cdcda4c300b6515ead8683097fc5f2ad 100644 (file)
 /**
  * How long to wait before sending another find finger trail request
  */
-#define DHT_FIND_FINGER_TRAIL_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50)
+#define DHT_FIND_FINGER_TRAIL_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)
 
 /**
  * How long to wait before sending another verify successor message.
  */
-#define DHT_SEND_VERIFY_SUCCESSOR_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5)
+#define DHT_SEND_VERIFY_SUCCESSOR_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 60)
 
 /**
  * How long at most to wait for transmission of a request to a friend ?
@@ -3499,7 +3499,29 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
       return GNUNET_OK;
     }
   }
-
+  
+  /* Check if you are already a part of put path. */
+  unsigned int i;
+  for (i = 0; i < putlen; i++)
+  {
+    if(0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &put_path[i]))
+    {
+      putlen = i;
+      break;
+    }
+  }
+    
+  /* Add yourself to the list. */
+  struct GNUNET_PeerIdentity pp[putlen + 1];
+  if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
+  {
+    memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity));
+    pp[putlen] = my_identity;
+    putlen++;
+  }
+  else
+    putlen = 0;
+  
   memcpy (&key_value, &(put->key), sizeof (uint64_t));
   if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity)))
   {
@@ -3513,9 +3535,20 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
                                 gettext_noop ("# Next hop to forward the packet not found "
                                 "trail setup request, packet dropped."),
                                 1, GNUNET_NO);
+      
       GNUNET_break_op (0);
+      //FIXME: Adding put here,only to ensure that process does not hang. but
+      // should not be here. fix the logic. 
+      GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time),
+                                &(put->key),putlen, pp, ntohl (put->block_type),
+                                 payload_size, payload);
       return GNUNET_OK;
     }
+    else
+    {
+      GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, 
+                                                            next_hop));
+    }
   }
   else
   {
@@ -3528,27 +3561,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
     best_known_dest = successor.best_known_destination;
   }
   
-  /* Check if you are already a part of put path. */
-  unsigned int i;
-  for (i = 0; i < putlen; i++)
-  {
-    if(0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &put_path[i]))
-    {
-      putlen = i;
-      break;
-    }
-  }
-    
-  /* Add yourself to the list. */
-  struct GNUNET_PeerIdentity pp[putlen + 1];
-  if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
-  {
-    memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity));
-    pp[putlen] = my_identity;
-    putlen++;
-  }
-  else
-    putlen = 0;
+
 
   GDS_CLIENTS_process_put (options,
                            ntohl (put->block_type),