diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-27 14:07:49 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-27 14:07:49 +0100 |
commit | d3b0b69e7d360b4b82c5a5580a7ea21317dfee24 (patch) | |
tree | 894eccdb39ed57e1fadc0bb12a7fabd2b1ede244 /src/cadet/gnunet-service-cadet-new_core.c | |
parent | 052c4fcb11913cad4baa3a4fa2032b2ae2f386e3 (diff) | |
download | gnunet-d3b0b69e7d360b4b82c5a5580a7ea21317dfee24.tar.gz gnunet-d3b0b69e7d360b4b82c5a5580a7ea21317dfee24.zip |
implement tie-breaking in case both peers establish a connection to each other via the same path at the same time, so that only one connection survives
Diffstat (limited to 'src/cadet/gnunet-service-cadet-new_core.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet-new_core.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_core.c b/src/cadet/gnunet-service-cadet-new_core.c index 4a4ead05b..086337c9a 100644 --- a/src/cadet/gnunet-service-cadet-new_core.c +++ b/src/cadet/gnunet-service-cadet-new_core.c | |||
@@ -479,10 +479,30 @@ handle_connection_create (void *cls, | |||
479 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); | 479 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
480 | path = GCPP_get_path_from_route (path_length - 1, | 480 | path = GCPP_get_path_from_route (path_length - 1, |
481 | pids); | 481 | pids); |
482 | GCT_add_inbound_connection (GCP_get_tunnel (origin, | 482 | if (GNUNET_OK != |
483 | GNUNET_YES), | 483 | GCT_add_inbound_connection (GCP_get_tunnel (origin, |
484 | &msg->cid, | 484 | GNUNET_YES), |
485 | path); | 485 | &msg->cid, |
486 | path)) | ||
487 | { | ||
488 | /* Send back BROKEN: duplicate connection on the same path, | ||
489 | we will use the other one. */ | ||
490 | struct GNUNET_MQ_Envelope *env; | ||
491 | struct GNUNET_CADET_ConnectionBrokenMessage *bm; | ||
492 | |||
493 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
494 | "Received CADET_CONNECTION_CREATE from %s for %s, but %s already has a connection. Sending BROKEN\n", | ||
495 | GCP_2s (sender), | ||
496 | GNUNET_sh2s (&msg->cid.connection_of_tunnel), | ||
497 | GCPP_2s (path)); | ||
498 | env = GNUNET_MQ_msg (bm, | ||
499 | GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); | ||
500 | bm->cid = msg->cid; | ||
501 | bm->peer1 = my_full_id; | ||
502 | GCP_send_ooo (sender, | ||
503 | env); | ||
504 | return; | ||
505 | } | ||
486 | return; | 506 | return; |
487 | } | 507 | } |
488 | /* We are merely a hop on the way, check if we can support the route */ | 508 | /* We are merely a hop on the way, check if we can support the route */ |
@@ -611,7 +631,7 @@ handle_connection_broken (void *cls, | |||
611 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 631 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
612 | "Received CONNECTION_BROKEN for connection %s. Destroying it.\n", | 632 | "Received CONNECTION_BROKEN for connection %s. Destroying it.\n", |
613 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); | 633 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
614 | GCC_destroy (cc); | 634 | GCC_destroy_without_core (cc); |
615 | 635 | ||
616 | /* FIXME: also destroy the path up to the specified link! */ | 636 | /* FIXME: also destroy the path up to the specified link! */ |
617 | return; | 637 | return; |
@@ -661,7 +681,7 @@ handle_connection_destroy (void *cls, | |||
661 | "Received CONNECTION_DESTROY for connection %s. Destroying connection.\n", | 681 | "Received CONNECTION_DESTROY for connection %s. Destroying connection.\n", |
662 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); | 682 | GNUNET_sh2s (&msg->cid.connection_of_tunnel)); |
663 | 683 | ||
664 | GCC_destroy (cc); | 684 | GCC_destroy_without_core (cc); |
665 | return; | 685 | return; |
666 | } | 686 | } |
667 | 687 | ||