[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r267 - in GNUnet/src/applications: datastore fs/lib fs/modu
From: |
grothoff |
Subject: |
[GNUnet-SVN] r267 - in GNUnet/src/applications: datastore fs/lib fs/module sqstore_mysql |
Date: |
Mon, 14 Feb 2005 21:13:41 -0800 (PST) |
Author: grothoff
Date: 2005-02-14 21:13:40 -0800 (Mon, 14 Feb 2005)
New Revision: 267
Modified:
GNUnet/src/applications/datastore/datastore.c
GNUnet/src/applications/fs/lib/fslibtest.c
GNUnet/src/applications/fs/module/ondemand.c
GNUnet/src/applications/sqstore_mysql/mysql.c
Log:
fslibtest passes
Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c 2005-02-15 03:45:07 UTC
(rev 266)
+++ GNUnet/src/applications/datastore/datastore.c 2005-02-15 05:13:40 UTC
(rev 267)
@@ -172,13 +172,6 @@
static int checkExists(const HashCode160 * key,
const Datastore_Value * value,
CE * ce) {
- if ( (value->size != ce->value->size) ||
- (value->type != ce->value->type) )
- return OK;
- if (0 != memcmp(&((char*)value)[sizeof(Datastore_Value)],
- &((char*)ce->value)[sizeof(Datastore_Value)],
- ntohl(value->size) - sizeof(Datastore_Value)))
- return OK;
ce->existing = MALLOC(ntohl(value->size));
memcpy(ce->existing,
value,
@@ -210,17 +203,20 @@
ntohl(value->type),
(Datum_Iterator) &checkExists,
&cls);
+ if (ntohl(value->type) == D_BLOCK)
+ sq->get(key,
+ ONDEMAND_BLOCK,
+ (Datum_Iterator) &checkExists,
+ &cls);
+
if (cls.exists) {
- if ( (0 == memcmp(cls.existing,
- value,
- sizeof(Datastore_Value))) &&
- (htonl(value->prio) == 0) ) {
+ if (htonl(value->prio) == 0) {
FREE(cls.existing);
return OK;
}
/* update prio */
sq->update(key,
- value,
+ cls.existing,
ntohl(value->prio));
FREE(cls.existing);
return OK;
Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c 2005-02-15 03:45:07 UTC (rev
266)
+++ GNUnet/src/applications/fs/lib/fslibtest.c 2005-02-15 05:13:40 UTC (rev
267)
@@ -131,7 +131,7 @@
"gnunetd", /* arg0, path to gnunet binary */
"-d", /* do not daemonize so we can easily kill you */
"-L",
- "DEBUG", /* gnunetd loglevel */
+ "NOTHING", /* gnunetd loglevel */
"-c",
"check.conf", /* configuration file */
NULL)) {
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2005-02-15 03:45:07 UTC
(rev 266)
+++ GNUnet/src/applications/fs/module/ondemand.c 2005-02-15 05:13:40 UTC
(rev 267)
@@ -329,7 +329,37 @@
return YES;
}
+
/**
+ * If the data portion and type of the value match our value in the
+ * closure, copy the header (prio, anonymityLevel, expirationTime) and
+ * abort the iteration: we found what we're looing for. Otherwise
+ * continue.
+ */
+static int completeValue(const HashCode160 * key,
+ const Datastore_Value * value,
+ void * closure) {
+ Datastore_Value * comp = closure;
+
+ if ( (comp->size != value->size) ||
+ (0 != memcmp(&value[1],
+ &comp[1],
+ ntohl(value->size) - sizeof(Datastore_Value))) ) {
+ LOG(LOG_DEBUG,
+ "'%s' found value that does not match (%u, %u).\n",
+ __FUNCTION__,
+ ntohl(comp->size),
+ ntohl(value->size));
+ return OK;
+ }
+ *comp = *value; /* make copy! */
+ LOG(LOG_DEBUG,
+ "'%s' found value that matches.\n",
+ __FUNCTION__);
+ return SYSERR;
+}
+
+/**
* Unindex the file with the given ID. Removes the file from the
* filesystem and all of the corresponding obd blocks from the
* datastore. Note that the IBlocks are NOT removed by this function.
@@ -351,6 +381,7 @@
unsigned long long size;
unsigned long long delta;
DBlock * block;
+ EncName enc;
fn = getOnDemandFile(fileId);
LOG(LOG_DEBUG,
@@ -390,6 +421,7 @@
odb.header.prio = 0;
odb.header.anonymityLevel = 0;
odb.header.expirationTime = 0;
+ odb.type = htonl(ONDEMAND_BLOCK);
odb.fileOffset = htonll(pos);
odb.blockSize = htonl(delta);
odb.fileId = *fileId;
@@ -397,11 +429,21 @@
fileBlockGetQuery(block,
delta + sizeof(DBlock),
&key);
- ret = datastore->del(&key,
- &odb.header);
- if (ret == SYSERR) {
- LOG(LOG_DEBUG,
- "ODB block from offset %llu already missing from datastore.\n",
+ if (SYSERR == datastore->get(&key,
+ ONDEMAND_BLOCK,
+ &completeValue,
+ &odb.header)) /* aborted == found! */
+ ret = datastore->del(&key,
+ &odb.header);
+ else /* not found */
+ ret = SYSERR;
+ if (ret == SYSERR) {
+ IFLOG(LOG_WARNING,
+ hash2enc(&key,
+ &enc));
+ LOG(LOG_WARNING,
+ _("Unindexed ODB block '%s' from offset %llu already missing from
datastore.\n"),
+ &enc,
pos);
}
pos += delta;
Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c 2005-02-15 03:45:07 UTC
(rev 266)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c 2005-02-15 05:13:40 UTC
(rev 267)
@@ -979,10 +979,13 @@
"DELETE FROM gn070 WHERE hash='%s'",
escapedHash);
} else {
+ /* FIXME: type=%d since the value is a
+ signed int here; it would be clean(er) if
+ we were to use prepared statements here, too */
SNPRINTF(scratch,
n,
"DELETE FROM gn070 WHERE hash='%s'"
- " AND size=%u AND type=%u AND prio=%u"
+ " AND size=%u AND type=%d AND prio=%u"
" AND anonLevel=%u AND expire=%lld"
" AND value='%s'",
escapedHash,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r267 - in GNUnet/src/applications: datastore fs/lib fs/module sqstore_mysql,
grothoff <=