[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6262 - GNUnet/src/applications/fs/gap
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6262 - GNUnet/src/applications/fs/gap |
Date: |
Tue, 12 Feb 2008 00:33:28 -0700 (MST) |
Author: grothoff
Date: 2008-02-12 00:33:28 -0700 (Tue, 12 Feb 2008)
New Revision: 6262
Modified:
GNUnet/src/applications/fs/gap/fs.c
GNUnet/src/applications/fs/gap/gap.c
GNUnet/src/applications/fs/gap/pid_table.h
GNUnet/src/applications/fs/gap/plan.c
GNUnet/src/applications/fs/gap/querymanager.c
GNUnet/src/applications/fs/gap/shared.c
GNUnet/src/applications/fs/gap/shared.h
GNUnet/src/applications/fs/gap/test_linear_topology.c
Log:
fixes
Modified: GNUnet/src/applications/fs/gap/fs.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs.c 2008-02-12 05:59:12 UTC (rev 6261)
+++ GNUnet/src/applications/fs/gap/fs.c 2008-02-12 07:33:28 UTC (rev 6262)
@@ -521,7 +521,6 @@
unsigned int type;
unsigned int netLoad;
enum GNUNET_FS_RoutingPolicy policy;
- GNUNET_PeerIdentity respond_to;
double preference;
fprintf(stderr,
@@ -541,9 +540,6 @@
"Dropping query from %s, this peer is too busy.\n",
sender == NULL ? "localhost" : (char *) &enc);
#endif
- fprintf(stderr,
- "FS dropped P2P query from `%p' due to high load\n",
- sender);
return GNUNET_OK;
}
size = ntohs (msg->size);
@@ -552,8 +548,6 @@
GNUNET_GE_BREAK_OP (ectx, 0);
return GNUNET_SYSERR; /* malformed query */
}
- fprintf(stderr,
- "FS is processing P2P query\n");
req = (const P2P_gap_query_MESSAGE *) msg;
query_count = ntohl (req->number_of_queries);
if ((query_count == 0) ||
@@ -595,17 +589,9 @@
policy = GNUNET_FS_RoutingPolicy_ANSWER;
return GNUNET_OK; /* drop */
}
- if ((policy & GNUNET_FS_RoutingPolicy_INDIRECT) > 0)
- {
- respond_to = *coreAPI->myIdentity;
- }
- else
- {
- /* otherwise we preserve the original sender
- and kill the priority (since we cannot benefit) */
- respond_to = *sender;
- prio = 0;
- }
+ if ((policy & GNUNET_FS_RoutingPolicy_INDIRECT) == 0)
+ /* kill the priority (since we cannot benefit) */
+ prio = 0;
ttl = GNUNET_FS_HELPER_bound_ttl (ntohl (req->ttl), prio);
type = ntohl (req->type);
/* decrement ttl (always) */
@@ -622,17 +608,11 @@
ttl -= 2 * TTL_DECREMENT +
GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, TTL_DECREMENT);
}
- fprintf(stderr,
- "TTL in: %d out: %d (prio: %u)\n",
- ntohl(req->type),
- ttl,
- prio);
-
preference = (double) prio;
if (preference < QUERY_BANDWIDTH_VALUE)
preference = QUERY_BANDWIDTH_VALUE;
coreAPI->preferTrafficFrom (sender, preference);
- GNUNET_FS_GAP_execute_query (&respond_to,
+ GNUNET_FS_GAP_execute_query (sender,
prio,
policy,
ttl,
@@ -665,15 +645,15 @@
unsigned long long expiration;
double preference;
+ fprintf(stderr,
+ "FS received P2P content from `%p'\n",
+ sender);
size = ntohs (pmsg->size);
if (size < sizeof (P2P_gap_reply_MESSAGE))
{
GNUNET_GE_BREAK_OP (ectx, 0);
return GNUNET_SYSERR; /* invalid! */
}
- fprintf(stderr,
- "FS received P2P response from `%p'\n",
- sender);
msg = (const P2P_gap_reply_MESSAGE *) pmsg;
data_size = size - sizeof (P2P_gap_reply_MESSAGE);
dblock = (const DBlock *) &msg[1];
Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c 2008-02-12 05:59:12 UTC (rev
6261)
+++ GNUnet/src/applications/fs/gap/gap.c 2008-02-12 07:33:28 UTC (rev
6262)
@@ -76,8 +76,6 @@
{
GNUNET_MessageHeader *msg = cls;
- fprintf(stderr,
- "!!!!!!!!!!!!!!!!!!!!!Injecting local
result!!!!!!!!!!!!!!!!!!!!!!!\n");
coreAPI->p2p_inject_message (NULL,
(const char *) msg,
ntohs (msg->size), GNUNET_YES, NULL);
@@ -149,8 +147,6 @@
msg->reserved = htonl (0);
msg->expiration = et;
memcpy (&msg[1], &value[1], size - sizeof (P2P_gap_reply_MESSAGE));
- fprintf(stderr,
- "GAP found response, queuing for delayed sending\n");
GNUNET_cron_add_job (cron,
send_delayed,
GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
@@ -193,27 +189,23 @@
PID_INDEX peer;
unsigned int index;
GNUNET_CronTime now;
+ GNUNET_CronTime newTTL;
int ret;
GNUNET_GE_ASSERT (NULL, query_count > 0);
GNUNET_mutex_lock (GNUNET_FS_lock);
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))
{
- fprintf(stderr,
- "New TTL: %llu + %d = %llu, Old: %llu and %llu\n",
- now, ttl, now+ttl, table[index]->expiration,
table[index]->next->expiration);
/* limit to at most two entries per slot in table */
- if ((now + ttl < table[index]->expiration) &&
- (now + ttl < table[index]->next->expiration))
+ if ((newTTL < table[index]->expiration) &&
+ (newTTL < table[index]->next->expiration))
{
/* do not process */
- fprintf(stderr,
- "GAP too busy to create RT entry for query in slot %u\n",
- index);
GNUNET_mutex_unlock (GNUNET_FS_lock);
return;
}
@@ -229,7 +221,6 @@
GNUNET_FS_SHARED_free_request_list (rl);
}
}
-
/* create new table entry */
rl =
GNUNET_malloc (sizeof (struct RequestList) +
@@ -250,17 +241,11 @@
rl->type = type;
rl->value = priority;
rl->remaining_value = priority > 0 ? priority - 1 : 0;
- rl->expiration = GNUNET_get_time () + ttl * GNUNET_CRON_SECONDS;
+ rl->expiration = newTTL;
rl->next = table[index];
rl->response_target = GNUNET_FS_PT_intern (respond_to);
+ rl->policy = policy;
table[index] = rl;
- fprintf(stderr,
- "GAP creates RT entry `%p' for query with ttl %d prio %u from `%u' in
slot %u\n",
- rl,
- ttl,
- priority,
- rl->response_target,
- index);
/* check local data store */
ret = datastore->get (&queries[0], type, datastore_value_processor, rl);
@@ -306,19 +291,23 @@
GNUNET_HashCode hc;
GNUNET_PeerIdentity target;
struct RequestList *rl;
+ struct RequestList *prev;
unsigned int value;
P2P_gap_reply_MESSAGE *msg;
PID_INDEX rid;
+ unsigned int index;
value = 0;
GNUNET_mutex_lock (GNUNET_FS_lock);
rid = GNUNET_FS_PT_intern (sender);
- rl = table[get_table_index (primary_query)];
+ 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)
{
if (GNUNET_OK == GNUNET_FS_SHARED_test_valid_new_response (rl,
@@ -330,7 +319,7 @@
GNUNET_FS_PT_resolve (rl->response_target, &target);
/* queue response */
msg = GNUNET_malloc (sizeof (P2P_gap_reply_MESSAGE) + size);
- msg->header.type = htons (GNUNET_CS_PROTO_GAP_RESULT);
+ msg->header.type = htons (GNUNET_P2P_PROTO_GAP_RESULT);
msg->header.size = htons (sizeof (P2P_gap_reply_MESSAGE) + size);
msg->reserved = 0;
msg->expiration = GNUNET_htonll (expiration);
@@ -350,7 +339,21 @@
GNUNET_FS_PLAN_success (rid, NULL, rl->response_target, rl);
value += rl->value;
rl->value = 0;
+ if (rl->type == GNUNET_ECRS_BLOCKTYPE_DATA)
+ {
+ if (prev == NULL)
+ table[index] = rl->next;
+ else
+ prev->next = rl->next;
+ GNUNET_FS_SHARED_free_request_list (rl);
+ if (prev == NULL)
+ rl = table[index];
+ else
+ rl = prev->next;
+ continue;
+ }
}
+ prev = rl;
rl = rl->next;
}
GNUNET_mutex_unlock (GNUNET_FS_lock);
@@ -413,9 +416,6 @@
{
if (pid == rl->response_target)
{
- fprintf(stderr,
- "GAP cleans up table due to disconnect from `%u'\n",
- pid);
if (prev == NULL)
table[i] = rl->next;
else
Modified: GNUnet/src/applications/fs/gap/pid_table.h
===================================================================
--- GNUnet/src/applications/fs/gap/pid_table.h 2008-02-12 05:59:12 UTC (rev
6261)
+++ GNUnet/src/applications/fs/gap/pid_table.h 2008-02-12 07:33:28 UTC (rev
6262)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2006 Christian Grothoff (and other contributing authors)
+ (C) 2006, 2008 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
Modified: GNUnet/src/applications/fs/gap/plan.c
===================================================================
--- GNUnet/src/applications/fs/gap/plan.c 2008-02-12 05:59:12 UTC (rev
6261)
+++ GNUnet/src/applications/fs/gap/plan.c 2008-02-12 07:33:28 UTC (rev
6262)
@@ -404,27 +404,36 @@
if (prio > allowable_prio)
prio = allowable_prio;
}
- ttl = rpc->request->last_ttl_used;
+ if ( (rpc->request->response_client == NULL) &&
+ (prio > rpc->request->remaining_value) )
+ prio = rpc->request->remaining_value;
if (prio > 0)
{
ttl = (1 << 30); /* bound only by prio */
}
else
{
- if (rpc->request->response_client == NULL)
+ if (rpc->request->response_client != NULL)
ttl = 0; /* initiator expiration is always "now" */
else
- ttl =
- (int) (((long long) (rpc->request->expiration -
- now)) / GNUNET_CRON_SECONDS);
- ttl =
- ttl - TTL_DECREMENT - GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
- 2 * TTL_DECREMENT);
- if (ttl > 0) /* integer underflow */
- ttl = -(1 << 30);
+ {
+ ttl =
+ (int) (((long long) (rpc->request->expiration -
+ now)) / (long long)GNUNET_CRON_SECONDS);
+ }
+ if (ttl < 0)
+ {
+ ttl -= TTL_DECREMENT + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+ 2 * TTL_DECREMENT);
+ if (ttl > 0) /* integer underflow */
+ ttl = -(1 << 30);
+ }
+ else
+ {
+ ttl -= TTL_DECREMENT + GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+ 2 * TTL_DECREMENT);
+ }
}
- fprintf(stderr,
- "Plan's TTL is %d (%u)\n", ttl, prio);
ttl = GNUNET_FS_HELPER_bound_ttl (ttl, prio);
rank->prio = prio;
rank->ttl = ttl;
@@ -479,10 +488,6 @@
double prob;
GNUNET_mutex_lock (GNUNET_FS_lock); /* needed? */
- fprintf(stderr,
- "Planning query of %p/%u\n",
- client,
- peer);
info = clients;
while ((info != NULL) && ((info->client != client) || (info->peer != peer)))
info = info->next;
@@ -527,12 +532,6 @@
if (target_count > total_peers)
target_count = total_peers;
- fprintf(stderr,
- "Will adding query from %p/%u to %u peers\n",
- client,
- peer,
- target_count);
-
/* select target_count peers */
for (i = 0; i < target_count; i++)
{
@@ -542,13 +541,18 @@
{
if (rank->score > selector)
{
- fprintf(stderr,
- "Adding query from %p/%u to plan for peer %u with ttl %d
and prio %u\n",
- client,
- peer,
- rank->peer,
- rank->ttl,
- rank->prio);
+ if (request->response_client == NULL)
+ {
+ if (rank->prio > request->remaining_value)
+ {
+ if ( (i == target_count - 1) ||
+ (request->remaining_value == 0) )
+ rank->prio = request->remaining_value;
+ else
+ rank->prio =
GNUNET_random_u32(GNUNET_RANDOM_QUALITY_WEAK, request->remaining_value);
+ }
+ request->remaining_value -= rank->prio;
+ }
add_request (rank->peer, request, rank->ttl, rank->prio);
total_score -= rank->score;
rank->score = 0; /* mark as used */
@@ -593,9 +597,6 @@
+ req->bloomfilter_size + (req->key_count - 1) * sizeof (GNUNET_HashCode);
if (size > available)
return 0;
- fprintf(stderr,
- "Adding request to send buffer (plan.c) with TTL %d (%d) and prio
%u\n",
- ttl, GNUNET_FS_HELPER_bound_ttl(ttl, prio), prio);
if ((prio > req->remaining_value) && (req->response_client == NULL))
prio = req->remaining_value;
ttl = GNUNET_FS_HELPER_bound_ttl (ttl, prio);
@@ -606,7 +607,11 @@
msg->ttl = htonl (ttl);
msg->filter_mutator = htonl (req->bloomfilter_mutator);
msg->number_of_queries = htonl (req->key_count);
- msg->returnTo = *coreAPI->myIdentity; /* FIXME? */
+ if (0 != (req->policy & GNUNET_FS_RoutingPolicy_INDIRECT))
+ msg->returnTo = *coreAPI->myIdentity;
+ else
+ GNUNET_FS_PT_resolve(req->response_target,
+ &msg->returnTo);
memcpy (&msg->queries[0],
&req->queries[0], req->key_count * sizeof (GNUNET_HashCode));
if (req->bloomfilter != NULL)
@@ -656,10 +661,6 @@
if (pl != NULL)
{
e = pl->head;
- if (e != NULL)
- fprintf(stderr,
- "Asked to fill buffer for %u - and I have a plan!\n",
- peer);
while ((e != NULL) && (padding - off >= sizeof (P2P_gap_query_MESSAGE)))
{
ret = try_add_request (e->request,
Modified: GNUnet/src/applications/fs/gap/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/gap/querymanager.c 2008-02-12 05:59:12 UTC
(rev 6261)
+++ GNUnet/src/applications/fs/gap/querymanager.c 2008-02-12 07:33:28 UTC
(rev 6262)
@@ -100,11 +100,8 @@
request->type = type;
request->primary_target = GNUNET_FS_PT_intern (target);
request->response_client = client;
+ request->policy = GNUNET_FS_RoutingPolicy_ALL;
memcpy (&request->queries[0], query, sizeof (GNUNET_HashCode) * key_count);
- fprintf(stderr,
- "Tracking request of type %u from client %p\n",
- type,
- client);
GNUNET_mutex_lock (GNUNET_FS_lock);
cl = clients;
while ((cl != NULL) && (cl->client != client))
@@ -229,8 +226,6 @@
msg->anonymityLevel = htonl (0); /* unknown */
msg->expirationTime = GNUNET_htonll (expirationTime);
memcpy (&msg[1], data, size);
- fprintf(stderr,
- "Forwarding response to client\n");
coreAPI->cs_send_to_client (client,
&msg->header,
(rl->type != GNUNET_ECRS_BLOCKTYPE_DATA)
@@ -398,10 +393,10 @@
while (request != NULL)
{
if ((NULL == request->plan_entries) &&
- ((request->expiration == 0) ||
+ ((client->client != NULL) ||
(request->expiration > now)) &&
(request->last_ttl_used * GNUNET_CRON_SECONDS +
- request->last_request_time > now))
+ request->last_request_time < now))
GNUNET_FS_PLAN_request (client->client, 0, request);
if ((request->anonymityLevel == 0) &&
Modified: GNUnet/src/applications/fs/gap/shared.c
===================================================================
--- GNUnet/src/applications/fs/gap/shared.c 2008-02-12 05:59:12 UTC (rev
6261)
+++ GNUnet/src/applications/fs/gap/shared.c 2008-02-12 07:33:28 UTC (rev
6262)
@@ -25,6 +25,7 @@
*/
#include "platform.h"
+#include "gnunet_protocols.h"
#include "shared.h"
#include "fs.h"
@@ -84,54 +85,44 @@
const DBlock * data,
GNUNET_HashCode * hc)
{
+#if 0
struct ResponseList *seen;
+#endif
GNUNET_HashCode m;
int ret;
/* check that type and primary key match */
- if ((rl->type != ntohl (data->type)) ||
+ if ( ( (rl->type != GNUNET_ECRS_BLOCKTYPE_ANY) &&
+ (rl->type != ntohl (data->type)) ) ||
(0 != memcmp (primary_key, &rl->queries[0], sizeof (GNUNET_HashCode))))
- {
- fprintf(stderr,
- "Response does not match request\n");
- return GNUNET_NO;
- }
+ return GNUNET_NO;
/* check that content matches query */
- ret = GNUNET_EC_is_block_applicable_for_query (rl->type,
+ ret = GNUNET_EC_is_block_applicable_for_query (ntohl(data->type),
size,
data,
&rl->queries[0],
rl->key_count,
&rl->queries[0]);
if (ret != GNUNET_OK)
- {
- fprintf(stderr,
- "Response does not match request (EC)\n");
- return ret;
- }
+ return ret;
/* check that this is a new response */
GNUNET_hash (data, size, hc);
GNUNET_FS_HELPER_mingle_hash (hc, rl->bloomfilter_mutator, &m);
if ((rl->bloomfilter != NULL) &&
(GNUNET_YES == GNUNET_bloomfilter_test (rl->bloomfilter, &m)))
- {
- fprintf(stderr,
- "Response does not match request (BF)\n");
- return GNUNET_NO; /* not useful */
- }
+ return GNUNET_NO; /* not useful */
+#if 0
+ /* bloomfilter should cover these already */
seen = rl->responses;
while (seen != NULL)
{
if (0 == memcmp (hc, &seen->hash, sizeof (GNUNET_HashCode)))
- {
- fprintf(stderr,
- "Response does not match request (seen)\n");
- return GNUNET_NO;
- }
+ return GNUNET_NO;
seen = seen->next;
}
+#endif
return GNUNET_OK;
}
@@ -145,8 +136,12 @@
GNUNET_HashCode * hc)
{
struct ResponseList *seen;
+ GNUNET_HashCode m;
- GNUNET_bloomfilter_add (rl->bloomfilter, hc);
+ GNUNET_FS_HELPER_mingle_hash (hc,
+ rl->bloomfilter_mutator,
+ &m);
+ GNUNET_bloomfilter_add (rl->bloomfilter, &m);
/* update seen list */
seen = GNUNET_malloc (sizeof (struct ResponseList));
seen->hash = *hc;
@@ -210,6 +205,8 @@
int
GNUNET_FS_HELPER_bound_ttl (int ttl_in, unsigned int prio)
{
+ if (ttl_in <= 0)
+ return ttl_in;
if (ttl_in >
((unsigned long long) prio) * TTL_DECREMENT / GNUNET_CRON_SECONDS)
{
Modified: GNUnet/src/applications/fs/gap/shared.h
===================================================================
--- GNUnet/src/applications/fs/gap/shared.h 2008-02-12 05:59:12 UTC (rev
6261)
+++ GNUnet/src/applications/fs/gap/shared.h 2008-02-12 07:33:28 UTC (rev
6262)
@@ -29,6 +29,7 @@
#include "gnunet_util.h"
#include "ecrs_core.h"
#include "pid_table.h"
+#include "gap.h"
/**
* Linked list of responses that we have gotten for
@@ -179,6 +180,11 @@
unsigned int remaining_value;
/**
+ * Routing policy for the request (foward, indirect).
+ */
+ enum GNUNET_FS_RoutingPolicy policy;
+
+ /**
* The queries of this request. At least one,
* if there are more, the key count field will say
* so.
Modified: GNUnet/src/applications/fs/gap/test_linear_topology.c
===================================================================
--- GNUnet/src/applications/fs/gap/test_linear_topology.c 2008-02-12
05:59:12 UTC (rev 6261)
+++ GNUnet/src/applications/fs/gap/test_linear_topology.c 2008-02-12
07:33:28 UTC (rev 6262)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2005, 2006, 2007 Christian Grothoff (and other contributing authors)
+ (C) 2005, 2006, 2007, 2008 Christian Grothoff (and other contributing
authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -37,7 +37,7 @@
#define PEER_COUNT 2
-#define SIZE 1024 * 32 * 2
+#define SIZE 1024 * 1024 * 2
static struct GNUNET_GE_Context *ectx;
@@ -198,6 +198,7 @@
"Starting download of `%s'\n", tmp);
GNUNET_free (tmp);
tmpName = makeName (0);
+ unlink(tmpName);
ret = GNUNET_SYSERR;
if (GNUNET_OK == GNUNET_ECRS_file_download (ectx,
cfg,
@@ -303,8 +304,7 @@
printf ("Downloading...\n");
CHECK (GNUNET_OK == downloadFile (SIZE, uri));
printf ("Download successful at %llu kbps!\n",
- (SIZE / 1024) / ((GNUNET_get_time () - start) /
- GNUNET_CRON_SECONDS));
+ (SIZE * GNUNET_CRON_SECONDS/ 1024) / ((1 + GNUNET_get_time () -
start)));
GNUNET_ECRS_uri_destroy (uri);
GNUNET_GC_set_configuration_value_string (cfg,
ectx,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6262 - GNUnet/src/applications/fs/gap,
gnunet <=