aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c59
-rw-r--r--src/cadet/gnunet-service-cadet_dht.c1
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c23
-rw-r--r--src/cadet/gnunet-service-cadet_peer.h4
4 files changed, 48 insertions, 39 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index b82c788e9..8c25a46b7 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -1354,7 +1354,12 @@ connection_cancel_queues (struct CadetConnection *c,
1354 { 1354 {
1355 GNUNET_SCHEDULER_cancel (fc->poll_task); 1355 GNUNET_SCHEDULER_cancel (fc->poll_task);
1356 fc->poll_task = NULL; 1356 fc->poll_task = NULL;
1357 LOG (GNUNET_ERROR_TYPE_DEBUG, "Cancel POLL in ccq for fc %p\n", fc); 1357 LOG (GNUNET_ERROR_TYPE_DEBUG, " cancelled POLL task for fc %p\n", fc);
1358 }
1359 if (NULL != fc->poll_msg)
1360 {
1361 GCC_cancel (fc->poll_msg);
1362 LOG (GNUNET_ERROR_TYPE_DEBUG, " cancelled POLL msg for fc %p\n", fc);
1358 } 1363 }
1359 peer = get_hop (c, fwd); 1364 peer = get_hop (c, fwd);
1360 GCP_queue_cancel (peer, c); 1365 GCP_queue_cancel (peer, c);
@@ -1852,6 +1857,30 @@ unregister_neighbors (struct CadetConnection *c)
1852 1857
1853 1858
1854/** 1859/**
1860 * Invalidates all paths towards all peers that comprise the connection which
1861 * rely on the disconnected peer.
1862 *
1863 * ~O(n^3) (peers in connection * paths/peer * links/path)
1864 *
1865 * @param c Connection whose peers' paths to clean.
1866 * @param disconnected Peer that disconnected.
1867 */
1868static void
1869invalidate_paths (struct CadetConnection *c, struct CadetPeer *disconnected)
1870{
1871 struct CadetPeer *peer;
1872 unsigned int i;
1873
1874 for (i = 0; i < c->path->length; i++)
1875 {
1876 peer = GCP_get_short (c->path->peers[i], GNUNET_NO);
1877 if (NULL != peer)
1878 GCP_notify_broken_link (peer, &my_full_id, GCP_get_id (disconnected));
1879 }
1880}
1881
1882
1883/**
1855 * Bind the connection to the peer and the tunnel to that peer. 1884 * Bind the connection to the peer and the tunnel to that peer.
1856 * 1885 *
1857 * If the peer has no tunnel, create one. Update tunnel and connection 1886 * If the peer has no tunnel, create one. Update tunnel and connection
@@ -3045,20 +3074,6 @@ GCC_destroy (struct CadetConnection *c)
3045 path_destroy (c->path); 3074 path_destroy (c->path);
3046 c->path = NULL; 3075 c->path = NULL;
3047 3076
3048 /* Cancel maintainance task (keepalive/timeout) */
3049 if (NULL != c->fwd_fc.poll_msg)
3050 {
3051 GCC_cancel (c->fwd_fc.poll_msg);
3052 LOG (GNUNET_ERROR_TYPE_DEBUG,
3053 " POLL msg FWD canceled\n");
3054 }
3055 if (NULL != c->bck_fc.poll_msg)
3056 {
3057 GCC_cancel (c->bck_fc.poll_msg);
3058 LOG (GNUNET_ERROR_TYPE_DEBUG,
3059 " POLL msg BCK canceled\n");
3060 }
3061
3062 /* Delete from tunnel */ 3077 /* Delete from tunnel */
3063 if (NULL != c->t) 3078 if (NULL != c->t)
3064 GCT_remove_connection (c->t, c); 3079 GCT_remove_connection (c->t, c);
@@ -3069,16 +3084,7 @@ GCC_destroy (struct CadetConnection *c)
3069 GNUNET_SCHEDULER_cancel (c->fwd_maintenance_task); 3084 GNUNET_SCHEDULER_cancel (c->fwd_maintenance_task);
3070 if (NULL != c->bck_maintenance_task) 3085 if (NULL != c->bck_maintenance_task)
3071 GNUNET_SCHEDULER_cancel (c->bck_maintenance_task); 3086 GNUNET_SCHEDULER_cancel (c->bck_maintenance_task);
3072 if (NULL != c->fwd_fc.poll_task) 3087
3073 {
3074 GNUNET_SCHEDULER_cancel (c->fwd_fc.poll_task);
3075 LOG (GNUNET_ERROR_TYPE_DEBUG, " POLL task FWD canceled\n");
3076 }
3077 if (NULL != c->bck_fc.poll_task)
3078 {
3079 GNUNET_SCHEDULER_cancel (c->bck_fc.poll_task);
3080 LOG (GNUNET_ERROR_TYPE_DEBUG, " POLL task BCK canceled\n");
3081 }
3082 if (GNUNET_NO == c->was_removed) 3088 if (GNUNET_NO == c->was_removed)
3083 { 3089 {
3084 GNUNET_break (GNUNET_YES == 3090 GNUNET_break (GNUNET_YES ==
@@ -3289,6 +3295,9 @@ GCC_neighbor_disconnected (struct CadetConnection *c, struct CadetPeer *peer)
3289 LOG (GNUNET_ERROR_TYPE_DEBUG, 3295 LOG (GNUNET_ERROR_TYPE_DEBUG,
3290 "shutting down %s, %s disconnected\n", 3296 "shutting down %s, %s disconnected\n",
3291 GCC_2s (c), peer_name); 3297 GCC_2s (c), peer_name);
3298
3299 invalidate_paths (c, peer);
3300
3292 hop = get_prev_hop (c); 3301 hop = get_prev_hop (c);
3293 if (NULL == hop) 3302 if (NULL == hop)
3294 { 3303 {
diff --git a/src/cadet/gnunet-service-cadet_dht.c b/src/cadet/gnunet-service-cadet_dht.c
index cdc1f5a7f..e4ae52da3 100644
--- a/src/cadet/gnunet-service-cadet_dht.c
+++ b/src/cadet/gnunet-service-cadet_dht.c
@@ -187,6 +187,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
187 s = path_2s (p); 187 s = path_2s (p);
188 LOG (GNUNET_ERROR_TYPE_INFO, "Got path from DHT: %s\n", s); 188 LOG (GNUNET_ERROR_TYPE_INFO, "Got path from DHT: %s\n", s);
189 GNUNET_free_non_null (s); 189 GNUNET_free_non_null (s);
190
190 peer = GCP_get_short (p->peers[p->length - 1], GNUNET_YES); 191 peer = GCP_get_short (p->peers[p->length - 1], GNUNET_YES);
191 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GCP_2s (peer)); 192 LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GCP_2s (peer));
192 h->callback (h->cls, p); 193 h->callback (h->cls, p);
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index d60858321..9d80336bd 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -358,9 +358,8 @@ notify_broken (void *cls,
358 struct CadetConnection *c = value; 358 struct CadetConnection *c = value;
359 359
360 LOG (GNUNET_ERROR_TYPE_DEBUG, 360 LOG (GNUNET_ERROR_TYPE_DEBUG,
361 "Notifying %s due to %s\n", 361 "Notifying %s due to %s disconnect\n",
362 GCC_2s (c), 362 GCC_2s (c), GCP_2s (peer));
363 GCP_2s (peer));
364 GCC_neighbor_disconnected (c, peer); 363 GCC_neighbor_disconnected (c, peer);
365 return GNUNET_YES; 364 return GNUNET_YES;
366} 365}
@@ -1016,8 +1015,8 @@ peer_get_first_message (const struct CadetPeer *peer)
1016 * paths form the initial tunnel, which can be optimized later. 1015 * paths form the initial tunnel, which can be optimized later.
1017 * Called on each result obtained for the DHT search. 1016 * Called on each result obtained for the DHT search.
1018 * 1017 *
1019 * @param cls closure 1018 * @param cls Closure (peer towards a path has been found).
1020 * @param path 1019 * @param path Path created from the DHT query. Will be freed afterwards.
1021 */ 1020 */
1022static void 1021static void
1023search_handler (void *cls, const struct CadetPeerPath *path) 1022search_handler (void *cls, const struct CadetPeerPath *path)
@@ -1537,7 +1536,7 @@ GCP_queue_cancel (struct CadetPeer *peer,
1537 LOG (GNUNET_ERROR_TYPE_DEBUG, 1536 LOG (GNUNET_ERROR_TYPE_DEBUG,
1538 "GMP queue cancel %s\n", 1537 "GMP queue cancel %s\n",
1539 GC_m2s (q->type)); 1538 GC_m2s (q->type));
1540 GNUNET_break (GNUNET_NO == connection_destroyed); 1539 GNUNET_assert (GNUNET_NO == connection_destroyed);
1541 if (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY == q->type) 1540 if (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY == q->type)
1542 { 1541 {
1543 q->c = NULL; 1542 q->c = NULL;
@@ -2066,7 +2065,7 @@ GCP_add_connection (struct CadetPeer *peer,
2066 * is the shortest. 2065 * is the shortest.
2067 * 2066 *
2068 * @param peer Destination peer to add the path to. 2067 * @param peer Destination peer to add the path to.
2069 * @param path New path to add. Last peer must be the peer in arg 1. 2068 * @param path New path to add. Last peer must be @c peer.
2070 * Path will be either used of freed if already known. 2069 * Path will be either used of freed if already known.
2071 * @param trusted Do we trust that this path is real? 2070 * @param trusted Do we trust that this path is real?
2072 * 2071 *
@@ -2206,13 +2205,13 @@ GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed)
2206 for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ; 2205 for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ;
2207 for (i++; i < p->length; i++) 2206 for (i++; i < p->length; i++)
2208 { 2207 {
2209 struct CadetPeer *aux; 2208 struct CadetPeer *peer;
2210 struct CadetPeerPath *copy; 2209 struct CadetPeerPath *copy;
2211 2210
2212 aux = GCP_get_short (p->peers[i], GNUNET_YES); 2211 peer = GCP_get_short (p->peers[i], GNUNET_YES);
2213 copy = path_duplicate (p); 2212 copy = path_duplicate (p);
2214 copy->length = i + 1; 2213 copy->length = i + 1;
2215 GCP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed); 2214 GCP_add_path (peer, copy, 3 > p->length ? GNUNET_NO : confirmed);
2216 } 2215 }
2217 GCC_check_connections (); 2216 GCC_check_connections ();
2218} 2217}
@@ -2531,8 +2530,8 @@ GCP_try_connect (struct CadetPeer *peer)
2531 */ 2530 */
2532void 2531void
2533GCP_notify_broken_link (struct CadetPeer *peer, 2532GCP_notify_broken_link (struct CadetPeer *peer,
2534 struct GNUNET_PeerIdentity *peer1, 2533 const struct GNUNET_PeerIdentity *peer1,
2535 struct GNUNET_PeerIdentity *peer2) 2534 const struct GNUNET_PeerIdentity *peer2)
2536{ 2535{
2537 struct CadetPeerPath *iter; 2536 struct CadetPeerPath *iter;
2538 struct CadetPeerPath *next; 2537 struct CadetPeerPath *next;
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h
index 7a60b33bd..65704f9c4 100644
--- a/src/cadet/gnunet-service-cadet_peer.h
+++ b/src/cadet/gnunet-service-cadet_peer.h
@@ -450,8 +450,8 @@ GCP_try_connect (struct CadetPeer *peer);
450 */ 450 */
451void 451void
452GCP_notify_broken_link (struct CadetPeer *peer, 452GCP_notify_broken_link (struct CadetPeer *peer,
453 struct GNUNET_PeerIdentity *peer1, 453 const struct GNUNET_PeerIdentity *peer1,
454 struct GNUNET_PeerIdentity *peer2); 454 const struct GNUNET_PeerIdentity *peer2);
455 455
456 456
457/** 457/**