[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5890 - GNUnet/src/applications/fs/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5890 - GNUnet/src/applications/fs/module |
Date: |
Wed, 12 Dec 2007 23:46:53 -0700 (MST) |
Author: grothoff
Date: 2007-12-12 23:46:53 -0700 (Wed, 12 Dec 2007)
New Revision: 5890
Modified:
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/fs/module/ondemand.c
Log:
improvements wrt on-demand blocks and expiration time
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2007-12-13 04:08:17 UTC (rev
5889)
+++ GNUnet/src/applications/fs/module/fs.c 2007-12-13 06:46:53 UTC (rev
5890)
@@ -772,15 +772,6 @@
GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
"Converting reply for query `%s' for gap.\n", &enc);
#endif
- et = GNUNET_ntohll (invalue->expirationTime);
- now = GNUNET_get_time ();
- if ((et <= now)
- && (ntohl (invalue->type) != GNUNET_GNUNET_ECRS_BLOCKTYPE_DATA))
- {
- /* content expired and not just data -- drop! */
- return GNUNET_OK;
- }
-
if (ntohl (invalue->type) == GNUNET_GNUNET_ECRS_BLOCKTYPE_ONDEMAND)
{
if (GNUNET_OK != ONDEMAND_getIndexed (datastore, invalue, key, &xvalue))
@@ -792,6 +783,17 @@
xvalue = NULL;
value = invalue;
}
+
+ et = GNUNET_ntohll (value->expirationTime);
+ now = GNUNET_get_time ();
+ if ((et <= now)
+ && (ntohl (value->type) != GNUNET_GNUNET_ECRS_BLOCKTYPE_DATA))
+ {
+ /* content expired and not just data -- drop! */
+ GNUNET_free_non_null (xvalue);
+ return GNUNET_OK;
+ }
+
#if EXTRA_CHECKS
if ((GNUNET_OK !=
GNUNET_EC_file_block_check_and_get_query (ntohl (value->size) -
@@ -911,18 +913,16 @@
myClosure.resultCallback = resultCallback;
myClosure.resCallbackClosure = resCallbackClosure;
ret = GNUNET_OK;
- if (type == GNUNET_GNUNET_ECRS_BLOCKTYPE_DATA)
- {
- ret = datastore->get (&keys[0],
- GNUNET_GNUNET_ECRS_BLOCKTYPE_ONDEMAND,
- &gapGetConverter, &myClosure);
- }
- if (ret != GNUNET_SYSERR)
+ if (type == GNUNET_GNUNET_ECRS_BLOCKTYPE_DATA)
+ ret = datastore->get (&keys[0],
+ GNUNET_GNUNET_ECRS_BLOCKTYPE_ONDEMAND,
+ &gapGetConverter, &myClosure);
+ if (myClosure.count == 0)
ret = datastore->get (&keys[0], type, &gapGetConverter, &myClosure);
if (ret != GNUNET_SYSERR)
- ret = myClosure.count; /* return number of actual
- results (unfiltered) that
- were found */
+ ret = myClosure.count; /* return number of actual
+ results (unfiltered) that
+ were found */
return ret;
}
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2007-12-13 04:08:17 UTC
(rev 5889)
+++ GNUnet/src/applications/fs/module/ondemand.c 2007-12-13 06:46:53 UTC
(rev 5890)
@@ -89,28 +89,7 @@
return fn;
}
-
/**
- * Test if the 'closure' OnDemandBlock is already
- * present in the datastore. Presence is indicated
- * by aborting the iteration.
- */
-static int
-checkPresent (const GNUNET_HashCode * key,
- const GNUNET_DatastoreValue * value, void *closure,
- unsigned long long uid)
-{
- GNUNET_DatastoreValue *comp = closure;
-
- if ((comp->size != value->size) ||
- (0 != memcmp (&value[1],
- &comp[1],
- ntohl (value->size) - sizeof (GNUNET_DatastoreValue))))
- return GNUNET_OK;
- return GNUNET_SYSERR;
-}
-
-/**
* Creates a symlink to the given file in the shared directory
*
* @param fn the file that was indexed
@@ -274,17 +253,7 @@
"Storing on-demand content for query `%s'\n", &enc);
#endif
- ret =
- datastore->get (&key, GNUNET_GNUNET_ECRS_BLOCKTYPE_ONDEMAND,
- &checkPresent, &odb.header);
- if (ret >= 0)
- {
- ret = datastore->put (&key, &odb.header);
- }
- else
- {
- ret = GNUNET_NO; /* already present! */
- }
+ ret = datastore->putUpdate(&key, &odb.header);
return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5890 - GNUnet/src/applications/fs/module,
gnunet <=