[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33674 - gnunet-gtk/src/peerinfo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33674 - gnunet-gtk/src/peerinfo |
Date: |
Mon, 16 Jun 2014 12:11:26 +0200 |
Author: grothoff
Date: 2014-06-16 12:11:26 +0200 (Mon, 16 Jun 2014)
New Revision: 33674
Modified:
gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
Log:
allow two addresses active at the same time, handle address destruction (should
fix #3406)
Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c 2014-06-16 10:10:59 UTC
(rev 33673)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c 2014-06-16 10:11:26 UTC
(rev 33674)
@@ -438,6 +438,33 @@
/**
+ * Free the given peer address which must belong to the
+ * given peer.
+ *
+ * @param info peer the address belongs to
+ * @param pa address to free
+ */
+static void
+free_peer_address (struct PeerInfo *info,
+ struct PeerAddress *pa)
+{
+ GNUNET_CONTAINER_DLL_remove (info->pa_head,
+ info->pa_tail,
+ pa);
+ if (NULL != pa->tos)
+ {
+ GNUNET_TRANSPORT_address_to_string_cancel (pa->tos);
+ pa->tos = NULL;
+ }
+ gtk_tree_row_reference_free (pa->rr);
+ GNUNET_free_non_null (pa->plugin);
+ GNUNET_free_non_null (pa->address_as_string);
+ GNUNET_free_non_null (pa->country_name);
+ GNUNET_free (pa);
+}
+
+
+/**
* Function called on each entry in the #peer2info map
* to free the associated path.
*
@@ -455,21 +482,8 @@
struct PeerAddress *pa;
while (NULL != (pa = info->pa_head))
- {
- GNUNET_CONTAINER_DLL_remove (info->pa_head,
- info->pa_tail,
- pa);
- if (NULL != pa->tos)
- {
- GNUNET_TRANSPORT_address_to_string_cancel (pa->tos);
- pa->tos = NULL;
- }
- gtk_tree_row_reference_free (pa->rr);
- GNUNET_free_non_null (pa->plugin);
- GNUNET_free_non_null (pa->address_as_string);
- GNUNET_free_non_null (pa->country_name);
- GNUNET_free (pa);
- }
+ free_peer_address (info,
+ pa);
gtk_tree_row_reference_free (info->rr);
GNUNET_free (info);
return GNUNET_OK;
@@ -791,8 +805,10 @@
*
* @param cts closure
* @param address the address, or NULL if service disconnected
- * @param address_active is this address actively used to maintain a connection
- * to a peer
+ * @param address_active #GNUNET_YES if this address is actively used
+ * to maintain a connection to a peer;
+ * #GNUNET_NO if the address is not actively used;
+ * #GNUNET_SYSERR if this address is no longer available for ATS
* @param bandwidth_in available amount of inbound bandwidth
* @param bandwidth_out available amount of outbound bandwidth
* @param ats performance data for the address (as far as known)
@@ -827,24 +843,43 @@
pa->ats_in = (guint) ntohl (bandwidth_in.value__);
pa->ats_out = (guint) ntohl (bandwidth_out.value__);
get_iter_from_rr (pa->rr, &iter);
+ if (GNUNET_SYSERR == address_active)
+ {
+ gtk_tree_store_remove (ts, &iter);
+ free_peer_address (info, pa);
+ return;
+ }
gtk_tree_store_set (ts, &iter,
PEERINFO_MC_ATS_CONNECTIVITY_LED,
(pa->address_ats_active) ? led_green : led_red,
PEERINFO_MC_ATS_SELECTED_STATUS, pa->address_ats_active,
PEERINFO_MC_BANDWIDTH_IN, pa->ats_in,
PEERINFO_MC_BANDWIDTH_OUT, pa->ats_out,
-1);
- act = NULL;
+ act = (GNUNET_YES == address_active) ? pa : NULL;
for (pa = info->pa_head; NULL != pa; pa = pa->next)
{
- if (pa->address_ats_active)
+ if (GNUNET_YES == pa->address_ats_active)
{
- GNUNET_break (NULL == act);
- act = pa;
+ if (NULL == act)
+ {
+ /* first active address found, remember it! */
+ act = pa;
+ }
+ else if (GNUNET_YES == address_active)
+ {
+ /* second address became active, set BW for first to zero */
+ get_iter_from_rr (pa->rr, &iter);
+ gtk_tree_store_set (ts, &iter,
+ PEERINFO_MC_BANDWIDTH_IN, (guint) 0,
+ PEERINFO_MC_BANDWIDTH_OUT, (guint) 0,
+ -1);
+ }
}
}
get_iter_from_rr (info->rr, &iter);
if (NULL == act)
{
+ /* no active address, make sure per-peer state is on 'off' */
gtk_tree_store_set (ts, &iter,
PEERINFO_MC_ATS_CONNECTIVITY_LED, led_red,
PEERINFO_MC_ATS_SELECTED_STATUS, FALSE,
@@ -858,6 +893,7 @@
}
else
{
+ /* update per-peer state to that of active address */
gtk_tree_store_set (ts, &iter,
PEERINFO_MC_ATS_CONNECTIVITY_LED, led_green,
PEERINFO_MC_ATS_SELECTED_STATUS, TRUE,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33674 - gnunet-gtk/src/peerinfo,
gnunet <=