[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r258 - in GNUnet/src/applications/fs: ecrs module
From: |
grothoff |
Subject: |
[GNUnet-SVN] r258 - in GNUnet/src/applications/fs: ecrs module |
Date: |
Sun, 13 Feb 2005 20:22:47 -0800 (PST) |
Author: grothoff
Date: 2005-02-13 20:22:47 -0800 (Sun, 13 Feb 2005)
New Revision: 258
Modified:
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/ecrs/tree.c
GNUnet/src/applications/fs/ecrs/upload.c
GNUnet/src/applications/fs/module/fs.c
Log:
gnunet-download works
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2005-02-14 02:21:20 UTC (rev
257)
+++ GNUnet/src/applications/fs/ecrs/download.c 2005-02-14 04:22:47 UTC (rev
258)
@@ -584,11 +584,11 @@
for (i=0;i<node->level;i++)
rsize *= CHK_PER_INODE;
spos = rsize * (node->offset / sizeof(CHK));
- epos = rsize * (node->offset / sizeof(CHK) + CHK_PER_INODE);
+ epos = spos + rsize;
if (epos > node->ctx->total)
epos = node->ctx->total;
- ret = (epos - spos) / rsize; /* rounds down! */
- if (ret * rsize < epos - spos)
+ ret = (epos - spos) / (rsize / CHK_PER_INODE);
+ if (ret * (rsize / CHK_PER_INODE) < epos - spos)
ret++; /* need to round up! */
return ret * sizeof(CHK);
}
@@ -743,6 +743,9 @@
int i;
NodeClosure * child;
unsigned int childcount;
+ CHK * chks;
+ unsigned int levelSize;
+ unsigned long long baseOffset;
GNUNET_ASSERT(node->level > 0);
childcount = size / sizeof(CHK);
@@ -750,8 +753,18 @@
BREAK();
return;
}
+ if (node->level == 1)
+ levelSize = DBLOCK_SIZE;
+ else
+ levelSize = sizeof(CHK);
+ baseOffset = node->offset * CHK_PER_INODE;
+ chks = (CHK*) data;
for (i=0;i<childcount;i++) {
child = MALLOC(sizeof(NodeClosure));
+ child->ctx = node->ctx;
+ child->chk = chks[i];
+ child->offset = baseOffset + i * levelSize;
+ child->level = node->level - 1;
if (NO == checkPresent(child))
addRequest(node->ctx->rm,
child);
@@ -875,6 +888,7 @@
}
}
FREE(data);
+ FREE(node);
return OK;
}
@@ -1102,7 +1116,7 @@
RequestManager * rm;
int ret;
CommonCtx ctx;
- NodeClosure top;
+ NodeClosure * top;
FileIdentifier fid;
fid = uri->data.chk;
@@ -1124,11 +1138,12 @@
ctx.dpcbClosure = dpcbClosure;
ctx.total = ntohll(fid.file_length);
ctx.completed = 0;
- top.ctx = &ctx;
- top.chk = fid.chk;
- top.offset = 0;
- top.level = computeDepth(ctx.total);
- addRequest(rm, &top);
+ top = MALLOC(sizeof(NodeClosure));
+ top->ctx = &ctx;
+ top->chk = fid.chk;
+ top->offset = 0;
+ top->level = computeDepth(ctx.total);
+ addRequest(rm, top);
while ( (OK == tt(ttClosure)) &&
(rm->abortFlag == NO) &&
(rm->requestListIndex != 0) )
Modified: GNUnet/src/applications/fs/ecrs/tree.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/tree.c 2005-02-14 02:21:20 UTC (rev
257)
+++ GNUnet/src/applications/fs/ecrs/tree.c 2005-02-14 04:22:47 UTC (rev
258)
@@ -41,3 +41,4 @@
}
return treeDepth;
}
+
Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c 2005-02-14 02:21:20 UTC (rev
257)
+++ GNUnet/src/applications/fs/ecrs/upload.c 2005-02-14 04:22:47 UTC (rev
258)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing
authors)
+ (C) 2001, 2002, 2003, 2004, 2005 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
@@ -55,15 +55,15 @@
CHK ichk;
EncName enc;
- size = ntohl(iblocks[level]->size) - sizeof(Datastore_Value) -
sizeof(DBlock);
- present = size / sizeof(CHK);
+ size = ntohl(iblocks[level]->size) - sizeof(Datastore_Value);
+ present = (size - sizeof(DBlock)) / sizeof(CHK);
db = (DBlock*) &iblocks[level][1];
if (present == CHK_PER_INODE) {
fileBlockGetKey(db,
- size + sizeof(DBlock),
+ size,
&ichk.key);
fileBlockGetQuery(db,
- size + sizeof(DBlock),
+ size,
&ichk.query);
IFLOG(LOG_DEBUG,
hash2enc(&ichk.query,
@@ -72,12 +72,19 @@
"Query for current iblock at level %u is %s\n",
level,
&enc);
- if (OK != pushBlock(sock, &ichk, level+1, iblocks))
+ if (OK != pushBlock(sock,
+ &ichk,
+ level+1,
+ iblocks))
return SYSERR;
fileBlockEncode(db,
size,
&ichk.query,
&value);
+ if (value == NULL) {
+ BREAK();
+ return SYSERR;
+ }
IFLOG(LOG_DEBUG,
hash2enc(&ichk.query,
&enc));
@@ -96,7 +103,9 @@
memcpy(&((char*)db)[size],
chk,
sizeof(CHK));
- iblocks[level]->size = htonl(size + sizeof(Datastore_Value) +
sizeof(DBlock));
+ iblocks[level]->size = htonl(size +
+ sizeof(CHK) +
+ sizeof(Datastore_Value));
return OK;
}
@@ -278,8 +287,8 @@
dblock->expirationTime = htonll(expirationTime);
db = (DBlock*) &dblock[1];
db->type = htonl(D_BLOCK);
- iblocks = MALLOC(sizeof(Datastore_Value*) * treedepth);
- for (i=0;i<treedepth;i++) {
+ iblocks = MALLOC(sizeof(Datastore_Value*) * (treedepth+1));
+ for (i=0;i<=treedepth;i++) {
iblocks[i] = MALLOC(sizeof(Datastore_Value) + IBLOCK_SIZE +
sizeof(DBlock));
iblocks[i]->size = htonl(sizeof(Datastore_Value) + sizeof(DBlock));
iblocks[i]->anonymityLevel = htonl(anonymityLevel);
@@ -323,7 +332,8 @@
hash2enc(&chk.query,
&enc));
LOG(LOG_DEBUG,
- "Query for current block is %s\n",
+ "Query for current block of size %u is %s\n",
+ size,
&enc);
if (doIndex) {
if (SYSERR == FS_index(sock,
@@ -362,27 +372,33 @@
if (tt != NULL)
if (OK != tt(ttClosure))
goto FAILURE;
+ LOG(LOG_DEBUG,
+ "Tree depth is %u, walking up tree.\n",
+ treedepth);
for (i=0;i<treedepth;i++) {
size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
- if (size == sizeof(DBlock))
+ if (size == sizeof(DBlock)) {
+ LOG(LOG_DEBUG,
+ "Level %u is empty\n",
+ i);
continue;
- db = (DBlock*) &iblocks[i];
+ }
+ db = (DBlock*) &iblocks[i][1];
fileBlockGetKey(db,
- size + sizeof(DBlock),
+ size,
&chk.key);
LOG(LOG_DEBUG,
- "Computing query for %u bytes content %.*s\n",
- size,
- size, db);
+ "Computing query for %u bytes content.\n",
+ size);
fileBlockGetQuery(db,
- size + sizeof(DBlock),
+ size,
&chk.query);
IFLOG(LOG_DEBUG,
hash2enc(&chk.query,
&enc));
LOG(LOG_DEBUG,
"Query for current block at level %u is %s\n",
- treedepth,
+ i,
&enc);
if (OK != pushBlock(sock,
&chk,
@@ -393,6 +409,10 @@
size,
&chk.query,
&value);
+ if (value == NULL) {
+ BREAK();
+ goto FAILURE;
+ }
if (OK != FS_insert(sock,
value)) {
FREE(value);
@@ -416,7 +436,7 @@
&enc);
/* build URI */
fid.file_length = htonll(filesize);
- fid.chk = chk;
+ fid.chk = *(CHK*)&((DBlock*) &iblocks[treedepth][1])[1];
uris = createFileURI(&fid);
*uri = ECRS_stringToUri(uris);
FREE(uris);
@@ -428,7 +448,7 @@
releaseClientSocket(sock);
return OK;
FAILURE:
- for (i=0;i<treedepth;i++)
+ for (i=0;i<=treedepth;i++)
FREENONNULL(iblocks[i]);
FREE(iblocks);
FREE(dblock);
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2005-02-14 02:21:20 UTC (rev
257)
+++ GNUnet/src/applications/fs/module/fs.c 2005-02-14 04:22:47 UTC (rev
258)
@@ -315,7 +315,8 @@
ret = datastore->put(&query,
datum);
MUTEX_UNLOCK(&lock);
- if (ntohl(ri->anonymityLevel) == 0) {
+ if ( (ntohl(ri->anonymityLevel) == 0) &&
+ (dht != NULL) ) {
GapWrapper * gw;
unsigned int size;
cron_t now;
@@ -699,7 +700,7 @@
&gapGetConverter,
&myClosure);
}
- if (ret == OK)
+ if (ret != SYSERR)
ret = datastore->get(&keys[0],
type,
&gapGetConverter,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r258 - in GNUnet/src/applications/fs: ecrs module,
grothoff <=