[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16448 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16448 - gnunet/src/transport |
Date: |
Thu, 11 Aug 2011 14:46:39 +0200 |
Author: grothoff
Date: 2011-08-11 14:46:39 +0200 (Thu, 11 Aug 2011)
New Revision: 16448
Modified:
gnunet/src/transport/gnunet-service-transport_ats-new.c
Log:
stuff
Modified: gnunet/src/transport/gnunet-service-transport_ats-new.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_ats-new.c 2011-08-11
12:36:27 UTC (rev 16447)
+++ gnunet/src/transport/gnunet-service-transport_ats-new.c 2011-08-11
12:46:39 UTC (rev 16448)
@@ -102,10 +102,25 @@
*/
struct GNUNET_CONTAINER_MultiHashMap *peers;
+ /**
+ * Task scheduled to update our bandwidth assignment.
+ */
+ GNUNET_SCHEDULER_TaskIdentifier ba_task;
};
+static void
+update_bandwidth_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GST_AtsHandle *atc = cls;
+ atc->ba_task = GNUNET_SCHEDULER_NO_TASK;
+ /* FIXME: update calculations! */
+
+}
+
+
/**
* Calculate an updated bandwidth assignment and notify.
*
@@ -116,7 +131,10 @@
update_bandwidth_assignment (struct GST_AtsHandle *atc,
struct AllocationRecord *change)
{
-
+ /* FIXME: based on the 'change', update the problem... */
+ if (atc->ba_task == GNUNET_SCHEDULER_NO_TASK)
+ atc->ba_task = GNUNET_SCHEDULER_add_now (&update_bandwidth_task,
+ atc);
}
@@ -174,6 +192,11 @@
void
GST_ats_shutdown (struct GST_AtsHandle *atc)
{
+ if (GNUNET_SCHEDULER_NO_TASK != atc->ba_task)
+ {
+ GNUNET_SCHEDULER_cancel (atc->ba_task);
+ atc->ba_task = GNUNET_SCHEDULER_NO_TASK;
+ }
GNUNET_CONTAINER_multihashmap_iterate (atc->peers,
&destroy_allocation_record,
NULL);
@@ -287,6 +310,31 @@
/**
+ * Mark all matching allocation records as not connected.
+ *
+ * @param cls 'struct GTS_AtsHandle'
+ * @param key identity of the peer associated with the record
+ * @param value the 'struct AllocationRecord' to clear the 'connected' flag
+ * @return GNUNET_OK (continue to iterate)
+ */
+static int
+disconnect_peer (void *cls,
+ const GNUNET_HashCode *key,
+ void *value)
+{
+ struct GST_AtsHandle *atc = cls;
+ struct AllocationRecord *ar = value;
+
+ if (GNUNET_YES == ar->connected)
+ {
+ ar->connected = GNUNET_NO;
+ update_bandwidth_assignment (atc, ar);
+ }
+ return GNUNET_OK;
+}
+
+
+/**
* We established a new connection with a peer (for example, because
* core asked for it or because the other peer connected to us).
* Calculate bandwidth assignments including the new peer.
@@ -313,6 +361,9 @@
struct AllocationRecord *ar;
struct UpdateSessionContext usc;
+ (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers,
+ &disconnect_peer,
+ atc);
ar = create_allocation_record (plugin_name,
session,
plugin_addr,
@@ -339,31 +390,6 @@
/**
- * Mark all matching allocation records as not connected.
- *
- * @param cls 'struct GTS_AtsHandle'
- * @param key identity of the peer associated with the record
- * @param value the 'struct AllocationRecord' to clear the 'connected' flag
- * @return GNUNET_OK (continue to iterate)
- */
-static int
-disconnect_peer (void *cls,
- const GNUNET_HashCode *key,
- void *value)
-{
- struct GST_AtsHandle *atc = cls;
- struct AllocationRecord *ar = value;
-
- if (GNUNET_YES == ar->connected)
- {
- ar->connected = GNUNET_NO;
- update_bandwidth_assignment (atc, ar);
- }
- return GNUNET_OK;
-}
-
-
-/**
* We disconnected from the given peer (for example, because ats, core
* or blacklist asked for it or because the other peer disconnected).
* Calculate bandwidth assignments without the peer.
@@ -375,9 +401,10 @@
GST_ats_peer_disconnect (struct GST_AtsHandle *atc,
const struct GNUNET_PeerIdentity *peer)
{
- (void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers,
- &disconnect_peer,
- atc);
+ (void) GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers,
+ &peer->hashPubKey,
+ &disconnect_peer,
+ atc);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16448 - gnunet/src/transport,
gnunet <=