[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2882 - in GNUnet/src/applications: advertising fs/ecrs
From: |
grothoff |
Subject: |
[GNUnet-SVN] r2882 - in GNUnet/src/applications: advertising fs/ecrs |
Date: |
Mon, 22 May 2006 07:03:55 -0700 (PDT) |
Author: grothoff
Date: 2006-05-22 07:03:51 -0700 (Mon, 22 May 2006)
New Revision: 2882
Modified:
GNUnet/src/applications/advertising/advertising.c
GNUnet/src/applications/fs/ecrs/download.c
Log:
fixing download resume problem (wrong .B/.C offset calculations)
Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c 2006-05-22 12:32:32 UTC
(rev 2881)
+++ GNUnet/src/applications/advertising/advertising.c 2006-05-22 14:03:51 UTC
(rev 2882)
@@ -350,8 +350,10 @@
SendData * sd) {
P2P_hello_MESSAGE * helo;
TSession * tsession;
+ int prio;
+#if DEBUG_ADVERTISING
EncName other;
- int prio;
+#endif
if (confirmed == NO)
return;
@@ -359,9 +361,10 @@
return; /* don't advertise NAT addresses via broadcast */
if (weak_randomi(sd->n) != 0)
return;
- hash2enc(&hi->hashPubKey,
- &other);
#if DEBUG_ADVERTISING
+ IFLOG(LOG_DEBUG,
+ hash2enc(&hi->hashPubKey,
+ &other));
LOG(LOG_DEBUG,
"Entering `%s' with target `%s'.\n",
__FUNCTION__,
@@ -596,6 +599,8 @@
if (getCPULoad() > 100)
return; /* CPU load too high... */
+ if (getNetworkLoadUp() > 100)
+ return; /* network load too high... */
#if DEBUG_ADVERTISING
LOG(LOG_CRON,
"Enter `%s'.\n",
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2006-05-22 12:32:32 UTC (rev
2881)
+++ GNUnet/src/applications/fs/ecrs/download.c 2006-05-22 14:03:51 UTC (rev
2882)
@@ -208,19 +208,23 @@
void * buf,
unsigned int len) {
int ret;
- size_t lpos;
- lpos = pos;
- for (ret=0;ret<level;ret++)
- lpos /= CHK_PER_INODE;
MUTEX_LOCK(&this->lock);
lseek(this->handles[level],
- lpos,
+ pos,
SEEK_SET);
ret = READ(this->handles[level],
buf,
len);
MUTEX_UNLOCK(&this->lock);
+#ifdef DEBUG_DOWNLOAD
+ LOG(LOG_DEBUG,
+ "IOC read at level %u offset %llu wanted %u got %d\n",
+ level,
+ pos,
+ len,
+ ret);
+#endif
return ret;
}
@@ -240,14 +244,10 @@
void * buf,
unsigned int len) {
int ret;
- size_t lpos;
- lpos = pos;
- for (ret=0;ret<level;ret++)
- lpos /= CHK_PER_INODE;
MUTEX_LOCK(&this->lock);
lseek(this->handles[level],
- lpos,
+ pos,
SEEK_SET);
ret = WRITE(this->handles[level],
buf,
@@ -261,6 +261,13 @@
STRERROR(errno));
}
MUTEX_UNLOCK(&this->lock);
+#ifdef DEBUG_DOWNLOAD
+ LOG(LOG_DEBUG,
+ "IOC write at level %u offset %llu writes %u\n",
+ level,
+ pos,
+ len);
+#endif
return ret;
}
@@ -618,29 +625,31 @@
if (node->offset + (unsigned long long) ret
> node->ctx->total)
ret = (unsigned int) (node->ctx->total - node->offset);
-#if 0
- PRINTF("Node at offset %llu and level %d has size %u\n",
- node->offset,
- node->level,
- ret);
+#if DEBUG_DOWNLOAD
+ LOG(LOG_DEBUG,
+ "Node at offset %llu and level %d has size %u\n",
+ node->offset,
+ node->level,
+ ret);
#endif
return ret;
}
rsize = DBLOCK_SIZE;
for (i=0;i<node->level-1;i++)
rsize *= CHK_PER_INODE;
- spos = rsize * CHK_PER_INODE * (node->offset / sizeof(CHK));
+ spos = rsize * (node->offset / sizeof(CHK));
epos = spos + rsize * CHK_PER_INODE;
if (epos > node->ctx->total)
epos = node->ctx->total;
ret = (epos - spos) / rsize;
if (ret * rsize < epos - spos)
ret++; /* need to round up! */
-#if 0
- PRINTF("Node at offset %llu and level %d has size %u\n",
- node->offset,
- node->level,
- ret * sizeof(CHK));
+#if DEBUG_DOWNLOAD
+ LOG(LOG_DEBUG,
+ "Node at offset %llu and level %d has size %u\n",
+ node->offset,
+ node->level,
+ ret * sizeof(CHK));
#endif
return ret * sizeof(CHK);
}
@@ -757,6 +766,7 @@
int ret;
char * data;
unsigned int size;
+ HashCode512 hc;
size = getNodeSize(node);
data = MALLOC(size);
@@ -766,8 +776,6 @@
data,
size);
if (res == size) {
- HashCode512 hc;
-
hash(data,
size,
&hc);
@@ -819,9 +827,9 @@
}
if (node->level == 1) {
levelSize = DBLOCK_SIZE;
- baseOffset = node->offset / sizeof(CHK) * CHK_PER_INODE * DBLOCK_SIZE;
+ baseOffset = node->offset / sizeof(CHK) * DBLOCK_SIZE;
} else {
- levelSize = sizeof(CHK);
+ levelSize = sizeof(CHK) * CHK_PER_INODE;
baseOffset = node->offset * CHK_PER_INODE;
}
chks = (CHK*) data;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2882 - in GNUnet/src/applications: advertising fs/ecrs,
grothoff <=