[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6266 - GNUnet/src/applications/fs/gap
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6266 - GNUnet/src/applications/fs/gap |
Date: |
Tue, 12 Feb 2008 10:36:07 -0700 (MST) |
Author: grothoff
Date: 2008-02-12 10:36:06 -0700 (Tue, 12 Feb 2008)
New Revision: 6266
Modified:
GNUnet/src/applications/fs/gap/fs.c
GNUnet/src/applications/fs/gap/gap.c
GNUnet/src/applications/fs/gap/plan.c
GNUnet/src/applications/fs/gap/querymanager.c
GNUnet/src/applications/fs/gap/test_linear_topology.c
Log:
more stuff
Modified: GNUnet/src/applications/fs/gap/fs.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs.c 2008-02-12 17:19:17 UTC (rev 6265)
+++ GNUnet/src/applications/fs/gap/fs.c 2008-02-12 17:36:06 UTC (rev 6266)
@@ -524,8 +524,7 @@
double preference;
fprintf(stderr,
- "FS received P2P query from `%p'\n",
- sender);
+ "R");
if (test_load_too_high ())
{
#if DEBUG_GAP
@@ -645,9 +644,9 @@
unsigned long long expiration;
double preference;
- fprintf(stderr,
- "FS received P2P content from `%p'\n",
- sender);
+ if (sender != NULL)
+ fprintf(stderr,
+ "C");
size = ntohs (pmsg->size);
if (size < sizeof (P2P_gap_reply_MESSAGE))
{
Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c 2008-02-12 17:19:17 UTC (rev
6265)
+++ GNUnet/src/applications/fs/gap/gap.c 2008-02-12 17:36:06 UTC (rev
6266)
@@ -35,6 +35,12 @@
#include "pid_table.h"
/**
+ * How many entries are allowed per slot in the
+ * collision list?
+ */
+#define MAX_ENTRIES_PER_SLOT 2
+
+/**
* The GAP routing table.
*/
static struct RequestList **table;
@@ -186,10 +192,13 @@
const void *bloomfilter_data)
{
struct RequestList *rl;
+ struct RequestList *prev;
PID_INDEX peer;
unsigned int index;
GNUNET_CronTime now;
GNUNET_CronTime newTTL;
+ GNUNET_CronTime minTTL;
+ unsigned int total;
int ret;
GNUNET_GE_ASSERT (NULL, query_count > 0);
@@ -197,29 +206,86 @@
index = get_table_index (&queries[0]);
now = GNUNET_get_time ();
newTTL = now + ttl * GNUNET_CRON_SECONDS;
-
- /* check if table is full (and/or delete old entries!) */
- if ((table[index] != NULL) && (table[index]->next != NULL))
+ peer = GNUNET_FS_PT_intern (respond_to);
+ /* check if entry already exists and compute
+ maxTTL if not */
+ minTTL = -1;
+ total = 0;
+ rl = table[index];
+ while (rl != NULL)
{
- /* limit to at most two entries per slot in table */
- if ((newTTL < table[index]->expiration) &&
- (newTTL < table[index]->next->expiration))
- {
- /* do not process */
- GNUNET_mutex_unlock (GNUNET_FS_lock);
- return;
- }
- if (table[index]->expiration > table[index]->next->expiration)
- {
- GNUNET_FS_SHARED_free_request_list (table[index]->next);
- table[index]->next = NULL;
- }
+ if ( (rl->type == type) &&
+ (rl->response_target == peer) &&
+ (0 == memcmp(&rl->queries[0], queries,
+ query_count * sizeof(GNUNET_HashCode))) )
+ {
+ if (rl->expiration > newTTL)
+ {
+ /* ignore */
+ GNUNET_FS_PT_change_rc (peer, -1);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return;
+ }
+ rl->value += priority;
+ rl->remaining_value += priority;
+ rl->expiration = newTTL;
+ rl->policy = policy;
+ if ( (rl->bloomfilter_size == filter_size) &&
+ (rl->bloomfilter_mutator == filter_mutator) )
+ {
+ /* update ttl / BF */
+ GNUNET_bloomfilter_or(rl->bloomfilter,
+ bloomfilter_data,
+ filter_size);
+ GNUNET_FS_PT_change_rc (peer, -1);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return;
+ }
+ /* update BF */
+ if (rl->bloomfilter != NULL)
+ GNUNET_bloomfilter_free(rl->bloomfilter);
+ rl->bloomfilter_mutator = filter_mutator;
+ rl->bloomfilter_size = filter_size;
+ if (filter_size > 0)
+ rl->bloomfilter = GNUNET_bloomfilter_init (coreAPI->ectx,
+ bloomfilter_data,
+ filter_size,
+ GAP_BLOOMFILTER_K);
+ else
+ rl->bloomfilter = NULL;
+ GNUNET_FS_PT_change_rc (peer, -1);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return;
+ }
+ if (rl->expiration < minTTL)
+ minTTL = rl->expiration;
+ total++;
+ rl = rl->next;
+ }
+
+ if ( (total >= MAX_ENTRIES_PER_SLOT) &&
+ (minTTL > newTTL) )
+ {
+ /* do not process */
+ GNUNET_FS_PT_change_rc (peer, -1);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return;
+ }
+ /* delete oldest table entry */
+ prev = NULL;
+ rl = table[index];
+ if (total >= MAX_ENTRIES_PER_SLOT)
+ {
+ while (rl->expiration != minTTL)
+ {
+ prev = rl;
+ rl = rl->next;
+ }
+ if (prev == NULL)
+ table[index] = rl->next;
else
- {
- rl = table[index];
- table[index] = rl->next;
- GNUNET_FS_SHARED_free_request_list (rl);
- }
+ prev->next = rl->next;
+ GNUNET_FS_SHARED_free_request_list (rl);
}
/* create new table entry */
rl =
@@ -243,10 +309,9 @@
rl->remaining_value = priority > 0 ? priority - 1 : 0;
rl->expiration = newTTL;
rl->next = table[index];
- rl->response_target = GNUNET_FS_PT_intern (respond_to);
+ rl->response_target = peer;
rl->policy = policy;
table[index] = rl;
-
/* check local data store */
ret = datastore->get (&queries[0], type, datastore_value_processor, rl);
if ((type == GNUNET_ECRS_BLOCKTYPE_DATA) && (ret != 1))
@@ -256,12 +321,7 @@
/* if not found or not unique, forward */
if ((ret != 1) || (type != GNUNET_ECRS_BLOCKTYPE_DATA))
- {
- peer = GNUNET_FS_PT_intern (respond_to);
- GNUNET_FS_PLAN_request (NULL, peer, rl);
- GNUNET_FS_PT_change_rc (peer, -1);
- }
-
+ GNUNET_FS_PLAN_request (NULL, peer, rl);
GNUNET_mutex_unlock (GNUNET_FS_lock);
}
@@ -302,11 +362,6 @@
rid = GNUNET_FS_PT_intern (sender);
index = get_table_index (primary_query);
rl = table[index];
- fprintf(stderr,
- "GAP received response from `%u' - slot: %u == %p\n",
- rid,
- get_table_index (primary_query),
- rl);
prev = NULL;
while (rl != NULL)
{
@@ -325,9 +380,7 @@
msg->expiration = GNUNET_htonll (expiration);
memcpy (&msg[1], data, size);
fprintf(stderr,
- "GAP forwards response from `%u' to `%u'\n",
- rid,
- rl->response_target);
+ "F");
coreAPI->unicast (&target,
&msg->header,
BASE_REPLY_PRIORITY * (1 + rl->value),
Modified: GNUnet/src/applications/fs/gap/plan.c
===================================================================
--- GNUnet/src/applications/fs/gap/plan.c 2008-02-12 17:19:17 UTC (rev
6265)
+++ GNUnet/src/applications/fs/gap/plan.c 2008-02-12 17:36:06 UTC (rev
6266)
@@ -35,6 +35,12 @@
#include "shared.h"
/**
+ * How many entires are we allowed to plan-ahead
+ * per peer (at most)?
+ */
+#define MAX_ENTRIES_PER_PEER 64
+
+/**
* Linked list summarizing how good other peers
* were at producing responses for a client.
*/
@@ -245,6 +251,43 @@
return hl;
}
+struct QueryPlanList *
+find_or_create_query_plan_list(PID_INDEX target)
+{
+ struct QueryPlanList *qpl;
+
+ /* find query plan for target */
+ qpl = queries;
+ while ((qpl != NULL) && (qpl->peer != target))
+ qpl = qpl->next;
+ if (qpl == NULL)
+ {
+ qpl = GNUNET_malloc (sizeof (struct QueryPlanList));
+ memset (qpl, 0, sizeof (struct QueryPlanList));
+ qpl->peer = target;
+ GNUNET_FS_PT_change_rc (target, 1);
+ qpl->next = queries;
+ queries = qpl;
+ }
+ return qpl;
+}
+
+static unsigned int
+count_query_plan_entries(struct QueryPlanList * qpl)
+{
+ struct QueryPlanEntry *pos;
+ unsigned int total;
+
+ total = 0;
+ pos = qpl->head;
+ while (pos != NULL)
+ {
+ total++;
+ pos = pos->next;
+ }
+ return total;
+}
+
/**
* Add the given request to the list of pending requests for the
* specified target. A random position in the queue will
@@ -264,19 +307,8 @@
struct QueryPlanEntry *pos;
unsigned int total;
- /* find query plan for target */
- qpl = queries;
- while ((qpl != NULL) && (qpl->peer != target))
- qpl = qpl->next;
- if (qpl == NULL)
- {
- qpl = GNUNET_malloc (sizeof (struct QueryPlanList));
- memset (qpl, 0, sizeof (struct QueryPlanList));
- qpl->peer = target;
- GNUNET_FS_PT_change_rc (target, 1);
- qpl->next = queries;
- queries = qpl;
- }
+ /* find query plan for target */
+ qpl = find_or_create_query_plan_list(target);
/* construct entry */
entry = GNUNET_malloc (sizeof (struct QueryPlanEntry));
memset (entry, 0, sizeof (struct QueryPlanEntry));
@@ -289,13 +321,7 @@
request->plan_entries = entry;
/* compute (random) insertion position in doubly-linked list */
- total = 0;
- pos = qpl->head;
- while (pos != NULL)
- {
- total++;
- pos = pos->next;
- }
+ total = count_query_plan_entries(qpl);
total = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, total + 1);
pos = qpl->head;
while (total-- > 0)
@@ -353,10 +379,18 @@
int ttl;
unsigned int allowable_prio;
long long score;
+ PID_INDEX peer;
+ peer = GNUNET_FS_PT_intern (identity);
+ if ( (peer == rpc->request->response_target) ||
+ (count_query_plan_entries(find_or_create_query_plan_list(peer)) >
MAX_ENTRIES_PER_PEER) )
+ {
+ GNUNET_FS_PT_change_rc(peer, -1);
+ return; /* ignore! */
+ }
rank = GNUNET_malloc (sizeof (struct PeerRankings));
memset (rank, 0, sizeof (struct PeerRankings));
- rank->peer = GNUNET_FS_PT_intern (identity);
+ rank->peer = peer;
rank->reserved_bandwidth = coreAPI->reserve_downstream_bandwidth (identity,
GNUNET_GAP_ESTIMATED_DATA_SIZE);
history = NULL;
@@ -511,6 +545,11 @@
total_score += rank->score;
rank = rank->next;
}
+ if (total_score == 0)
+ {
+ GNUNET_mutex_unlock(GNUNET_FS_lock);
+ return; /* no peers available */
+ }
entropy = 0;
rank = rpc.rankings;
@@ -622,6 +661,7 @@
req->last_prio_used = prio;
req->last_ttl_used = ttl;
req->remaining_value -= prio;
+ fprintf(stderr, "!");
return size;
}
Modified: GNUnet/src/applications/fs/gap/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/gap/querymanager.c 2008-02-12 17:19:17 UTC
(rev 6265)
+++ GNUnet/src/applications/fs/gap/querymanager.c 2008-02-12 17:36:06 UTC
(rev 6266)
@@ -38,7 +38,7 @@
#include "pid_table.h"
#include "shared.h"
-#define CHECK_REPEAT_FREQUENCY (5 * GNUNET_CRON_SECONDS)
+#define CHECK_REPEAT_FREQUENCY (1 * GNUNET_CRON_SECONDS)
/**
* Linked list with information for each client.
Modified: GNUnet/src/applications/fs/gap/test_linear_topology.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_linear_topology.c 2008-02-12
17:19:17 UTC (rev 6265)
+++ GNUnet/src/applications/fs/gap/test_linear_topology.c 2008-02-12
17:36:06 UTC (rev 6266)
@@ -33,7 +33,7 @@
#include "gnunet_stats_lib.h"
-#define START_PEERS 0
+#define START_PEERS 1
#define PEER_COUNT 2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6266 - GNUnet/src/applications/fs/gap,
gnunet <=