aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-07-22 02:54:12 +0000
committerBart Polot <bart@net.in.tum.de>2014-07-22 02:54:12 +0000
commit5886b0a23ebbcac2e8ed1edfcef63ea2188c68c5 (patch)
treed068073c959a70e6e9a5a784f1d60a85783f2e69 /src/cadet
parent42ca364c4f55d19d64355c57ac983fc02e058fa5 (diff)
downloadgnunet-5886b0a23ebbcac2e8ed1edfcef63ea2188c68c5.tar.gz
gnunet-5886b0a23ebbcac2e8ed1edfcef63ea2188c68c5.zip
- add connection state BROKEN for connections destroyed on behalf of intermediate nodes
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c16
-rw-r--r--src/cadet/gnunet-service-cadet_connection.h5
2 files changed, 15 insertions, 6 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 9d2583d5f..b9eb5991d 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -378,6 +378,8 @@ GCC_state2s (enum CadetConnectionState s)
378 return "CADET_CONNECTION_READY"; 378 return "CADET_CONNECTION_READY";
379 case CADET_CONNECTION_DESTROYED: 379 case CADET_CONNECTION_DESTROYED:
380 return "CADET_CONNECTION_DESTROYED"; 380 return "CADET_CONNECTION_DESTROYED";
381 case CADET_CONNECTION_BROKEN:
382 return "CADET_CONNECTION_BROKEN";
381 default: 383 default:
382 GNUNET_break (0); 384 GNUNET_break (0);
383 LOG (GNUNET_ERROR_TYPE_ERROR, " conn state %u unknown!\n", s); 385 LOG (GNUNET_ERROR_TYPE_ERROR, " conn state %u unknown!\n", s);
@@ -424,7 +426,7 @@ connection_change_state (struct CadetConnection* c,
424 LOG (GNUNET_ERROR_TYPE_DEBUG, 426 LOG (GNUNET_ERROR_TYPE_DEBUG,
425 "Connection %s state %s -> %s\n", 427 "Connection %s state %s -> %s\n",
426 GCC_2s (c), GCC_state2s (c->state), GCC_state2s (state)); 428 GCC_2s (c), GCC_state2s (c->state), GCC_state2s (state));
427 if (CADET_CONNECTION_DESTROYED == c->state) 429 if (CADET_CONNECTION_DESTROYED <= c->state) /* Destroyed or broken. */
428 { 430 {
429 LOG (GNUNET_ERROR_TYPE_DEBUG, "state not changing anymore\n"); 431 LOG (GNUNET_ERROR_TYPE_DEBUG, "state not changing anymore\n");
430 return; 432 return;
@@ -1415,7 +1417,7 @@ unregister_neighbors (struct CadetConnection *c)
1415 if (GNUNET_OK != GCP_remove_connection (peer, c)) 1417 if (GNUNET_OK != GCP_remove_connection (peer, c))
1416 { 1418 {
1417 GNUNET_assert (CADET_CONNECTION_NEW == c->state 1419 GNUNET_assert (CADET_CONNECTION_NEW == c->state
1418 || CADET_CONNECTION_DESTROYED == c->state); 1420 || CADET_CONNECTION_DESTROYED <= c->state);
1419 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state); 1421 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state);
1420 if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG); 1422 if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG);
1421 } 1423 }
@@ -1424,7 +1426,7 @@ unregister_neighbors (struct CadetConnection *c)
1424 if (GNUNET_OK != GCP_remove_connection (peer, c)) 1426 if (GNUNET_OK != GCP_remove_connection (peer, c))
1425 { 1427 {
1426 GNUNET_assert (CADET_CONNECTION_NEW == c->state 1428 GNUNET_assert (CADET_CONNECTION_NEW == c->state
1427 || CADET_CONNECTION_DESTROYED == c->state); 1429 || CADET_CONNECTION_DESTROYED <= c->state);
1428 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state); 1430 LOG (GNUNET_ERROR_TYPE_DEBUG, " cstate: %u\n", c->state);
1429 if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG); 1431 if (NULL != c->t) GCT_debug (c->t, GNUNET_ERROR_TYPE_DEBUG);
1430 } 1432 }
@@ -1840,7 +1842,7 @@ GCC_handle_broken (void* cls,
1840 endpoint = GCP_get_short (c->path->peers[c->path->length - 1]); 1842 endpoint = GCP_get_short (c->path->peers[c->path->length - 1]);
1841 path_invalidate (c->path); 1843 path_invalidate (c->path);
1842 GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2); 1844 GCP_notify_broken_link (endpoint, &msg->peer1, &msg->peer2);
1843 c->state = CADET_CONNECTION_DESTROYED; 1845 c->state = CADET_CONNECTION_BROKEN;
1844 GCT_remove_connection (t, c); 1846 GCT_remove_connection (t, c);
1845 c->t = NULL; 1847 c->t = NULL;
1846 pending = c->pending_messages; 1848 pending = c->pending_messages;
@@ -1853,8 +1855,10 @@ GCC_handle_broken (void* cls,
1853 GCT_resend_message (out_msg, t); 1855 GCT_resend_message (out_msg, t);
1854 } 1856 }
1855 /* All pending messages should have been popped, 1857 /* All pending messages should have been popped,
1856 * and the connection destroyed by the continuation. */ 1858 * and the connection destroyed by the continuation.
1857 if (0 < pending) 1859 * If last message was just deleted, then continuation wasn't called.
1860 */
1861 if (0 < pending || 0 < del)
1858 { 1862 {
1859 GNUNET_break (0); 1863 GNUNET_break (0);
1860 GCC_destroy (c); 1864 GCC_destroy (c);
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h
index 90a06e62f..6a2eff7de 100644
--- a/src/cadet/gnunet-service-cadet_connection.h
+++ b/src/cadet/gnunet-service-cadet_connection.h
@@ -69,6 +69,11 @@ enum CadetConnectionState
69 * Connection to be destroyed, just waiting to empty queues. 69 * Connection to be destroyed, just waiting to empty queues.
70 */ 70 */
71 CADET_CONNECTION_DESTROYED, 71 CADET_CONNECTION_DESTROYED,
72
73 /**
74 * Connection to be destroyed because of a distant peer, same as DESTROYED.
75 */
76 CADET_CONNECTION_BROKEN,
72}; 77};
73 78
74 79