aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-16 10:11:26 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-16 10:11:26 +0000
commit83fe5c2dbd9289bfd699a5e39bcc327e68cb93f6 (patch)
treef7c80ab207dae53b734622391e706b29c868c8a4
parent483ab9b8fd1a82ee2817d0692e2f383dd6d127d3 (diff)
downloadgnunet-gtk-83fe5c2dbd9289bfd699a5e39bcc327e68cb93f6.tar.gz
gnunet-gtk-83fe5c2dbd9289bfd699a5e39bcc327e68cb93f6.zip
allow two addresses active at the same time, handle address destruction (should fix #3406)
-rw-r--r--src/peerinfo/gnunet-peerinfo-gtk.c78
1 files changed, 57 insertions, 21 deletions
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c
index 35c25acd..bfe0116b 100644
--- a/src/peerinfo/gnunet-peerinfo-gtk.c
+++ b/src/peerinfo/gnunet-peerinfo-gtk.c
@@ -438,6 +438,33 @@ get_object (const char *name)
438 438
439 439
440/** 440/**
441 * Free the given peer address which must belong to the
442 * given peer.
443 *
444 * @param info peer the address belongs to
445 * @param pa address to free
446 */
447static void
448free_peer_address (struct PeerInfo *info,
449 struct PeerAddress *pa)
450{
451 GNUNET_CONTAINER_DLL_remove (info->pa_head,
452 info->pa_tail,
453 pa);
454 if (NULL != pa->tos)
455 {
456 GNUNET_TRANSPORT_address_to_string_cancel (pa->tos);
457 pa->tos = NULL;
458 }
459 gtk_tree_row_reference_free (pa->rr);
460 GNUNET_free_non_null (pa->plugin);
461 GNUNET_free_non_null (pa->address_as_string);
462 GNUNET_free_non_null (pa->country_name);
463 GNUNET_free (pa);
464}
465
466
467/**
441 * Function called on each entry in the #peer2info map 468 * Function called on each entry in the #peer2info map
442 * to free the associated path. 469 * to free the associated path.
443 * 470 *
@@ -455,21 +482,8 @@ free_paths (void *cts,
455 struct PeerAddress *pa; 482 struct PeerAddress *pa;
456 483
457 while (NULL != (pa = info->pa_head)) 484 while (NULL != (pa = info->pa_head))
458 { 485 free_peer_address (info,
459 GNUNET_CONTAINER_DLL_remove (info->pa_head, 486 pa);
460 info->pa_tail,
461 pa);
462 if (NULL != pa->tos)
463 {
464 GNUNET_TRANSPORT_address_to_string_cancel (pa->tos);
465 pa->tos = NULL;
466 }
467 gtk_tree_row_reference_free (pa->rr);
468 GNUNET_free_non_null (pa->plugin);
469 GNUNET_free_non_null (pa->address_as_string);
470 GNUNET_free_non_null (pa->country_name);
471 GNUNET_free (pa);
472 }
473 gtk_tree_row_reference_free (info->rr); 487 gtk_tree_row_reference_free (info->rr);
474 GNUNET_free (info); 488 GNUNET_free (info);
475 return GNUNET_OK; 489 return GNUNET_OK;
@@ -791,8 +805,10 @@ reset_ats_status (void *cls,
791 * 805 *
792 * @param cts closure 806 * @param cts closure
793 * @param address the address, or NULL if service disconnected 807 * @param address the address, or NULL if service disconnected
794 * @param address_active is this address actively used to maintain a connection 808 * @param address_active #GNUNET_YES if this address is actively used
795 * to a peer 809 * to maintain a connection to a peer;
810 * #GNUNET_NO if the address is not actively used;
811 * #GNUNET_SYSERR if this address is no longer available for ATS
796 * @param bandwidth_in available amount of inbound bandwidth 812 * @param bandwidth_in available amount of inbound bandwidth
797 * @param bandwidth_out available amount of outbound bandwidth 813 * @param bandwidth_out available amount of outbound bandwidth
798 * @param ats performance data for the address (as far as known) 814 * @param ats performance data for the address (as far as known)
@@ -827,24 +843,43 @@ ats_status_cb (void *cts,
827 pa->ats_in = (guint) ntohl (bandwidth_in.value__); 843 pa->ats_in = (guint) ntohl (bandwidth_in.value__);
828 pa->ats_out = (guint) ntohl (bandwidth_out.value__); 844 pa->ats_out = (guint) ntohl (bandwidth_out.value__);
829 get_iter_from_rr (pa->rr, &iter); 845 get_iter_from_rr (pa->rr, &iter);
846 if (GNUNET_SYSERR == address_active)
847 {
848 gtk_tree_store_remove (ts, &iter);
849 free_peer_address (info, pa);
850 return;
851 }
830 gtk_tree_store_set (ts, &iter, 852 gtk_tree_store_set (ts, &iter,
831 PEERINFO_MC_ATS_CONNECTIVITY_LED, (pa->address_ats_active) ? led_green : led_red, 853 PEERINFO_MC_ATS_CONNECTIVITY_LED, (pa->address_ats_active) ? led_green : led_red,
832 PEERINFO_MC_ATS_SELECTED_STATUS, pa->address_ats_active, 854 PEERINFO_MC_ATS_SELECTED_STATUS, pa->address_ats_active,
833 PEERINFO_MC_BANDWIDTH_IN, pa->ats_in, 855 PEERINFO_MC_BANDWIDTH_IN, pa->ats_in,
834 PEERINFO_MC_BANDWIDTH_OUT, pa->ats_out, 856 PEERINFO_MC_BANDWIDTH_OUT, pa->ats_out,
835 -1); 857 -1);
836 act = NULL; 858 act = (GNUNET_YES == address_active) ? pa : NULL;
837 for (pa = info->pa_head; NULL != pa; pa = pa->next) 859 for (pa = info->pa_head; NULL != pa; pa = pa->next)
838 { 860 {
839 if (pa->address_ats_active) 861 if (GNUNET_YES == pa->address_ats_active)
840 { 862 {
841 GNUNET_break (NULL == act); 863 if (NULL == act)
842 act = pa; 864 {
865 /* first active address found, remember it! */
866 act = pa;
867 }
868 else if (GNUNET_YES == address_active)
869 {
870 /* second address became active, set BW for first to zero */
871 get_iter_from_rr (pa->rr, &iter);
872 gtk_tree_store_set (ts, &iter,
873 PEERINFO_MC_BANDWIDTH_IN, (guint) 0,
874 PEERINFO_MC_BANDWIDTH_OUT, (guint) 0,
875 -1);
876 }
843 } 877 }
844 } 878 }
845 get_iter_from_rr (info->rr, &iter); 879 get_iter_from_rr (info->rr, &iter);
846 if (NULL == act) 880 if (NULL == act)
847 { 881 {
882 /* no active address, make sure per-peer state is on 'off' */
848 gtk_tree_store_set (ts, &iter, 883 gtk_tree_store_set (ts, &iter,
849 PEERINFO_MC_ATS_CONNECTIVITY_LED, led_red, 884 PEERINFO_MC_ATS_CONNECTIVITY_LED, led_red,
850 PEERINFO_MC_ATS_SELECTED_STATUS, FALSE, 885 PEERINFO_MC_ATS_SELECTED_STATUS, FALSE,
@@ -858,6 +893,7 @@ ats_status_cb (void *cts,
858 } 893 }
859 else 894 else
860 { 895 {
896 /* update per-peer state to that of active address */
861 gtk_tree_store_set (ts, &iter, 897 gtk_tree_store_set (ts, &iter,
862 PEERINFO_MC_ATS_CONNECTIVITY_LED, led_green, 898 PEERINFO_MC_ATS_CONNECTIVITY_LED, led_green,
863 PEERINFO_MC_ATS_SELECTED_STATUS, TRUE, 899 PEERINFO_MC_ATS_SELECTED_STATUS, TRUE,