aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-07-21 00:15:29 +0000
committerBart Polot <bart@net.in.tum.de>2014-07-21 00:15:29 +0000
commit5cafb23ffb6c30f7f32227219e351546ae0a5e56 (patch)
tree811a1b47cc259b53f73259613bed9745524fc51c /src/cadet
parent3e82db5582e578e52e0a9e06fb0af1a297338a6f (diff)
downloadgnunet-5cafb23ffb6c30f7f32227219e351546ae0a5e56.tar.gz
gnunet-5cafb23ffb6c30f7f32227219e351546ae0a5e56.zip
- fix tunnel state management after connection failure<
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c4
-rw-r--r--src/cadet/gnunet-service-cadet_local.c4
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c6
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c29
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.h12
5 files changed, 44 insertions, 11 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index ab8f94fc4..c1a75fca4 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -1709,7 +1709,7 @@ GCC_handle_confirm (void *cls, const struct GNUNET_PeerIdentity *peer,
1709 } 1709 }
1710 else if (get_prev_hop (c) == pi) 1710 else if (get_prev_hop (c) == pi)
1711 { 1711 {
1712 LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK\n"); 1712 LOG (GNUNET_ERROR_TYPE_DEBUG, " FINAL ACK\n");
1713 fwd = GNUNET_YES; 1713 fwd = GNUNET_YES;
1714 connection_change_state (c, CADET_CONNECTION_READY); 1714 connection_change_state (c, CADET_CONNECTION_READY);
1715 } 1715 }
@@ -2693,7 +2693,7 @@ GCC_get_allowed (struct CadetConnection *c, int fwd)
2693 struct CadetFlowControl *fc; 2693 struct CadetFlowControl *fc;
2694 2694
2695 fc = fwd ? &c->fwd_fc : &c->bck_fc; 2695 fc = fwd ? &c->fwd_fc : &c->bck_fc;
2696 if (GC_is_pid_bigger(fc->last_pid_recv, fc->last_ack_sent)) 2696 if (GC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent))
2697 { 2697 {
2698 return 0; 2698 return 0;
2699 } 2699 }
diff --git a/src/cadet/gnunet-service-cadet_local.c b/src/cadet/gnunet-service-cadet_local.c
index b612be6dd..10e1a0ab4 100644
--- a/src/cadet/gnunet-service-cadet_local.c
+++ b/src/cadet/gnunet-service-cadet_local.c
@@ -771,7 +771,7 @@ get_all_tunnels_iterator (void *cls,
771 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS); 771 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS);
772 msg.destination = *peer; 772 msg.destination = *peer;
773 msg.channels = htonl (GCT_count_channels (t)); 773 msg.channels = htonl (GCT_count_channels (t));
774 msg.connections = htonl (GCT_count_connections (t)); 774 msg.connections = htonl (GCT_count_any_connections (t));
775 msg.cstate = htons ((uint16_t) GCT_get_cstate (t)); 775 msg.cstate = htons ((uint16_t) GCT_get_cstate (t));
776 msg.estate = htons ((uint16_t) GCT_get_estate (t)); 776 msg.estate = htons ((uint16_t) GCT_get_estate (t));
777 777
@@ -900,7 +900,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client,
900 900
901 /* Initialize context */ 901 /* Initialize context */
902 ch_n = GCT_count_channels (t); 902 ch_n = GCT_count_channels (t);
903 c_n = GCT_count_connections (t); 903 c_n = GCT_count_any_connections (t);
904 904
905 size = sizeof (struct GNUNET_CADET_LocalInfoTunnel); 905 size = sizeof (struct GNUNET_CADET_LocalInfoTunnel);
906 size += c_n * sizeof (struct GNUNET_CADET_Hash); 906 size += c_n * sizeof (struct GNUNET_CADET_Hash);
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index c037c6171..11b3fc9a8 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -1708,8 +1708,7 @@ GCP_connect (struct CadetPeer *peer)
1708 { 1708 {
1709 GCD_search_stop (peer->search_h); 1709 GCD_search_stop (peer->search_h);
1710 peer->search_h = NULL; 1710 peer->search_h = NULL;
1711 LOG (GNUNET_ERROR_TYPE_DEBUG, 1711 LOG (GNUNET_ERROR_TYPE_DEBUG, " Stopping DHT GET for peer %s\n",
1712 " Stopping DHT GET for peer %s\n",
1713 GCP_2s (peer)); 1712 GCP_2s (peer));
1714 } 1713 }
1715 1714
@@ -1721,7 +1720,8 @@ GCP_connect (struct CadetPeer *peer)
1721 LOG (GNUNET_ERROR_TYPE_DEBUG, 1720 LOG (GNUNET_ERROR_TYPE_DEBUG,
1722 " Starting DHT GET for peer %s\n", GCP_2s (peer)); 1721 " Starting DHT GET for peer %s\n", GCP_2s (peer));
1723 peer->search_h = GCD_search (id, &search_handler, peer); 1722 peer->search_h = GCD_search (id, &search_handler, peer);
1724 if (CADET_TUNNEL_NEW == GCT_get_cstate (t)) 1723 if (CADET_TUNNEL_NEW == GCT_get_cstate (t)
1724 || 0 == GCT_count_any_connections (t))
1725 GCT_change_cstate (t, CADET_TUNNEL_SEARCHING); 1725 GCT_change_cstate (t, CADET_TUNNEL_SEARCHING);
1726 } 1726 }
1727} 1727}
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index 2d8aa90b6..6e5137925 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -2361,8 +2361,7 @@ GCT_remove_connection (struct CadetTunnel *t,
2361 && CADET_TUNNEL_SHUTDOWN != t->cstate 2361 && CADET_TUNNEL_SHUTDOWN != t->cstate
2362 && GNUNET_NO == shutting_down) 2362 && GNUNET_NO == shutting_down)
2363 { 2363 {
2364 LOG (GNUNET_ERROR_TYPE_DEBUG, " no more connections, getting new ones\n"); 2364 LOG (GNUNET_ERROR_TYPE_DEBUG, " too few connections, getting new ones\n");
2365 GCT_change_cstate (t, CADET_TUNNEL_SEARCHING);
2366 GCP_connect (t->peer); 2365 GCP_connect (t->peer);
2367 return; 2366 return;
2368 } 2367 }
@@ -2674,13 +2673,36 @@ GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p)
2674 2673
2675 2674
2676/** 2675/**
2677 * Count created connections of a tunnel. Not necessarily ready connections! 2676 * Count all created connections of a tunnel. Not necessarily ready connections!
2678 * 2677 *
2679 * @param t Tunnel on which to count. 2678 * @param t Tunnel on which to count.
2680 * 2679 *
2681 * @return Number of connections created, either being established or ready. 2680 * @return Number of connections created, either being established or ready.
2682 */ 2681 */
2683unsigned int 2682unsigned int
2683GCT_count_any_connections (struct CadetTunnel *t)
2684{
2685 struct CadetTConnection *iter;
2686 unsigned int count;
2687
2688 if (NULL == t)
2689 return 0;
2690
2691 for (count = 0, iter = t->connection_head; NULL != iter; iter = iter->next)
2692 count++;
2693
2694 return count;
2695}
2696
2697
2698/**
2699 * Count established (ready) connections of a tunnel.
2700 *
2701 * @param t Tunnel on which to count.
2702 *
2703 * @return Number of connections.
2704 */
2705unsigned int
2684GCT_count_connections (struct CadetTunnel *t) 2706GCT_count_connections (struct CadetTunnel *t)
2685{ 2707{
2686 struct CadetTConnection *iter; 2708 struct CadetTConnection *iter;
@@ -2696,6 +2718,7 @@ GCT_count_connections (struct CadetTunnel *t)
2696 return count; 2718 return count;
2697} 2719}
2698 2720
2721
2699/** 2722/**
2700 * Count channels of a tunnel. 2723 * Count channels of a tunnel.
2701 * 2724 *
diff --git a/src/cadet/gnunet-service-cadet_tunnel.h b/src/cadet/gnunet-service-cadet_tunnel.h
index f94153258..382fcdf33 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.h
+++ b/src/cadet/gnunet-service-cadet_tunnel.h
@@ -51,7 +51,7 @@ enum CadetTunnelCState
51 CADET_TUNNEL_NEW, 51 CADET_TUNNEL_NEW,
52 52
53 /** 53 /**
54 * Path to the peer not known yet. 54 * No path to the peer known yet.
55 */ 55 */
56 CADET_TUNNEL_SEARCHING, 56 CADET_TUNNEL_SEARCHING,
57 57
@@ -312,6 +312,16 @@ struct CadetConnection *
312GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p); 312GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p);
313 313
314/** 314/**
315 * Count all created connections of a tunnel. Not necessarily ready connections!
316 *
317 * @param t Tunnel on which to count.
318 *
319 * @return Number of connections created, either being established or ready.
320 */
321unsigned int
322GCT_count_any_connections (struct CadetTunnel *t);
323
324/**
315 * Count established (ready) connections of a tunnel. 325 * Count established (ready) connections of a tunnel.
316 * 326 *
317 * @param t Tunnel on which to count. 327 * @param t Tunnel on which to count.