aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-10-14 16:31:36 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-10-14 16:31:36 +0000
commit14c1597bdc566612ac267c278b71fefec97fcbde (patch)
tree051d094914b79f5a789761ac5873e7d4a904f401 /src/transport
parent9a00e42171a1e91c577ed83cafc3eebaa27ccc96 (diff)
downloadgnunet-14c1597bdc566612ac267c278b71fefec97fcbde.tar.gz
gnunet-14c1597bdc566612ac267c278b71fefec97fcbde.zip
increasign sockets for limited test
reverting neighbours: nice idea...not so easy...but ats is more important
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c71
-rw-r--r--src/transport/test_transport_api_limited_sockets.c2
2 files changed, 15 insertions, 58 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index a3582d5b5..b0e639984 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -530,8 +530,8 @@ neighbour_timeout_task (void *cls,
530 n->timeout_task = GNUNET_SCHEDULER_NO_TASK; 530 n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
531 if (GNUNET_YES == n->is_connected) 531 if (GNUNET_YES == n->is_connected)
532 GNUNET_STATISTICS_update (GST_stats, 532 GNUNET_STATISTICS_update (GST_stats,
533 gettext_noop ("# peers disconnected due to timeout"), 1, 533 gettext_noop ("# peers disconnected due to timeout"), 1,
534 GNUNET_NO); 534 GNUNET_NO);
535 disconnect_neighbour (n); 535 disconnect_neighbour (n);
536} 536}
537 537
@@ -614,52 +614,6 @@ GST_neighbours_stop ()
614 disconnect_notify_cb = NULL; 614 disconnect_notify_cb = NULL;
615} 615}
616 616
617struct AddressContext
618{
619 struct NeighbourMapEntry * n;
620 struct GNUNET_TRANSPORT_ATS_Information * ats;
621 uint32_t ats_count;
622};
623
624void neighbour_send_cb (void *cls, int success)
625{
626 struct AddressContext * ac = cls;
627 struct NeighbourMapEntry * n = ac->n;
628 int was_connected = n->is_connected;
629
630 if (success == GNUNET_YES)
631 {
632 n->is_connected = GNUNET_YES;
633
634 /* was already connected */
635 if (was_connected == GNUNET_YES)
636 {
637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
638 "Successfully switched to address `%s' for peer `%s' \n",
639 GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen),
640 GNUNET_i2s (&n->id));
641 GNUNET_free (ac);
642 return;
643 }
644
645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
646 "Successfully connected to peer `%s' with address `%s'\n",
647 GNUNET_i2s (&n->id),
648 GST_plugins_a2s(n->plugin_name, n->addr, n->addrlen));
649
650 neighbours_connected++;
651 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
652 GNUNET_NO);
653 connect_notify_cb (callback_cls, &n->id, ac->ats, ac->ats_count);
654 GNUNET_free (ac);
655 return;
656 }
657
658 /* Could not connecte using this address, notifying ATS about bad address */
659 GNUNET_ATS_address_destroyed(GST_ats, &n->id, n->plugin_name, n->addr, n->addrlen, n->session);
660 GNUNET_ATS_suggest_address(GST_ats, &n->id);
661 GNUNET_free (ac);
662}
663 617
664/** 618/**
665 * For an existing neighbour record, set the active connection to 619 * For an existing neighbour record, set the active connection to
@@ -683,7 +637,7 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
683{ 637{
684 struct NeighbourMapEntry *n; 638 struct NeighbourMapEntry *n;
685 struct SessionConnectMessage connect_msg; 639 struct SessionConnectMessage connect_msg;
686 struct AddressContext *ac; 640 int was_connected;
687 641
688 GNUNET_assert (neighbours != NULL); 642 GNUNET_assert (neighbours != NULL);
689 643
@@ -695,10 +649,12 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
695 // GNUNET_break (0); 649 // GNUNET_break (0);
696 return; 650 return;
697 } 651 }
652 was_connected = n->is_connected;
653 n->is_connected = GNUNET_YES;
698 654
699#if DEBUG_TRANSPORT 655#if DEBUG_TRANSPORT
700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 656 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
701 "Peer `%4s' switches to plugin `%s' address '%s' session %X\n", 657 "SWITCH! Peer `%4s' switches to plugin `%s' address '%s' session %X\n",
702 GNUNET_i2s (peer), plugin_name, 658 GNUNET_i2s (peer), plugin_name,
703 (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name, 659 (address_len == 0) ? "<inbound>" : GST_plugins_a2s (plugin_name,
704 address, 660 address,
@@ -706,12 +662,6 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
706 session); 662 session);
707#endif 663#endif
708 664
709 ac = GNUNET_malloc(sizeof (struct AddressContext) +
710 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
711 ac->n = n;
712 ac->ats_count = ats_count;
713 memcpy(&ac[1],ats, ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
714
715 GNUNET_free_non_null (n->addr); 665 GNUNET_free_non_null (n->addr);
716 n->addr = GNUNET_malloc (address_len); 666 n->addr = GNUNET_malloc (address_len);
717 memcpy (n->addr, address, address_len); 667 memcpy (n->addr, address, address_len);
@@ -730,10 +680,17 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
730 connect_msg.timestamp = 680 connect_msg.timestamp =
731 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 681 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
732 GST_neighbours_send (peer, &connect_msg, sizeof (connect_msg), 682 GST_neighbours_send (peer, &connect_msg, sizeof (connect_msg),
733 GNUNET_TIME_UNIT_FOREVER_REL, &neighbour_send_cb, ac); 683 GNUNET_TIME_UNIT_FOREVER_REL, NULL, NULL);
734 684
735 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task, 685 n->keepalive_task = GNUNET_SCHEDULER_add_now (&neighbour_keepalive_task,
736 n); 686 n);
687 if (GNUNET_YES == was_connected)
688 return;
689 /* First tell clients about connected neighbours...*/
690 neighbours_connected++;
691 GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# peers connected"), 1,
692 GNUNET_NO);
693 connect_notify_cb (callback_cls, peer, ats, ats_count);
737} 694}
738 695
739/** 696/**
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c
index 231934f89..66e1917a1 100644
--- a/src/transport/test_transport_api_limited_sockets.c
+++ b/src/transport/test_transport_api_limited_sockets.c
@@ -55,7 +55,7 @@
55 55
56#define MTYPE 12345 56#define MTYPE 12345
57 57
58#define MAX_FILES 20 58#define MAX_FILES 50
59 59
60static char *test_source; 60static char *test_source;
61 61