[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r31486 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r31486 - gnunet/src/mesh |
Date: |
Tue, 17 Dec 2013 17:16:28 +0100 |
Author: bartpolot
Date: 2013-12-17 17:16:28 +0100 (Tue, 17 Dec 2013)
New Revision: 31486
Modified:
gnunet/src/mesh/gnunet-service-mesh_connection.c
gnunet/src/mesh/gnunet-service-mesh_peer.c
gnunet/src/mesh/mesh_path.c
Log:
- fix core_disconnect handler to avoid reusing the direct path being destroyed
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-12-17 16:14:26 UTC
(rev 31485)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-12-17 16:16:28 UTC
(rev 31486)
@@ -640,11 +640,21 @@
{
GNUNET_PEER_Id id;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " get prev hop %s [%u/%u]\n",
+ GMC_2s (c), c->own_pos, c->path->length);
if (0 == c->own_pos || c->path->length < 2)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " own pos is zero\n");
id = c->path->peers[0];
+ }
else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " own pos is NOT zero\n");
id = c->path->peers[c->own_pos - 1];
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " id: %u\n", id);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " ID: %s\n", GNUNET_i2s (GNUNET_PEER_resolve2
(id)));
return GMP_get_short (id);
}
@@ -661,11 +671,22 @@
{
GNUNET_PEER_Id id;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " get next hop %s [%u/%u]\n",
+ GMC_2s (c), c->own_pos, c->path->length);
if ((c->path->length - 1) == c->own_pos || c->path->length < 2)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " own pos is end\n");
id = c->path->peers[c->path->length - 1];
+ }
else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " own pos is NOT end\n");
id = c->path->peers[c->own_pos + 1];
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " id: %u\n", id);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, " ID: %s\n", GNUNET_i2s (GNUNET_PEER_resolve2
(id)));
+
return GMP_get_short (id);
}
@@ -1152,10 +1173,16 @@
next_peer = get_next_hop (c);
prev_peer = get_prev_hop (c);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to next peer %s\n",
- GMC_2s (c), GMP_2s (next_peer));
- LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to prev peer %s\n",
- GMC_2s (c), GMP_2s (prev_peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "register neighbors for connection %s\n",
+ GMC_2s (c));
+ path_debug (c->path);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "own pos %u\n", c->own_pos);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to next peer %p\n",
+ GMC_2s (c), next_peer);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "next peer %p %s\n", next_peer, GMP_2s
(next_peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to prev peer %p\n",
+ GMC_2s (c), prev_peer);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "prev peer %p %s\n", prev_peer, GMP_2s
(prev_peer));
if (GNUNET_NO == GMP_is_neighbor (next_peer)
|| GNUNET_NO == GMP_is_neighbor (prev_peer))
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-12-17 16:14:26 UTC (rev
31485)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c 2013-12-17 16:16:28 UTC (rev
31486)
@@ -234,6 +234,30 @@
/**
+ * Remove the direct path to the peer.
+ *
+ * @param peer Peer to remove the direct path from.
+ *
+ */
+static struct MeshPeerPath *
+pop_direct_path (struct MeshPeer *peer)
+{
+ struct MeshPeerPath *iter;
+
+ for (iter = peer->path_head; NULL != iter; iter = iter->next)
+ {
+ if (2 <= iter->length)
+ {
+ GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, iter);
+ return iter;
+ }
+ }
+ return NULL;
+}
+
+
+
+/**
* Method called whenever a given peer connects.
*
* @param cls closure
@@ -280,6 +304,7 @@
core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct MeshPeer *p;
+ struct MeshPeerPath *direct_path;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer disconnected\n");
p = GNUNET_CONTAINER_multipeermap_get (peers, peer);
@@ -293,7 +318,7 @@
else
LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n", GMP_2s (p));
-
+ direct_path = pop_direct_path (p);
GNUNET_CONTAINER_multihashmap_iterate (p->connections, ¬ify_broken, p);
GNUNET_CONTAINER_multihashmap_destroy (p->connections);
p->connections = NULL;
@@ -304,6 +329,7 @@
}
GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO);
+ path_destroy (direct_path);
return;
}
@@ -1453,15 +1479,31 @@
GMP_add_connection (struct MeshPeer *peer,
struct MeshConnection *c)
{
+ int result;
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "adding connection %s\n", GMC_2s (c));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "to peer %s\n", GMP_2s (peer));
+
if (NULL == peer->connections)
{
GNUNET_break (0);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %s is not a neighbor!\n",
+ GMP_2s (peer));
return GNUNET_SYSERR;
}
- return GNUNET_CONTAINER_multihashmap_put (peer->connections,
- GMC_get_id (c),
- c,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "peer %s ok, has %u connections.\n",
+ GMP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections));
+ result = GNUNET_CONTAINER_multihashmap_put (peer->connections,
+ GMC_get_id (c),
+ c,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ " now has %u connections.\n",
+ GNUNET_CONTAINER_multihashmap_size (peer->connections));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "result %u\n", result);
+
+ return result;
}
@@ -1654,9 +1696,9 @@
GMP_remove_connection (struct MeshPeer *peer,
const struct MeshConnection *c)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "removing connection %s from peer %s\n",
- GMC_2s (c), GMP_2s (peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "removing connection %s\n", GMC_2s (c));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "from peer %s\n", GMP_2s (peer));
+
if (NULL == peer || NULL == peer->connections)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1664,6 +1706,10 @@
GMP_2s (peer));
return GNUNET_SYSERR;
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "peer %s ok, has %u connections.\n",
+ GMP_2s (peer), GNUNET_CONTAINER_multihashmap_size (peer->connections));
+
return GNUNET_CONTAINER_multihashmap_remove (peer->connections,
GMC_get_id (c),
c);
Modified: gnunet/src/mesh/mesh_path.c
===================================================================
--- gnunet/src/mesh/mesh_path.c 2013-12-17 16:14:26 UTC (rev 31485)
+++ gnunet/src/mesh/mesh_path.c 2013-12-17 16:16:28 UTC (rev 31486)
@@ -187,8 +187,9 @@
{
unsigned int i;
- fprintf (stderr, "PATH:");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH:\n");
for (i = 0; i < p->length; i++)
- fprintf (stderr, " %s", GNUNET_i2s (GNUNET_PEER_resolve2 (p->peers[i])));
- fprintf (stderr, " END\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %s\n",
+ GNUNET_i2s (GNUNET_PEER_resolve2 (p->peers[i])));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "END\n");
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r31486 - gnunet/src/mesh,
gnunet <=