gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r4811 - GNUnet/src/applications/fs/ecrs


From: gnunet
Subject: [GNUnet-SVN] r4811 - GNUnet/src/applications/fs/ecrs
Date: Sun, 27 May 2007 16:09:26 -0600 (MDT)

Author: grothoff
Date: 2007-05-27 16:09:25 -0600 (Sun, 27 May 2007)
New Revision: 4811

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
Log:
range limiting for DBlocks

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2007-05-27 21:55:07 UTC (rev 
4810)
+++ GNUnet/src/applications/fs/ecrs/download.c  2007-05-27 22:09:25 UTC (rev 
4811)
@@ -449,8 +449,9 @@
  *
  * @return NULL on error
  */
-static RequestManager * createRequestManager(struct GE_Context * ectx,
-                                            struct GC_Configuration * cfg) {
+static RequestManager * 
+createRequestManager(struct GE_Context * ectx,
+                    struct GC_Configuration * cfg) {
   RequestManager * rm;
 
   rm = MALLOC(sizeof(RequestManager));
@@ -665,6 +666,8 @@
 typedef struct CommonCtx {
   unsigned long long total;
   unsigned long long completed;
+  unsigned long long offset;
+  unsigned long long length;
   cron_t startTime;
   cron_t TTL_DECREMENT;
   RequestManager * rm;
@@ -744,10 +747,10 @@
     if (node->ctx->completed > 0) {
       eta = (cron_t) (node->ctx->startTime +
                      (((double)(eta - 
node->ctx->startTime)/(double)node->ctx->completed))
-                     * (double)node->ctx->total);
+                     * (double)node->ctx->length);
     }
     if (node->ctx->dpcb != NULL) {
-      node->ctx->dpcb(node->ctx->total,
+      node->ctx->dpcb(node->ctx->length,
                      node->ctx->completed,
                      eta,
                      node->offset,
@@ -834,6 +837,11 @@
  * block is present and it is an iblock, downloading the children is
  * triggered.
  *
+ * Also checks if the block is within the range of blocks
+ * that we are supposed to download.  If not, the method
+ * returns as if the block is present but does NOT signal
+ * progress.
+ *
  * @param node that is checked for presence
  * @return YES if present, NO if not.
  */
@@ -845,6 +853,15 @@
   HashCode512 hc;
 
   size = getNodeSize(node);
+
+  /* first check if node is within range.
+     For now, keeping it simple, we only do
+     this for level-0 nodes */
+  if ( (node->level == 0) &&
+       ( (node->offset + size < node->ctx->offset) ||
+        (node->offset > node->ctx->offset + node->ctx->length) ) )
+    return YES;
+
   data = MALLOC(size);
   res = readFromIOC(node->ctx->ioc,
                    node->level,
@@ -1052,9 +1069,9 @@
 
   for (i=0;i<10;i++) {
     if ( (node->ctx->completed * 10000L >
-         node->ctx->total * (10000L - (1024 >> i)) ) &&
+         node->ctx->length * (10000L - (1024 >> i)) ) &&
         ( (node->ctx->completed-size) * 10000L <=
-          node->ctx->total * (10000L - (1024 >> i)) ) ) {
+          node->ctx->length * (10000L - (1024 >> i)) ) ) {
       /* end-game boundary crossed, slaughter TTLs */
       requestManagerEndgame(node->ctx->rm);
     }
@@ -1477,6 +1494,8 @@
 
   ctx.startTime = get_time();
   ctx.anonymityLevel = anonymityLevel;
+  ctx.offset = offset;
+  ctx.length = length;
   ctx.TTL_DECREMENT = 5 * cronSECONDS; /* HACK! */
   ctx.rm = rm;
   ctx.ioc = &ioc;
@@ -1504,7 +1523,9 @@
   }
 
   if ( (rm->requestListIndex == 0) &&
-       (ctx.completed == ctx.total) &&
+       ( (ctx.completed == ctx.total) ||
+        ( (ctx.total != ctx.length) &&
+          (ctx.completed >= ctx.length) ) ) &&
        (rm->abortFlag == NO) ) {
     ret = OK;
   } else {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]