[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17192 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17192 - gnunet/src/mesh |
Date: |
Wed, 5 Oct 2011 10:54:30 +0200 |
Author: bartpolot
Date: 2011-10-05 10:54:30 +0200 (Wed, 05 Oct 2011)
New Revision: 17192
Modified:
gnunet/src/mesh/gnunet-service-mesh.c
Log:
Adapted path generation to new DHT_RECORD_ROUTE behavior
Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c 2011-10-05 08:53:05 UTC (rev
17191)
+++ gnunet/src/mesh/gnunet-service-mesh.c 2011-10-05 08:54:30 UTC (rev
17192)
@@ -139,6 +139,11 @@
struct GNUNET_DHT_GetHandle *dhtget;
/**
+ * Task to reissue the DHT get request a path for this peer
+ */
+ GNUNET_SCHEDULER_TaskIdentifier dhtget_task;
+
+ /**
* Handles to stop queued transmissions for this peer
*/
struct GNUNET_CORE_TransmitHandle *core_transmit[CORE_QUEUE_SIZE];
@@ -346,6 +351,11 @@
*/
struct GNUNET_DHT_GetHandle *dht_get_type;
+ /**
+ * Task to reissue the DHT get request for a type
+ */
+ GNUNET_SCHEDULER_TaskIdentifier dht_get_type_task;
+
#if MESH_DEBUG
/**
* ID of the client, for debug messages
@@ -764,7 +774,7 @@
path_info->peer = peer_d;
path_info->t = peer->tunnels[i];
peer_d->dhtget = GNUNET_DHT_get_start(dht_handle, /* handle */
- GNUNET_TIME_UNIT_FOREVER_REL,
/* timeout */
+ GNUNET_TIME_UNIT_SECONDS, /*
timeout */
GNUNET_BLOCK_TYPE_TEST, /* type
*/
&id.hashPubKey, /*key to search
*/
4, /* replication level */
@@ -859,7 +869,9 @@
GNUNET_PEER_Id id;
int i;
- p = path_new (0);
+ p = path_new (1);
+ p->peers[0] = myid;
+ GNUNET_PEER_change_rc(myid, 1);
i = get_path_length;
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: GET has %d hops.\n", i);
for (i--; i >= 0; i--)
@@ -872,10 +884,9 @@
}
else
{
- p->peers =
- GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1));
+ p->length++;
+ p->peers = GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) *
p->length);
p->peers[p->length] = id;
- p->length++;
}
}
i = put_path_length;
@@ -883,6 +894,14 @@
for (i--; i >= 0; i--)
{
id = GNUNET_PEER_intern (&put_path[i]);
+ if (id == myid)
+ {
+ /* PUT path went through us, so discard the path up until now and start
+ * from here to get a much shorter (and loop-free) path.
+ */
+ path_destroy (p);
+ p = path_new (0);
+ }
if (p->length > 0 && id == p->peers[p->length - 1])
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "MESH: Optimizing 1 hop out.\n");
@@ -890,10 +909,9 @@
}
else
{
- p->peers =
- GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1));
+ p->length++;
+ p->peers = GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) *
p->length);
p->peers[p->length] = id;
- p->length++;
}
}
#if MESH_DEBUG
@@ -2132,9 +2150,9 @@
dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
+ unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
+ unsigned int put_path_length,
enum GNUNET_BLOCK_Type type, size_t size, const void *data)
{
struct MeshPathInfo *path_info = cls;
@@ -2155,7 +2173,7 @@
// Find ourselves some alternate initial path to the destination: retry
GNUNET_DHT_get_stop (path_info->peer->dhtget);
path_info->peer->dhtget = GNUNET_DHT_get_start (dht_handle, /*
handle */
-
GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */
+
GNUNET_TIME_UNIT_SECONDS, /* timeout */
GNUNET_BLOCK_TYPE_TEST,
/* type */
&pi.hashPubKey, /*key
to search */
4, /* replication
level */
@@ -2246,7 +2264,7 @@
return;
}
GNUNET_assert (NULL != t->client);
- GNUNET_DHT_get_stop (t->client->dht_get_type);
+ GNUNET_DHT_get_stop (t->client->dht_get_type); /* FIXME move to task? */
t->client->dht_get_type = NULL;
peer_info = peer_info_get (pi);
GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info,
@@ -2261,7 +2279,7 @@
/* we don't have a route to the peer, let's try a direct lookup */
peer_info->dhtget = GNUNET_DHT_get_start (dht_handle,
/* handle */
- GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_TIME_UNIT_SECONDS,
/* timeout */
GNUNET_BLOCK_TYPE_TEST,
/* block type */
@@ -2327,6 +2345,18 @@
}
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+dht_get_type_restart (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+
+}
+
/******************************************************************************/
/********************* MESH LOCAL HANDLES
**************************/
/******************************************************************************/
@@ -2381,7 +2411,10 @@
if (NULL != c->types)
GNUNET_CONTAINER_multihashmap_destroy (c->types);
if (NULL != c->dht_get_type)
+ {
+ GNUNET_SCHEDULER_cancel (c->dht_get_type_task);
GNUNET_DHT_get_stop (c->dht_get_type);
+ }
GNUNET_CONTAINER_DLL_remove (clients, clients_tail, c);
next = c->next;
GNUNET_free (c);
@@ -2704,7 +2737,7 @@
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_TIME_UNIT_SECONDS, /*
timeout */
GNUNET_BLOCK_TYPE_TEST, /* type
*/
&peer_msg->peer.hashPubKey,
/*key to search */
4, /* replication level */
@@ -2892,6 +2925,7 @@
/* Ok, lets find a peer offering the service */
if (c->dht_get_type)
{
+ GNUNET_SCHEDULER_cancel (c->dht_get_type_task);
GNUNET_DHT_get_stop (c->dht_get_type);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: looking in DHT for %s\n",
@@ -2901,6 +2935,9 @@
GNUNET_BLOCK_TYPE_TEST, &hash, 10U,
GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0,
&dht_get_type_handler, t);
+ c->dht_get_type_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS,
+ &dht_get_type_restart,
+ NULL);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
@@ -3228,7 +3265,10 @@
{
for (c = clients; NULL != c; c = c->next)
if (NULL != c->dht_get_type)
+ {
+ GNUNET_SCHEDULER_cancel(c->dht_get_type_task);
GNUNET_DHT_get_stop (c->dht_get_type);
+ }
GNUNET_DHT_disconnect (dht_handle);
dht_handle = NULL;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17192 - gnunet/src/mesh,
gnunet <=