diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-06-08 19:04:24 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-06-08 19:04:24 +0000 |
commit | da6302d6689bb70daa7fcbbed6711193f36ab6bb (patch) | |
tree | 2d3d56ee8c3237fe4f28bc16d98316ae72199f2c /src | |
parent | c9214464dc79316a25914914c16c2b0b0a989ea9 (diff) | |
download | gnunet-da6302d6689bb70daa7fcbbed6711193f36ab6bb.tar.gz gnunet-da6302d6689bb70daa7fcbbed6711193f36ab6bb.zip |
-assertion also does not hold, messy code
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 46 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.c | 77 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnel.c | 4 |
3 files changed, 63 insertions, 64 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 2c9ec0704..21a0ee5c8 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -22,12 +22,9 @@ | |||
22 | * @brief GNUnet CADET service connection handling | 22 | * @brief GNUnet CADET service connection handling |
23 | * @author Bartlomiej Polot | 23 | * @author Bartlomiej Polot |
24 | */ | 24 | */ |
25 | |||
26 | #include "platform.h" | 25 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
28 | |||
29 | #include "gnunet_statistics_service.h" | 27 | #include "gnunet_statistics_service.h" |
30 | |||
31 | #include "cadet_path.h" | 28 | #include "cadet_path.h" |
32 | #include "cadet_protocol.h" | 29 | #include "cadet_protocol.h" |
33 | #include "cadet.h" | 30 | #include "cadet.h" |
@@ -101,7 +98,7 @@ struct CadetFlowControl | |||
101 | /** | 98 | /** |
102 | * Task to poll the peer in case of a lost ACK causes stall. | 99 | * Task to poll the peer in case of a lost ACK causes stall. |
103 | */ | 100 | */ |
104 | struct GNUNET_SCHEDULER_Task * poll_task; | 101 | struct GNUNET_SCHEDULER_Task *poll_task; |
105 | 102 | ||
106 | /** | 103 | /** |
107 | * How frequently to poll for ACKs. | 104 | * How frequently to poll for ACKs. |
@@ -177,32 +174,22 @@ struct CadetConnection | |||
177 | struct GNUNET_CADET_Hash id; | 174 | struct GNUNET_CADET_Hash id; |
178 | 175 | ||
179 | /** | 176 | /** |
180 | * State of the connection. | ||
181 | */ | ||
182 | enum CadetConnectionState state; | ||
183 | |||
184 | /** | ||
185 | * Path being used for the tunnel. At the origin of the connection | 177 | * Path being used for the tunnel. At the origin of the connection |
186 | * it's a pointer to the destination's path pool, otherwise just a copy. | 178 | * it's a pointer to the destination's path pool, otherwise just a copy. |
187 | */ | 179 | */ |
188 | struct CadetPeerPath *path; | 180 | struct CadetPeerPath *path; |
189 | 181 | ||
190 | /** | 182 | /** |
191 | * Position of the local peer in the path. | ||
192 | */ | ||
193 | unsigned int own_pos; | ||
194 | |||
195 | /** | ||
196 | * Task to keep the used paths alive at the owner, | 183 | * Task to keep the used paths alive at the owner, |
197 | * time tunnel out on all the other peers. | 184 | * time tunnel out on all the other peers. |
198 | */ | 185 | */ |
199 | struct GNUNET_SCHEDULER_Task * fwd_maintenance_task; | 186 | struct GNUNET_SCHEDULER_Task *fwd_maintenance_task; |
200 | 187 | ||
201 | /** | 188 | /** |
202 | * Task to keep the used paths alive at the destination, | 189 | * Task to keep the used paths alive at the destination, |
203 | * time tunnel out on all the other peers. | 190 | * time tunnel out on all the other peers. |
204 | */ | 191 | */ |
205 | struct GNUNET_SCHEDULER_Task * bck_maintenance_task; | 192 | struct GNUNET_SCHEDULER_Task *bck_maintenance_task; |
206 | 193 | ||
207 | /** | 194 | /** |
208 | * Queue handle for maintainance traffic. One handle for FWD and BCK since | 195 | * Queue handle for maintainance traffic. One handle for FWD and BCK since |
@@ -211,9 +198,14 @@ struct CadetConnection | |||
211 | struct CadetPeerQueue *maintenance_q; | 198 | struct CadetPeerQueue *maintenance_q; |
212 | 199 | ||
213 | /** | 200 | /** |
214 | * Counter to do exponential backoff when creating a connection (max 64). | 201 | * State of the connection. |
215 | */ | 202 | */ |
216 | unsigned short create_retry; | 203 | enum CadetConnectionState state; |
204 | |||
205 | /** | ||
206 | * Position of the local peer in the path. | ||
207 | */ | ||
208 | unsigned int own_pos; | ||
217 | 209 | ||
218 | /** | 210 | /** |
219 | * Pending message count. | 211 | * Pending message count. |
@@ -224,8 +216,14 @@ struct CadetConnection | |||
224 | * Destroy flag: if true, destroy on last message. | 216 | * Destroy flag: if true, destroy on last message. |
225 | */ | 217 | */ |
226 | int destroy; | 218 | int destroy; |
219 | |||
220 | /** | ||
221 | * Counter to do exponential backoff when creating a connection (max 64). | ||
222 | */ | ||
223 | unsigned short create_retry; | ||
227 | }; | 224 | }; |
228 | 225 | ||
226 | |||
229 | /** | 227 | /** |
230 | * Handle for messages queued but not yet sent. | 228 | * Handle for messages queued but not yet sent. |
231 | */ | 229 | */ |
@@ -237,19 +235,19 @@ struct CadetConnectionQueue | |||
237 | struct CadetPeerQueue *q; | 235 | struct CadetPeerQueue *q; |
238 | 236 | ||
239 | /** | 237 | /** |
240 | * Was this a forced message? (Do not account for it) | ||
241 | */ | ||
242 | int forced; | ||
243 | |||
244 | /** | ||
245 | * Continuation to call once sent. | 238 | * Continuation to call once sent. |
246 | */ | 239 | */ |
247 | GCC_sent cont; | 240 | GCC_sent cont; |
248 | 241 | ||
249 | /** | 242 | /** |
250 | * Closure for @c cont. | 243 | * Closure for @e cont. |
251 | */ | 244 | */ |
252 | void *cont_cls; | 245 | void *cont_cls; |
246 | |||
247 | /** | ||
248 | * Was this a forced message? (Do not account for it) | ||
249 | */ | ||
250 | int forced; | ||
253 | }; | 251 | }; |
254 | 252 | ||
255 | /******************************************************************************/ | 253 | /******************************************************************************/ |
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 57bde4a44..45e38c0fb 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2013, 2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -17,19 +17,18 @@ | |||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | /** | |
21 | 21 | * @file cadet/gnunet-service-cadet_peer.c | |
22 | * @brief GNUnet CADET service connection handling | ||
23 | * @author Bartlomiej Polot | ||
24 | */ | ||
22 | #include "platform.h" | 25 | #include "platform.h" |
23 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
24 | |||
25 | #include "gnunet_signatures.h" | 27 | #include "gnunet_signatures.h" |
26 | |||
27 | #include "gnunet_transport_service.h" | 28 | #include "gnunet_transport_service.h" |
28 | #include "gnunet_core_service.h" | 29 | #include "gnunet_core_service.h" |
29 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
30 | |||
31 | #include "cadet_protocol.h" | 31 | #include "cadet_protocol.h" |
32 | |||
33 | #include "gnunet-service-cadet_peer.h" | 32 | #include "gnunet-service-cadet_peer.h" |
34 | #include "gnunet-service-cadet_dht.h" | 33 | #include "gnunet-service-cadet_dht.h" |
35 | #include "gnunet-service-cadet_connection.h" | 34 | #include "gnunet-service-cadet_connection.h" |
@@ -385,6 +384,7 @@ pop_direct_path (struct CadetPeer *peer) | |||
385 | /***************************** CORE CALLBACKS *********************************/ | 384 | /***************************** CORE CALLBACKS *********************************/ |
386 | /******************************************************************************/ | 385 | /******************************************************************************/ |
387 | 386 | ||
387 | |||
388 | /** | 388 | /** |
389 | * Method called whenever a given peer connects. | 389 | * Method called whenever a given peer connects. |
390 | * | 390 | * |
@@ -392,41 +392,48 @@ pop_direct_path (struct CadetPeer *peer) | |||
392 | * @param peer peer identity this notification is about | 392 | * @param peer peer identity this notification is about |
393 | */ | 393 | */ |
394 | static void | 394 | static void |
395 | core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 395 | core_connect (void *cls, |
396 | const struct GNUNET_PeerIdentity *peer) | ||
396 | { | 397 | { |
397 | struct CadetPeer *mp; | 398 | struct CadetPeer *mp; |
398 | struct CadetPeerPath *path; | 399 | struct CadetPeerPath *path; |
399 | char own_id[16]; | 400 | char own_id[16]; |
400 | 401 | ||
401 | strncpy (own_id, GNUNET_i2s (&my_full_id), 15); | 402 | GNUNET_snprintf (own_id, |
403 | sizeof (own_id), | ||
404 | "%s", | ||
405 | GNUNET_i2s (&my_full_id)); | ||
402 | mp = GCP_get (peer); | 406 | mp = GCP_get (peer); |
403 | if (myid == mp->id) | 407 | if (myid == mp->id) |
404 | { | 408 | { |
405 | LOG (GNUNET_ERROR_TYPE_INFO, "CONNECTED %s (self)\n", own_id); | 409 | LOG (GNUNET_ERROR_TYPE_INFO, |
410 | "CONNECTED %s (self)\n", | ||
411 | own_id); | ||
406 | path = path_new (1); | 412 | path = path_new (1); |
407 | } | 413 | } |
408 | else | 414 | else |
409 | { | 415 | { |
410 | LOG (GNUNET_ERROR_TYPE_INFO, "CONNECTED %s <= %s\n", | 416 | LOG (GNUNET_ERROR_TYPE_INFO, |
411 | own_id, GNUNET_i2s (peer)); | 417 | "CONNECTED %s <= %s\n", |
418 | own_id, | ||
419 | GNUNET_i2s (peer)); | ||
412 | path = path_new (2); | 420 | path = path_new (2); |
413 | path->peers[1] = mp->id; | 421 | path->peers[1] = mp->id; |
414 | GNUNET_PEER_change_rc (mp->id, 1); | 422 | GNUNET_PEER_change_rc (mp->id, 1); |
415 | GNUNET_STATISTICS_update (stats, "# peers", 1, GNUNET_NO); | ||
416 | } | 423 | } |
417 | path->peers[0] = myid; | 424 | path->peers[0] = myid; |
418 | GNUNET_PEER_change_rc (myid, 1); | 425 | GNUNET_PEER_change_rc (myid, 1); |
419 | GCP_add_path (mp, path, GNUNET_YES); | 426 | GCP_add_path (mp, path, GNUNET_YES); |
420 | 427 | GNUNET_STATISTICS_update (stats, | |
428 | "# peers", | ||
429 | 1, | ||
430 | GNUNET_NO); | ||
431 | GNUNET_assert (NULL == mp->connections); | ||
421 | mp->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES); | 432 | mp->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES); |
422 | 433 | ||
423 | if (NULL != GCP_get_tunnel (mp) && | 434 | if ( (NULL != GCP_get_tunnel (mp)) && |
424 | 0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) | 435 | (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) ) |
425 | { | ||
426 | GCP_connect (mp); | 436 | GCP_connect (mp); |
427 | } | ||
428 | |||
429 | return; | ||
430 | } | 437 | } |
431 | 438 | ||
432 | 439 | ||
@@ -467,15 +474,16 @@ core_disconnect (void *cls, | |||
467 | GNUNET_CONTAINER_multihashmap_destroy (p->connections); | 474 | GNUNET_CONTAINER_multihashmap_destroy (p->connections); |
468 | p->connections = NULL; | 475 | p->connections = NULL; |
469 | if (NULL != p->core_transmit) | 476 | if (NULL != p->core_transmit) |
470 | { | 477 | { |
471 | GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit); | 478 | GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit); |
472 | p->core_transmit = NULL; | 479 | p->core_transmit = NULL; |
473 | p->tmt_time.abs_value_us = 0; | 480 | p->tmt_time.abs_value_us = 0; |
474 | } | 481 | } |
475 | GNUNET_STATISTICS_update (stats, "# peers", -1, GNUNET_NO); | 482 | GNUNET_STATISTICS_update (stats, |
476 | 483 | "# peers", | |
484 | -1, | ||
485 | GNUNET_NO); | ||
477 | path_destroy (direct_path); | 486 | path_destroy (direct_path); |
478 | return; | ||
479 | } | 487 | } |
480 | 488 | ||
481 | 489 | ||
@@ -534,7 +542,6 @@ core_init (void *cls, | |||
534 | GNUNET_assert (0); | 542 | GNUNET_assert (0); |
535 | } | 543 | } |
536 | GML_start (); | 544 | GML_start (); |
537 | return; | ||
538 | } | 545 | } |
539 | 546 | ||
540 | 547 | ||
@@ -717,9 +724,8 @@ shutdown_tunnel (void *cls, | |||
717 | * Check if peer is searching for a path (either active or delayed search). | 724 | * Check if peer is searching for a path (either active or delayed search). |
718 | * | 725 | * |
719 | * @param peer Peer to check | 726 | * @param peer Peer to check |
720 | * | 727 | * @return #GNUNET_YES if there is a search active. |
721 | * @return GNUNET_YES if there is a search active. | 728 | * #GNUNET_NO otherwise. |
722 | * GNUNET_NO otherwise. | ||
723 | */ | 729 | */ |
724 | static int | 730 | static int |
725 | is_searching (const struct CadetPeer *peer) | 731 | is_searching (const struct CadetPeer *peer) |
@@ -753,8 +759,7 @@ delayed_search (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
753 | * Destroy the peer_info and free any allocated resources linked to it | 759 | * Destroy the peer_info and free any allocated resources linked to it |
754 | * | 760 | * |
755 | * @param peer The peer_info to destroy. | 761 | * @param peer The peer_info to destroy. |
756 | * | 762 | * @return #GNUNET_OK on success |
757 | * @return GNUNET_OK on success | ||
758 | */ | 763 | */ |
759 | static int | 764 | static int |
760 | peer_destroy (struct CadetPeer *peer) | 765 | peer_destroy (struct CadetPeer *peer) |
@@ -797,7 +802,6 @@ peer_destroy (struct CadetPeer *peer) | |||
797 | * Returns if peer is used (has a tunnel or is neighbor). | 802 | * Returns if peer is used (has a tunnel or is neighbor). |
798 | * | 803 | * |
799 | * @param peer Peer to check. | 804 | * @param peer Peer to check. |
800 | * | ||
801 | * @return #GNUNET_YES if peer is in use. | 805 | * @return #GNUNET_YES if peer is in use. |
802 | */ | 806 | */ |
803 | static int | 807 | static int |
@@ -895,7 +899,6 @@ peer_delete_oldest (void) | |||
895 | * considering the tunnel properties. | 899 | * considering the tunnel properties. |
896 | * | 900 | * |
897 | * @param peer The destination peer. | 901 | * @param peer The destination peer. |
898 | * | ||
899 | * @return Best current known path towards the peer, if any. | 902 | * @return Best current known path towards the peer, if any. |
900 | */ | 903 | */ |
901 | static struct CadetPeerPath * | 904 | static struct CadetPeerPath * |
@@ -932,7 +935,6 @@ peer_get_best_path (const struct CadetPeer *peer) | |||
932 | * - For payload traffic, check the connection flow control. | 935 | * - For payload traffic, check the connection flow control. |
933 | * | 936 | * |
934 | * @param q Queue element to inspect. | 937 | * @param q Queue element to inspect. |
935 | * | ||
936 | * @return #GNUNET_YES if it is sendable, #GNUNET_NO otherwise. | 938 | * @return #GNUNET_YES if it is sendable, #GNUNET_NO otherwise. |
937 | */ | 939 | */ |
938 | static int | 940 | static int |
@@ -1013,7 +1015,6 @@ search_handler (void *cls, const struct CadetPeerPath *path) | |||
1013 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); | 1015 | LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); |
1014 | GCP_connect (peer); | 1016 | GCP_connect (peer); |
1015 | } | 1017 | } |
1016 | return; | ||
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | 1020 | ||
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index 81f6e877b..dace9ef45 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c | |||
@@ -2694,7 +2694,6 @@ destroy_ax (struct CadetTunnel *t) | |||
2694 | } | 2694 | } |
2695 | 2695 | ||
2696 | 2696 | ||
2697 | |||
2698 | /** | 2697 | /** |
2699 | * The peer's ephemeral key has changed: update the symmetrical keys. | 2698 | * The peer's ephemeral key has changed: update the symmetrical keys. |
2700 | * | 2699 | * |
@@ -2788,7 +2787,8 @@ handle_ephemeral (struct CadetTunnel *t, | |||
2788 | * @param msg Key eXchange Pong message. | 2787 | * @param msg Key eXchange Pong message. |
2789 | */ | 2788 | */ |
2790 | static void | 2789 | static void |
2791 | handle_pong (struct CadetTunnel *t, const struct GNUNET_CADET_KX_Pong *msg) | 2790 | handle_pong (struct CadetTunnel *t, |
2791 | const struct GNUNET_CADET_KX_Pong *msg) | ||
2792 | { | 2792 | { |
2793 | uint32_t challenge; | 2793 | uint32_t challenge; |
2794 | 2794 | ||