[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4974 - GNUnet/src/applications/fs/ecrs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4974 - GNUnet/src/applications/fs/ecrs |
Date: |
Fri, 8 Jun 2007 23:41:57 -0600 (MDT) |
Author: grothoff
Date: 2007-06-08 23:41:57 -0600 (Fri, 08 Jun 2007)
New Revision: 4974
Modified:
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/ecrs/namespacetest.c
GNUnet/src/applications/fs/ecrs/peer.conf
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/ecrs/uri.c
Log:
fixing various bugs in namespace search
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2007-06-09 05:02:41 UTC (rev
4973)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2007-06-09 05:41:57 UTC (rev
4974)
@@ -403,6 +403,7 @@
SBlock * sb;
HashCode512 namespace;
char * dstURI;
+ char * destPos;
char * fileName;
PrivateKeyEncoded * hke;
char * dst;
@@ -446,20 +447,21 @@
dstURI = ECRS_uriToString(dstU);
mdsize = ECRS_sizeofMetaData(md,
ECRS_SERIALIZE_PART);
- size = mdsize + sizeof(SBlock) + strlen(dstURI) + 1;
+ size = mdsize + sizeof(SBlock) + strlen(dstURI) + 1;
if (size > MAX_SBLOCK_SIZE) {
size = MAX_SBLOCK_SIZE;
value = MALLOC(sizeof(Datastore_Value) +
size);
sb = (SBlock*) &value[1];
sb->type = htonl(S_BLOCK);
- memcpy(&sb[1],
+ destPos = (char*) &sb[1];
+ memcpy(destPos,
dstURI,
strlen(dstURI) + 1);
mdsize = size - sizeof(SBlock) - strlen(dstURI) - 1;
mdsize = ECRS_serializeMetaData(ectx,
md,
- &((char*)&sb[1])[strlen(dstURI)+1],
+ &destPos[strlen(dstURI)+1],
mdsize,
ECRS_SERIALIZE_PART);
if (mdsize == -1) {
@@ -468,18 +470,19 @@
freePrivateKey(hk);
return NULL;
}
- size = sizeof(SBlock) + mdsize;
+ size = sizeof(SBlock) + mdsize + strlen(dstURI) + 1;
} else {
value = MALLOC(sizeof(Datastore_Value) +
size);
sb = (SBlock*) &value[1];
sb->type = htonl(S_BLOCK);
- memcpy(&sb[1],
+ destPos = (char*) &sb[1];
+ memcpy(destPos,
dstURI,
strlen(dstURI) + 1);
ECRS_serializeMetaData(ectx,
md,
- &((char*)&sb[1])[strlen(dstURI)+1],
+ &destPos[strlen(dstURI)+1],
mdsize,
ECRS_SERIALIZE_FULL);
}
Modified: GNUnet/src/applications/fs/ecrs/namespacetest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespacetest.c 2007-06-09 05:02:41 UTC
(rev 4973)
+++ GNUnet/src/applications/fs/ecrs/namespacetest.c 2007-06-09 05:41:57 UTC
(rev 4974)
@@ -38,6 +38,25 @@
static struct GC_Configuration * cfg;
+static int match;
+
+static int spcb(const ECRS_FileInfo * fi,
+ const HashCode512 * key,
+ int isRoot,
+ void * closure) {
+ struct ECRS_URI * want = closure;
+
+ if (ECRS_equalsUri(want,
+ fi->uri))
+ match = 1;
+ else
+ fprintf(stderr,
+ "Namespace search returned unexpected result: \nHAVE: %s\nWANT:
%s...\n",
+ ECRS_uriToString(fi->uri),
+ ECRS_uriToString(want));
+ return OK;
+}
+
static int testNamespace() {
HashCode512 root;
HashCode512 thisId;
@@ -76,8 +95,8 @@
advURI = ECRS_addToNamespace(NULL,
cfg,
CHECKNAME,
- 0,
- 0,
+ 1, /* anonymity */
+ 1000, /* priority */
5 * cronMINUTES + get_time(),
TIME(NULL) + 300,
0,
@@ -86,6 +105,19 @@
uri,
meta);
CHECK(NULL != advURI);
+ fprintf(stderr,
+ "Starting namespace search...\n");
+ CHECK(OK == ECRS_search(NULL,
+ cfg,
+ advURI,
+ 1,
+ 60 * cronSECONDS,
+ &spcb,
+ uri,
+ NULL,
+ NULL));
+ fprintf(stderr,
+ "Completed namespace search...\n");
CHECK(OK == ECRS_deleteNamespace(NULL,
cfg,
CHECKNAME));
@@ -95,6 +127,7 @@
ECRS_freeMetaData(meta);
ECRS_freeUri(rootURI);
ECRS_freeUri(advURI);
+ CHECK(match == 1);
return 0;
}
@@ -115,7 +148,7 @@
GE_ASSERT(NULL, daemon > 0);
if (OK != connection_wait_for_running(NULL,
cfg,
- 30 * cronSECONDS)) {
+ 60 * cronSECONDS)) {
failureCount++;
} else {
PTHREAD_SLEEP(5 * cronSECONDS);
Modified: GNUnet/src/applications/fs/ecrs/peer.conf
===================================================================
--- GNUnet/src/applications/fs/ecrs/peer.conf 2007-06-09 05:02:41 UTC (rev
4973)
+++ GNUnet/src/applications/fs/ecrs/peer.conf 2007-06-09 05:41:57 UTC (rev
4974)
@@ -15,6 +15,8 @@
APPLICATIONS = "fs getoption stats"
TRANSPORTS = ""
+
+
[MODULES]
sqstore = "sqstore_sqlite"
# you can also use sqstore_mysql here if
@@ -27,6 +29,12 @@
HELOEXCHANGE = NO
TRUSTED = 127.0.0.0/8;
+[LOGGING]
+USER-LEVEL = WARNING
+ADMIN-LEVEL = WARNING
+DEVELOPER = YES
+
+
[LOAD]
INTERFACES = eth0
BASICLIMITING = YES
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2007-06-09 05:02:41 UTC (rev
4973)
+++ GNUnet/src/applications/fs/ecrs/search.c 2007-06-09 05:41:57 UTC (rev
4974)
@@ -177,10 +177,10 @@
&uri->data.sks.namespace,
&keys[0]); /* compute routing key r = H(identifier) ^
namespace */
keys[1] = uri->data.sks.namespace;
- addPS(K_BLOCK,
+ addPS(S_BLOCK,
2,
&keys[0],
- &uri->data.sks.identifier,
+ &uri->data.sks.identifier, /* identifier = decryption key */
sqc);
break;
}
@@ -471,25 +471,27 @@
ECRS_decryptInPlace(&ps->decryptKey,
&sb->creationTime,
size
+ - sizeof(unsigned int)
- sizeof(Signature)
- sizeof(PublicKey)
- sizeof(HashCode512));
- j = sizeof(SBlock);
- while ( (j < size) &&
- (((char*) &sb[1])[j] != '\0') )
+ j = 0;
+ dstURI = (const char*) &sb[1];
+ while ( (j < size - sizeof(SBlock)) &&
+ (dstURI[j] != '\0') )
j++;
- if (j == size) {
+ if (j == size - sizeof(SBlock)) {
GE_BREAK(ectx, 0); /* sblock malformed */
FREE(sb);
return SYSERR;
- }
- dstURI = (const char*) &sb[1];
+ }
j++;
+ /* j == strlen(dstURI) + 1 */
fi.meta = ECRS_deserializeMetaData(ectx,
&dstURI[j],
- size - j);
+ size - j - sizeof(SBlock));
if (fi.meta == NULL) {
- GE_BREAK(ectx, 0); /* kblock malformed */
+ GE_BREAK(ectx, 0); /* sblock malformed */
FREE(sb);
return SYSERR;
}
@@ -589,7 +591,8 @@
ctx.lock);
addQueryForURI(uri,
&ctx);
- while ( (OK == tt(ttClosure)) &&
+ while ( ( (NULL == tt) ||
+ (OK == tt(ttClosure)) ) &&
(NO == GNUNET_SHUTDOWN_TEST()) &&
(timeout > now) &&
(ctx.aborted == NO) ) {
@@ -640,9 +643,10 @@
&ctx);
}
MUTEX_UNLOCK(ctx.lock);
- if (! ( (OK == tt(ttClosure)) &&
- (timeout > now) &&
- (ctx.aborted == NO) ) )
+ if ( ( (NULL != tt) &&
+ (OK != tt(ttClosure))) ||
+ (timeout <= now) ||
+ (ctx.aborted != NO) )
break;
PTHREAD_SLEEP(100 * cronMILLIS);
now = get_time();
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2007-06-09 05:02:41 UTC (rev
4973)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2007-06-09 05:41:57 UTC (rev
4974)
@@ -322,7 +322,8 @@
return SYSERR;
pos += strlen(ECRS_SUBSPACE_INFIX);
if ( (slen < pos+sizeof(EncName)+1) ||
- (!(uri[pos+sizeof(EncName)-1] == '/') || (uri[pos+sizeof(EncName)-1] ==
'\\')) )
+ (! ( (uri[pos+sizeof(EncName)-1] == '/') ||
+ (uri[pos+sizeof(EncName)-1] == '\\') ) ) )
return SYSERR;
up = STRDUP(uri);
@@ -333,7 +334,7 @@
return SYSERR;
}
if ( (slen != pos+2*sizeof(EncName)-1) ||
- (OK == enc2hash(&up[pos+sizeof(EncName)],
+ (OK != enc2hash(&up[pos+sizeof(EncName)],
identifier)) ) {
if (up[slen-1] == '\\')
up[--slen] = '\0';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4974 - GNUnet/src/applications/fs/ecrs,
gnunet <=