[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17415 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17415 - gnunet/src/ats |
Date: |
Wed, 12 Oct 2011 16:03:45 +0200 |
Author: grothoff
Date: 2011-10-12 16:03:45 +0200 (Wed, 12 Oct 2011)
New Revision: 17415
Modified:
gnunet/src/ats/ats_api.c
Log:
debug code, some hackery around connected flag
Modified: gnunet/src/ats/ats_api.c
===================================================================
--- gnunet/src/ats/ats_api.c 2011-10-12 13:29:50 UTC (rev 17414)
+++ gnunet/src/ats/ats_api.c 2011-10-12 14:03:45 UTC (rev 17415)
@@ -136,7 +136,9 @@
struct SetBandwidthContext *sbc = cls;
struct AllocationRecord *ar = value;
- if (GNUNET_YES == ar->connected)
+ GNUNET_assert (GNUNET_SYSERR != ar->connected);
+ /* FIXME: ||1 because we currently NEVER get 'connected' events... */
+ if ( (GNUNET_YES == ar->connected) || 1)
{
ar->bandwidth_in = sbc->bw_in;
ar->bandwidth_out = sbc->bw_out;
@@ -165,6 +167,13 @@
ar->plugin_addr_len, ar->bandwidth_out,
ar->bandwidth_in);
}
+ else
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Not communicating bandwidth assigned to peer %s: not connected and bw
is: i:%u/o:%u bytes/s\n",
+ GNUNET_i2s ((const struct GNUNET_PeerIdentity *) key),
+ ntohl (ar->bandwidth_in.value__),
+ ntohl (ar->bandwidth_out.value__));
+
return GNUNET_YES;
}
@@ -191,7 +200,11 @@
GNUNET_assert (ac > 0);
bwc.bw_in = GNUNET_BANDWIDTH_value_init (atc->total_bps_in / ac);
bwc.bw_out = GNUNET_BANDWIDTH_value_init (atc->total_bps_out / ac);
- GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &set_bw_connections,
&bwc);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Trivial implementation: bandwidth assigned to each peer is i:%u/o:%u
bytes/s\n",
+ ntohl (bwc.bw_in.value__),
+ ntohl (bwc.bw_out.value__));
+ GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &set_bw_connections,
&bwc);
}
@@ -418,43 +431,38 @@
struct UpdateSessionContext *usc = cls;
struct AllocationRecord *arnew = usc->arnew;
struct AllocationRecord *arold = value;
- int change;
int c_old;
int c_new;
int found;
+ if (0 != strcmp (arnew->plugin_name, arold->plugin_name))
+ return GNUNET_YES;
+ if (! (((arnew->session == arold->session) && (arnew->session != NULL)) ||
+ ((arold->session == NULL) &&
+ (arold->plugin_addr_len == arnew->plugin_addr_len) &&
+ (0 ==
+ memcmp (arold->plugin_addr, arnew->plugin_addr,
+ arnew->plugin_addr_len)))))
+ return GNUNET_YES; /* no match */
+ /* records match */
#if DEBUG_ATS
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Updating session for peer `%s' plugin `%s'\n", GNUNET_h2s (key),
arold->plugin_name);
#endif
-
- if (0 != strcmp (arnew->plugin_name, arold->plugin_name))
- return GNUNET_YES;
- if (((arnew->session == arold->session) && (arnew->session != NULL)) ||
- ((arold->session == NULL) &&
- (arold->plugin_addr_len == arnew->plugin_addr_len) &&
- (0 ==
- memcmp (arold->plugin_addr, arnew->plugin_addr,
- arnew->plugin_addr_len))))
- {
- change = GNUNET_NO;
- /* records match */
- if (arnew->session != arold->session)
+ if (arnew->session != arold->session)
{
arold->session = arnew->session;
- change = GNUNET_YES;
}
- if ((arnew->connected == GNUNET_YES) && (arold->connected == GNUNET_NO))
+ if ((arnew->connected == GNUNET_YES) && (arold->connected == GNUNET_NO))
{
arold->connected = GNUNET_YES;
- change = GNUNET_YES;
}
-
- /* Update existing value */
- c_new = 0;
- while (c_new < arnew->ats_count)
+
+ /* Update existing value */
+ c_new = 0;
+ while (c_new < arnew->ats_count)
{
c_old = 0;
found = GNUNET_NO;
@@ -493,12 +501,9 @@
}
c_new++;
}
-
- if (GNUNET_YES == change)
- update_bandwidth_assignment (usc->atc, arold);
- return GNUNET_NO;
- }
- return GNUNET_YES;
+
+ update_bandwidth_assignment (usc->atc, arold);
+ return GNUNET_NO;
}
@@ -532,6 +537,7 @@
GNUNET_array_grow (ar->ats, ar->ats_count, ats_count);
memcpy (ar->ats, ats,
ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information));
+ ar->connected = GNUNET_SYSERR; /* aka: not known / no change */
return ar;
}
@@ -584,6 +590,12 @@
struct AllocationRecord *ar;
struct UpdateSessionContext usc;
+#if DEBUG_ATS
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Connected to peer %s\n",
+ GNUNET_i2s (peer));
+#endif
+
(void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &disconnect_peer,
atc);
ar = create_allocation_record (plugin_name, session, plugin_addr,
@@ -616,6 +628,11 @@
GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc,
const struct GNUNET_PeerIdentity *peer)
{
+#if DEBUG_ATS
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnected from peer %s\n",
+ GNUNET_i2s (peer));
+#endif
(void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers,
&peer->hashPubKey,
&disconnect_peer, atc);
@@ -767,6 +784,7 @@
"Adding new address for peer `%s', plugin `%s'\n", GNUNET_i2s (peer),
plugin_name);
#endif
+ ar->connected = GNUNET_NO;
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (atc->peers,
&peer->hashPubKey, ar,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17415 - gnunet/src/ats,
gnunet <=