aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-11 12:23:57 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-11 12:23:57 +0000
commit5b48f06a02b221f2263d3d531b70367209619e24 (patch)
tree7cdfd5d95ee23c04505a0402547e984ef26e6781 /src/mesh
parent0619087fbfdc6d93d421edee1a1320c494f18079 (diff)
downloadgnunet-5b48f06a02b221f2263d3d531b70367209619e24.tar.gz
gnunet-5b48f06a02b221f2263d3d531b70367209619e24.zip
- fixes in DHT handling
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh_connection.c12
-rw-r--r--src/mesh/gnunet-service-mesh_connection.h9
-rw-r--r--src/mesh/gnunet-service-mesh_peer.c53
-rw-r--r--src/mesh/gnunet-service-mesh_peer.h12
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c6
5 files changed, 67 insertions, 25 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c
index e9e16293a..0c03b2da4 100644
--- a/src/mesh/gnunet-service-mesh_connection.c
+++ b/src/mesh/gnunet-service-mesh_connection.c
@@ -568,7 +568,7 @@ send_connection_ack (struct MeshConnection *connection, int fwd)
568 if (MESH_TUNNEL3_NEW == GMT_get_state (t)) 568 if (MESH_TUNNEL3_NEW == GMT_get_state (t))
569 GMT_change_state (t, MESH_TUNNEL3_WAITING); 569 GMT_change_state (t, MESH_TUNNEL3_WAITING);
570 if (MESH_CONNECTION_READY != connection->state) 570 if (MESH_CONNECTION_READY != connection->state)
571 GMC_change_state (connection, MESH_CONNECTION_SENT); 571 connection_change_state (connection, MESH_CONNECTION_SENT);
572} 572}
573 573
574 574
@@ -613,7 +613,7 @@ connection_recreate (struct MeshConnection *c, int fwd)
613{ 613{
614 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending connection recreate\n"); 614 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending connection recreate\n");
615 if (fwd) 615 if (fwd)
616 send_connection_create (c); 616 GMC_send_create (c);
617 else 617 else
618 send_connection_ack (c, GNUNET_NO); 618 send_connection_ack (c, GNUNET_NO);
619} 619}
@@ -1679,7 +1679,7 @@ GMC_init (const struct GNUNET_CONFIGURATION_Handle *c)
1679 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_MSGS_QUEUE", 1679 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_MSGS_QUEUE",
1680 &max_msgs_queue)) 1680 &max_msgs_queue))
1681 { 1681 {
1682 LOG_config_invalid (GNUNET_ERROR_TYPE_ERROR, 1682 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
1683 "MESH", "MAX_MSGS_QUEUE", "MISSING"); 1683 "MESH", "MAX_MSGS_QUEUE", "MISSING");
1684 GNUNET_SCHEDULER_shutdown (); 1684 GNUNET_SCHEDULER_shutdown ();
1685 return; 1685 return;
@@ -1689,7 +1689,7 @@ GMC_init (const struct GNUNET_CONFIGURATION_Handle *c)
1689 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_CONNECTIONS", 1689 GNUNET_CONFIGURATION_get_value_number (c, "MESH", "MAX_CONNECTIONS",
1690 &max_connections)) 1690 &max_connections))
1691 { 1691 {
1692 LOG_config_invalid (GNUNET_ERROR_TYPE_ERROR, 1692 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
1693 "MESH", "MAX_CONNECTIONS", "MISSING"); 1693 "MESH", "MAX_CONNECTIONS", "MISSING");
1694 GNUNET_SCHEDULER_shutdown (); 1694 GNUNET_SCHEDULER_shutdown ();
1695 return; 1695 return;
@@ -1699,7 +1699,7 @@ GMC_init (const struct GNUNET_CONFIGURATION_Handle *c)
1699 GNUNET_CONFIGURATION_get_value_time (c, "MESH", "REFRESH_CONNECTION_TIME", 1699 GNUNET_CONFIGURATION_get_value_time (c, "MESH", "REFRESH_CONNECTION_TIME",
1700 &refresh_connection_time)) 1700 &refresh_connection_time))
1701 { 1701 {
1702 LOG_config_invalid (GNUNET_ERROR_TYPE_ERROR, 1702 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
1703 "MESH", "REFRESH_CONNECTION_TIME", "MISSING"); 1703 "MESH", "REFRESH_CONNECTION_TIME", "MISSING");
1704 GNUNET_SCHEDULER_shutdown (); 1704 GNUNET_SCHEDULER_shutdown ();
1705 return; 1705 return;
@@ -2105,7 +2105,7 @@ enum MeshTunnel3State state;
2105 if (MESH_TUNNEL3_SEARCHING == state || MESH_TUNNEL3_NEW == state) 2105 if (MESH_TUNNEL3_SEARCHING == state || MESH_TUNNEL3_NEW == state)
2106 GMT_change_state (connection->t, MESH_TUNNEL3_WAITING); 2106 GMT_change_state (connection->t, MESH_TUNNEL3_WAITING);
2107 if (MESH_CONNECTION_NEW == connection->state) 2107 if (MESH_CONNECTION_NEW == connection->state)
2108 GMC_change_state (connection, MESH_CONNECTION_SENT); 2108 connection_change_state (connection, MESH_CONNECTION_SENT);
2109} 2109}
2110 2110
2111 2111
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h
index b0ddeabd9..9e9dec512 100644
--- a/src/mesh/gnunet-service-mesh_connection.h
+++ b/src/mesh/gnunet-service-mesh_connection.h
@@ -335,15 +335,6 @@ GMC_bck_keepalive (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
335 335
336 336
337/** 337/**
338 * Change the tunnel state.
339 *
340 * @param c Connection whose state to change.
341 * @param state New state.
342 */
343void
344GMC_change_state (struct MeshConnection* c, enum MeshConnectionState state);
345
346/**
347 * Notify other peers on a connection of a broken link. Mark connections 338 * Notify other peers on a connection of a broken link. Mark connections
348 * to destroy after all traffic has been sent. 339 * to destroy after all traffic has been sent.
349 * 340 *
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c
index 70b88afe3..3a38fc40a 100644
--- a/src/mesh/gnunet-service-mesh_peer.c
+++ b/src/mesh/gnunet-service-mesh_peer.c
@@ -247,13 +247,13 @@ notify_broken (void *cls,
247static void 247static void
248core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) 248core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
249{ 249{
250 struct MeshPeer *pi; 250 struct MeshPeer *mp;
251 struct MeshPeerPath *path; 251 struct MeshPeerPath *path;
252 252
253 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer connected\n"); 253 LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer connected\n");
254 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n", GNUNET_i2s (&my_full_id)); 254 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n", GNUNET_i2s (&my_full_id));
255 pi = GMP_get (peer); 255 mp = GMP_get (peer);
256 if (myid == pi->id) 256 if (myid == mp->id)
257 { 257 {
258 LOG (GNUNET_ERROR_TYPE_DEBUG, " (self)\n"); 258 LOG (GNUNET_ERROR_TYPE_DEBUG, " (self)\n");
259 path = path_new (1); 259 path = path_new (1);
@@ -262,15 +262,15 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
262 { 262 {
263 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n", GNUNET_i2s (peer)); 263 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n", GNUNET_i2s (peer));
264 path = path_new (2); 264 path = path_new (2);
265 path->peers[1] = pi->id; 265 path->peers[1] = mp->id;
266 GNUNET_PEER_change_rc (pi->id, 1); 266 GNUNET_PEER_change_rc (mp->id, 1);
267 GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); 267 GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO);
268 } 268 }
269 path->peers[0] = myid; 269 path->peers[0] = myid;
270 GNUNET_PEER_change_rc (myid, 1); 270 GNUNET_PEER_change_rc (myid, 1);
271 peer_add_path (pi, path, GNUNET_YES); 271 GMP_add_path (mp, path, GNUNET_YES);
272 272
273 pi->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES); 273 mp->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES);
274 return; 274 return;
275} 275}
276 276
@@ -1589,6 +1589,45 @@ GMP_remove_connection (struct MeshPeer *peer,
1589} 1589}
1590 1590
1591/** 1591/**
1592 * Start the DHT search for new paths towards the peer: we don't have
1593 * enough good connections.
1594 *
1595 * @param peer Destination peer.
1596 */
1597void
1598GMP_start_search (struct MeshPeer *peer)
1599{
1600 if (NULL != peer->search_h)
1601 {
1602 GNUNET_break (0);
1603 return;
1604 }
1605
1606 peer->search_h = GMD_search (GMP_get_id (peer), &search_handler, peer);
1607}
1608
1609
1610/**
1611 * Stop the DHT search for new paths towards the peer: we already have
1612 * enough good connections.
1613 *
1614 * @param peer Destination peer.
1615 */
1616void
1617GMP_stop_search (struct MeshPeer *peer)
1618{
1619 if (NULL == peer->search_h)
1620 {
1621 GNUNET_break (0);
1622 return;
1623 }
1624
1625 GMD_search_stop (peer->search_h);
1626 peer->search_h = NULL;
1627}
1628
1629
1630/**
1592 * Get the Full ID of a peer. 1631 * Get the Full ID of a peer.
1593 * 1632 *
1594 * @param peer Peer to get from. 1633 * @param peer Peer to get from.
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h
index 97f928bfd..7cc48fb66 100644
--- a/src/mesh/gnunet-service-mesh_peer.h
+++ b/src/mesh/gnunet-service-mesh_peer.h
@@ -237,9 +237,21 @@ GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed);
237int 237int
238GMP_remove_connection (struct MeshPeer *peer, const struct MeshConnection *c); 238GMP_remove_connection (struct MeshPeer *peer, const struct MeshConnection *c);
239 239
240/**
241 * Start the DHT search for new paths towards the peer: we don't have
242 * enough good connections.
243 *
244 * @param peer Destination peer.
245 */
240void 246void
241GMP_start_search (struct MeshPeer *peer); 247GMP_start_search (struct MeshPeer *peer);
242 248
249/**
250 * Stop the DHT search for new paths towards the peer: we already have
251 * enough good connections.
252 *
253 * @param peer Destination peer.
254 */
243void 255void
244GMP_stop_search (struct MeshPeer *peer); 256GMP_stop_search (struct MeshPeer *peer);
245 257
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index a8cb883f6..e117a9481 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -1179,10 +1179,10 @@ GMT_is_loopback (const struct MeshTunnel3 *t)
1179int 1179int
1180GMT_is_path_used (const struct MeshTunnel3 *t, const struct MeshPeerPath *p) 1180GMT_is_path_used (const struct MeshTunnel3 *t, const struct MeshPeerPath *p)
1181{ 1181{
1182 struct MeshTConnection *c; 1182 struct MeshTConnection *iter;
1183 1183
1184 for (c = t->connection_head; NULL != c; c = c->next) 1184 for (iter = t->connection_head; NULL != iter; iter = iter->next)
1185 if (GMC_get_path (c) == p) 1185 if (GMC_get_path (iter->c) == p)
1186 return GNUNET_YES; 1186 return GNUNET_YES;
1187 1187
1188 return GNUNET_NO; 1188 return GNUNET_NO;