[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16446 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16446 - gnunet/src/transport |
Date: |
Thu, 11 Aug 2011 14:15:01 +0200 |
Author: grothoff
Date: 2011-08-11 14:15:01 +0200 (Thu, 11 Aug 2011)
New Revision: 16446
Modified:
gnunet/src/transport/gnunet-service-transport_ats-new.c
Log:
more ats API hacking
Modified: gnunet/src/transport/gnunet-service-transport_ats-new.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_ats-new.c 2011-08-11
12:05:11 UTC (rev 16445)
+++ gnunet/src/transport/gnunet-service-transport_ats-new.c 2011-08-11
12:15:01 UTC (rev 16446)
@@ -105,7 +105,22 @@
};
+
/**
+ * Calculate an updated bandwidth assignment and notify.
+ *
+ * @param ats handle
+ * @param change which allocation record changed?
+ */
+static void
+update_bandwidth_assignment (struct GST_AtsHandle *atc,
+ struct AllocationRecord *change)
+{
+
+}
+
+
+/**
* Initialize the ATS subsystem.
*
* @param cfg configuration to use
@@ -168,6 +183,23 @@
/**
+ * Closure for 'update_session'
+ */
+struct UpdateSessionContext
+{
+ /**
+ * Ats handle.
+ */
+ struct GST_AtsHandle *atc;
+
+ /**
+ * Allocation record with new information.
+ */
+ struct AllocationRecord *arnew;
+};
+
+
+/**
* Update an allocation record, merging with the new information
*
* @param cls a new 'struct AllocationRecord'
@@ -181,8 +213,10 @@
const GNUNET_HashCode *key,
void *value)
{
- struct AllocationRecord *arnew = cls;
+ struct UpdateSessionContext *usc = cls;
+ struct AllocationRecord *arnew = usc->arnew;
struct AllocationRecord *arold = value;
+ int change;
if (0 != strcmp (arnew->plugin_name, arold->plugin_name))
return GNUNET_YES;
@@ -193,12 +227,24 @@
arnew->plugin_addr,
arnew->plugin_addr_len)) ) )
{
+ change = GNUNET_NO;
/* records match */
- arold->session = arnew->session;
- if (arnew->connected == GNUNET_YES)
- arold->connected = GNUNET_YES;
+ if (arnew->session != arold->session)
+ {
+ arold->session = arnew->session;
+ change = GNUNET_YES;
+ }
+ if ( (arnew->connected == GNUNET_YES) &&
+ (arold->connected == GNUNET_NO) )
+ {
+ arold->connected = GNUNET_YES;
+ change = GNUNET_YES;
+ }
// FIXME: merge ats arrays of (arold, arnew);
- return GNUNET_NO;
+
+ if (GNUNET_YES == change)
+ update_bandwidth_assignment (usc->atc, arold);
+ return GNUNET_NO;
}
return GNUNET_YES;
}
@@ -265,6 +311,7 @@
uint32_t ats_count)
{
struct AllocationRecord *ar;
+ struct UpdateSessionContext usc;
ar = create_allocation_record (plugin_name,
session,
@@ -273,10 +320,12 @@
ats,
ats_count);
ar->connected = GNUNET_YES;
+ usc.atc = atc;
+ usc.arnew = ar;
if (GNUNET_SYSERR ==
GNUNET_CONTAINER_multihashmap_iterate (atc->peers,
&update_session,
- ar))
+ &usc))
{
destroy_allocation_record (NULL, &peer->hashPubKey, ar);
return;
@@ -292,7 +341,7 @@
/**
* Mark all matching allocation records as not connected.
*
- * @param cls unused
+ * @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)
@@ -302,9 +351,14 @@
const GNUNET_HashCode *key,
void *value)
{
+ struct GST_AtsHandle *atc = cls;
struct AllocationRecord *ar = value;
- ar->connected = GNUNET_NO;
+ if (GNUNET_YES == ar->connected)
+ {
+ ar->connected = GNUNET_NO;
+ update_bandwidth_assignment (atc, ar);
+ }
return GNUNET_OK;
}
@@ -323,7 +377,7 @@
{
(void) GNUNET_CONTAINER_multihashmap_iterate (atc->peers,
&disconnect_peer,
- NULL);
+ atc);
}
@@ -369,6 +423,11 @@
GNUNET_CONTAINER_multihashmap_remove (sdc->atc->peers,
key,
ar));
+ if (GNUNET_YES == ar->connected);
+ {
+ /* FIXME: is this supposed to be allowed? What to do then? */
+ GNUNET_break (0);
+ }
destroy_allocation_record (NULL, key, ar);
return GNUNET_OK;
}
@@ -424,6 +483,7 @@
uint32_t ats_count)
{
struct AllocationRecord *ar;
+ struct UpdateSessionContext usc;
ar = create_allocation_record (plugin_name,
session,
@@ -431,11 +491,12 @@
plugin_addr_len,
ats,
ats_count);
-
+ usc.atc = atc;
+ usc.arnew = ar;
if (GNUNET_SYSERR ==
GNUNET_CONTAINER_multihashmap_iterate (atc->peers,
&update_session,
- ar))
+ &usc))
{
destroy_allocation_record (NULL, &peer->hashPubKey, ar);
return;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16446 - gnunet/src/transport,
gnunet <=