[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7417 - in GNUnet/src: applications/datastore applications/
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7417 - in GNUnet/src: applications/datastore applications/fs/ecrs applications/fs/gap applications/fs/tools include |
Date: |
Sun, 13 Jul 2008 14:45:31 -0600 (MDT) |
Author: grothoff
Date: 2008-07-13 14:45:30 -0600 (Sun, 13 Jul 2008)
New Revision: 7417
Modified:
GNUnet/src/applications/datastore/datastore.c
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/gap/fs.c
GNUnet/src/applications/fs/gap/gap.c
GNUnet/src/applications/fs/gap/migration.c
GNUnet/src/applications/fs/tools/gnunet-insert.c
GNUnet/src/include/fs.h
Log:
better expiration handling
Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c 2008-07-13 20:00:00 UTC
(rev 7416)
+++ GNUnet/src/applications/datastore/datastore.c 2008-07-13 20:45:30 UTC
(rev 7417)
@@ -110,7 +110,7 @@
get (const GNUNET_HashCode * query,
unsigned int type, GNUNET_DatastoreValueIterator iter, void *closure)
{
- int ret;
+ int ret = 0;
if (!testAvailable (query))
{
@@ -212,7 +212,7 @@
int exists;
const GNUNET_DatastoreValue *value;
unsigned long long uid;
- unsigned long long expiration;
+ GNUNET_CronTime expiration;
} CE;
static int
@@ -322,8 +322,6 @@
const GNUNET_DatastoreValue * value, void *closure,
unsigned long long uid)
{
- if ((available > 0) && (available >= MIN_GNUNET_free))
- return GNUNET_SYSERR;
if (GNUNET_get_time () < GNUNET_ntohll (value->expiration_time))
return GNUNET_SYSERR; /* not expired */
available += ntohl (value->size);
@@ -354,14 +352,11 @@
cronMaintenance (void *unused)
{
available = quota - sq->getSize ();
+ sq->iterateExpirationTime (GNUNET_ECRS_BLOCKTYPE_ANY,
+ &freeSpaceExpired, NULL);
if ((available < 0) || (available < MIN_GNUNET_free))
- {
- sq->iterateExpirationTime (GNUNET_ECRS_BLOCKTYPE_ANY,
- &freeSpaceExpired, NULL);
- if ((available < 0) || (available < MIN_GNUNET_free))
- sq->iterateLowPriority (GNUNET_ECRS_BLOCKTYPE_ANY,
- &freeSpaceLow, NULL);
- }
+ sq->iterateLowPriority (GNUNET_ECRS_BLOCKTYPE_ANY,
+ &freeSpaceLow, NULL);
}
/**
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2008-07-13 20:00:00 UTC (rev
7416)
+++ GNUnet/src/applications/fs/ecrs/search.c 2008-07-13 20:45:30 UTC (rev
7417)
@@ -313,7 +313,11 @@
unsigned int size;
int ret;
GNUNET_HashCode query;
+ GNUNET_CronTime expiration;
+ expiration = GNUNET_ntohll(value->expiration_time);
+ if (expiration < GNUNET_get_time() )
+ return GNUNET_OK; /* expired, ignore! */
type = ntohl (value->type);
size = ntohl (value->size) - sizeof (GNUNET_DatastoreValue);
#if DEBUG_SEARCH
Modified: GNUnet/src/applications/fs/gap/fs.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs.c 2008-07-13 20:00:00 UTC (rev 7416)
+++ GNUnet/src/applications/fs/gap/fs.c 2008-07-13 20:45:30 UTC (rev 7417)
@@ -722,6 +722,7 @@
unsigned int prio;
unsigned long long expiration;
double preference;
+ GNUNET_CronTime now;
size = ntohs (pmsg->size);
if (size < sizeof (P2P_gap_reply_MESSAGE))
@@ -732,6 +733,11 @@
msg = (const P2P_gap_reply_MESSAGE *) pmsg;
data_size = size - sizeof (P2P_gap_reply_MESSAGE);
dblock = (const GNUNET_EC_DBlock *) &msg[1];
+
+ expiration = GNUNET_ntohll (msg->expiration);
+ if ( (expiration > GNUNET_GAP_MAX_MIGRATION_EXP) &&
+ (ntohl(dblock->type) == GNUNET_ECRS_BLOCKTYPE_KEYWORD) )
+ return GNUNET_OK; /* expired KSK block -- ignore! */
if (GNUNET_OK !=
GNUNET_EC_file_block_check_and_get_query (data_size,
dblock, GNUNET_YES, &query))
@@ -741,11 +747,27 @@
}
if ((stats != NULL) && (sender != NULL))
stats->change (stat_gap_content_received, 1);
- expiration = GNUNET_ntohll (msg->expiration);
/* forward to other peers */
prio = GNUNET_FS_GAP_handle_response (sender,
&query,
expiration, data_size, dblock);
+ /* convert expiration to absolute time and bound properly for
+ storage in local datastore */
+ now = GNUNET_get_time();
+ if (expiration > GNUNET_GAP_MAX_MIGRATION_EXP)
+ {
+ /* expired, sometime in the past */
+ expiration = now - 1;
+ }
+ else
+ {
+ /* expires in future, apply bounding! */
+ if (ntohl(dblock->type) == GNUNET_ECRS_BLOCKTYPE_KEYWORD)
+ expiration %= GNUNET_GAP_MAX_MIGRATION_EXP_KSK;
+ else
+ expiration %= GNUNET_GAP_MAX_MIGRATION_EXP;
+ expiration += now;
+ }
/* forward to local clients */
prio += GNUNET_FS_QUERYMANAGER_handle_response (sender,
&query,
@@ -761,8 +783,7 @@
value->type = dblock->type;
value->priority = htonl (prio);
value->anonymity_level = htonl (1);
- value->expiration_time =
- GNUNET_htonll (expiration + GNUNET_get_time ());
+ value->expiration_time = GNUNET_htonll (expiration);
memcpy (&value[1], dblock, data_size);
datastore->putUpdate (&query, value);
GNUNET_free (value);
Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c 2008-07-13 20:00:00 UTC (rev
7416)
+++ GNUnet/src/applications/fs/gap/gap.c 2008-07-13 20:45:30 UTC (rev
7417)
@@ -180,11 +180,22 @@
}
et = GNUNET_ntohll (value->expiration_time);
now = GNUNET_get_time ();
+ /* convert to relative expiration time */
if (now > et)
- et -= now;
+ {
+ et -= now;
+ if (ntohl(value->type) == GNUNET_ECRS_BLOCKTYPE_KEYWORD)
+ et %= GNUNET_GAP_MAX_MIGRATION_EXP_KSK;
+ else
+ et %= GNUNET_GAP_MAX_MIGRATION_EXP;
+ }
else
- et = 0;
- et %= GNUNET_GAP_MAX_MIGRATION_EXP;
+ {
+ if (ntohl(value->type) == GNUNET_ECRS_BLOCKTYPE_KEYWORD)
+ return want_more; /* expired KSK -- ignore! */
+ /* indicate entry has expired */
+ et = -1;
+ }
size =
sizeof (P2P_gap_reply_MESSAGE) + ntohl (value->size) -
sizeof (GNUNET_DatastoreValue);
Modified: GNUnet/src/applications/fs/gap/migration.c
===================================================================
--- GNUnet/src/applications/fs/gap/migration.c 2008-07-13 20:00:00 UTC (rev
7416)
+++ GNUnet/src/applications/fs/gap/migration.c 2008-07-13 20:45:30 UTC (rev
7417)
@@ -299,7 +299,10 @@
et -= now;
else
et = 0;
- et %= GNUNET_GAP_MAX_MIGRATION_EXP;
+ if (ntohl(value->type) == GNUNET_ECRS_BLOCKTYPE_KEYWORD)
+ et %= GNUNET_GAP_MAX_MIGRATION_EXP_KSK;
+ else
+ et %= GNUNET_GAP_MAX_MIGRATION_EXP;
anonymity = ntohl (value->anonymity_level);
ret = 0;
if ((anonymity == 0) ||
Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c 2008-07-13 20:00:00 UTC
(rev 7416)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c 2008-07-13 20:45:30 UTC
(rev 7417)
@@ -45,6 +45,8 @@
static GNUNET_CronTime start_time;
+static GNUNET_CronTime expiration = 2 * GNUNET_CRON_YEARS;
+
/* ************ config options ******** */
static char *cfgFilename = GNUNET_DEFAULT_CLIENT_CONFIG_FILE;
@@ -104,7 +106,7 @@
anonymity,
priority,
GNUNET_get_time () +
- 2 * GNUNET_CRON_YEARS, &nsid,
+ expiration, &nsid,
this_id, next_id, uri, meta);
if (nsuri != NULL)
{
@@ -459,7 +461,7 @@
gloKeywords,
anonymity,
priority,
- start_time + 2 * GNUNET_CRON_YEARS,
+ start_time + expiration,
us, meta);
if (topKeywords != NULL)
GNUNET_ECRS_publish_under_keyword (ectx,
@@ -467,7 +469,7 @@
topKeywords,
anonymity,
priority,
- start_time + 2 * GNUNET_CRON_YEARS,
+ start_time + expiration,
us, meta);
GNUNET_ECRS_uri_destroy (us);
goto quit;
@@ -490,7 +492,7 @@
priority,
do_simulate ? GNUNET_SYSERR : (!do_insert),
GNUNET_YES, !do_no_direct_references,
- start_time + 2 * GNUNET_CRON_YEARS, meta,
+ start_time + expiration, meta,
gloKeywords, topKeywords);
GNUNET_free (tmp);
if (ul != NULL)
Modified: GNUnet/src/include/fs.h
===================================================================
--- GNUnet/src/include/fs.h 2008-07-13 20:00:00 UTC (rev 7416)
+++ GNUnet/src/include/fs.h 2008-07-13 20:45:30 UTC (rev 7417)
@@ -318,7 +318,7 @@
/**
* When does this result expire? The given time
- * is relative (and in big-endian).
+ * is relative (and in big-endian).
*/
unsigned long long expiration;
@@ -442,6 +442,11 @@
#define GNUNET_GAP_MAX_MIGRATION_EXP (1L * GNUNET_CRON_MONTHS)
/**
+ * Same as MIGRATION_EXP except for KSK blocks.
+ */
+#define GNUNET_GAP_MAX_MIGRATION_EXP_KSK (6L * GNUNET_CRON_HOURS)
+
+/**
* Estimated size of most blocks transported with
* the GAP protocol. 32k DBlocks are the norm.
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7417 - in GNUnet/src: applications/datastore applications/fs/ecrs applications/fs/gap applications/fs/tools include,
gnunet <=