gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r17021 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r17021 - gnunet/src/mesh
Date: Mon, 26 Sep 2011 21:23:56 +0200

Author: bartpolot
Date: 2011-09-26 21:23:55 +0200 (Mon, 26 Sep 2011)
New Revision: 17021

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
Log:
Adapted service API handling to new tree API

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-09-26 19:16:59 UTC (rev 
17020)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-09-26 19:23:55 UTC (rev 
17021)
@@ -1105,14 +1105,25 @@
 void
 tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer)
 {
+//   struct MeshTunnelTreeNode *n;
   struct MeshPeerPath *p;
   struct MeshPeerPath *best_p;
   unsigned int best_cost;
   unsigned int cost;
 
+  if (NULL != tree_find_peer(t->tree->root, peer->id))
+  {
+    /* Already have it, nothing to do. */
+    return;
+  }
+
+  t->peers_total++;
   GNUNET_array_append (peer->tunnels, peer->ntunnels, t);
   if (NULL == (p = peer->path_head))
+  {
+    GNUNET_break (0);
     return;
+  }
 
   best_p = p;
   best_cost = UINT_MAX;
@@ -2599,8 +2610,6 @@
  * @param cls closure
  * @param client identification of the client
  * @param message the actual message (PeerControl)
- *
- * FIXME path
  */
 static void
 handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client,
@@ -2648,21 +2657,33 @@
     return;
   }
 
-  t->peers_total++;
   peer_info = peer_info_get (&peer_msg->peer);
 
-  /* Start DHT search if needed FIXME: if not already connected */
-  if (NULL == peer_info->dhtget)
+  /* Start DHT search if needed, otherwise just add peer to tunnel. */
+  if (NULL == peer_info->dhtget && NULL == peer_info->path_head)
   {
-    peer_info->dhtget = GNUNET_DHT_get_start (dht_handle, 
GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_BLOCK_TYPE_TEST, 
&peer_msg->peer.hashPubKey, 4,  /* replication level */
-                                              GNUNET_DHT_RO_RECORD_ROUTE, 
NULL, /* bloom filter */
-                                              0,        /* mutator */
-                                              NULL,     /* xquery */
-                                              0,        /* xquery bits */
-                                              dht_get_id_handler,
-                                              (void *) peer_info);
+    struct MeshPathInfo *path_info;
+
+    path_info = GNUNET_malloc(sizeof(struct MeshPathInfo));
+    path_info->peer = peer_info;
+    path_info->t = t;
+    peer_info->dhtget = GNUNET_DHT_get_start(dht_handle,       /* handle */
+                                            GNUNET_TIME_UNIT_FOREVER_REL,     
/* timeout */
+                                            GNUNET_BLOCK_TYPE_TEST,   /* type 
*/
+                                            &peer_msg->peer.hashPubKey,   
/*key to search */
+                                            4,        /* replication level */
+                                            GNUNET_DHT_RO_RECORD_ROUTE,
+                                            NULL,     /* bloom filter */
+                                            0,        /* mutator */
+                                            NULL,     /* xquery */
+                                            0,        /* xquery bits */
+                                            dht_get_id_handler,
+                                            (void *) path_info);
   }
-
+  if (NULL != peer_info->path_head)
+  {
+    tunnel_add_peer(t, peer_info);
+  }
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
   return;
 }




reply via email to

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