gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r238 - GNUnet/src/applications/fs/module


From: grothoff
Subject: [GNUnet-SVN] r238 - GNUnet/src/applications/fs/module
Date: Thu, 10 Feb 2005 19:08:53 -0800 (PST)

Author: grothoff
Date: 2005-02-10 19:08:53 -0800 (Thu, 10 Feb 2005)
New Revision: 238

Modified:
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/applications/fs/module/ondemand.c
Log:
fix

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-02-11 02:51:39 UTC (rev 
237)
+++ GNUnet/src/applications/fs/module/fs.c      2005-02-11 03:08:53 UTC (rev 
238)
@@ -525,7 +525,7 @@
  * gap routing protocol.
  */
 static int gapGetConverter(const HashCode160 * key,
-                          const Datastore_Value * value,
+                          const Datastore_Value * invalue,
                           void * cls) {
   GGC * ggc = (GGC*) cls;
   GapWrapper * gw;
@@ -533,18 +533,36 @@
   unsigned int size;
   cron_t et;
   cron_t now;
+  const Datastore_Value * value;
+  Datastore_Value * xvalue;
 
+  if (ntohl(invalue->type) == ONDEMAND_BLOCK) {
+    if (OK != ONDEMAND_getIndexed(datastore,
+                                 invalue,
+                                 key,
+                                 &xvalue))
+      return SYSERR;
+    value = xvalue;
+  } else {
+    xvalue = NULL;
+    value = invalue;
+  }
+                  
   ret = isDatumApplicable(ntohl(value->type),
                          ntohl(value->size) - sizeof(Datastore_Value),
                          (const char*) &value[1],
                          ggc->keyCount,
                          ggc->keys);
-  if (ret == SYSERR)
+  if (ret == SYSERR) {
+    FREENONNULL(xvalue);
     return SYSERR; /* no query will ever match */
-  if (ret == NO)
+  }
+  if (ret == NO) {
+    FREENONNULL(xvalue);
     return OK; /* Additional filtering based on type;
                  i.e., namespace request and namespace
                  in reply does not match namespace in query */
+  }
   size = sizeof(GapWrapper) +
     ntohl(value->size) -
     sizeof(Datastore_Value);
@@ -577,23 +595,27 @@
                             &timevect)) {
        LOG(LOG_WARNING,
            _("Failed to get traffic stats.\n"));
+       FREENONNULL(xvalue);
        return OK;
       }
       if (level > 1000) {
        if (peers < level / 1000) {
          LOG(LOG_DEBUG,
              "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
+         FREENONNULL(xvalue);
          return OK;
        }
        if (count < level % 1000) {
          LOG(LOG_DEBUG,
              "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
+         FREENONNULL(xvalue);
          return OK;
        }
       } else {
        if (count < level) {
          LOG(LOG_DEBUG,
              "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
+         FREENONNULL(xvalue);
          return OK;
        }
       }
@@ -601,6 +623,7 @@
       /* traffic required by module not loaded;
         refuse to hand out data that requires
         anonymity! */
+      FREENONNULL(xvalue);
       return OK;
     }
   }
@@ -629,6 +652,7 @@
   else
     ret = OK;
   FREE(gw);
+  FREENONNULL(xvalue);
   return ret;
 }
 
@@ -700,7 +724,7 @@
  * DHT routing protocol.
  */
 static int dhtGetConverter(const HashCode160 * key,
-                          const Datastore_Value * value,
+                          const Datastore_Value * invalue,
                           void * cls) {
   GGC * ggc = (GGC*) cls;
   GapWrapper * gw;
@@ -708,25 +732,45 @@
   unsigned int size;
   cron_t et;
   cron_t now;
+  const Datastore_Value * value;
+  Datastore_Value * xvalue;
 
+  if (ntohl(invalue->type) == ONDEMAND_BLOCK) {
+    if (OK != ONDEMAND_getIndexed(datastore,
+                                 invalue,
+                                 key,
+                                 &xvalue))
+      return SYSERR;
+    value = xvalue;
+  } else {
+    xvalue = NULL;
+    value = invalue;
+  }
+
   ret = isDatumApplicable(ntohl(value->type),
                          ntohl(value->size) - sizeof(Datastore_Value),
                          (char*) &value[1],
                          ggc->keyCount,
                          ggc->keys);
-  if (ret == SYSERR)
+  if (ret == SYSERR) {
+    FREENONNULL(xvalue);
     return SYSERR; /* no query will ever match */
-  if (ret == NO)
+  }
+  if (ret == NO) {
+    FREENONNULL(xvalue);
     return OK; /* Additional filtering based on type;
                  i.e., namespace request and namespace
                  in reply does not match namespace in query */
+  }
   size = sizeof(GapWrapper) +
     ntohl(value->size) -
     sizeof(Datastore_Value);
 
-  if (ntohl(value->anonymityLevel) != 0) 
+  if (ntohl(value->anonymityLevel) != 0) {
+    FREENONNULL(xvalue);
     return OK; /* do not allow anonymous content to leak through DHT */
-  
+  }
+
   gw = MALLOC(size);
   gw->dc.size = htonl(size);
   et = ntohll(value->expirationTime);
@@ -751,6 +795,7 @@
   else
     ret = OK;
   FREE(gw);
+  FREENONNULL(xvalue);
   return ret;
 }
 

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2005-02-11 02:51:39 UTC 
(rev 237)
+++ GNUnet/src/applications/fs/module/ondemand.c        2005-02-11 03:08:53 UTC 
(rev 238)
@@ -272,7 +272,10 @@
   ret = fileBlockEncode(db,
                        ntohl(odb->blockSize) + sizeof(DBlock),
                        query,
-                       enc);  
+                       enc);
+  (*enc)->anonymityLevel = dbv->anonymityLevel;
+  (*enc)->expirationTime = dbv->expirationTime;
+  (*enc)->prio = dbv->prio;
   FREE(db);
   FREE(fn);
   if (ret == SYSERR)
@@ -325,7 +328,7 @@
   unsigned long long pos;
   unsigned long long size;
   unsigned long long delta;
-  char * block;
+  DBlock * block;
 
   fn = getOnDemandFile(fileId);
   fd = OPEN(fn, 
@@ -338,13 +341,14 @@
   }
   pos = 0;
   size = getFileSize(fn);
-  block = MALLOC(blocksize);
+  block = MALLOC(sizeof(DBlock) + blocksize);
+  block->type = htonl(D_BLOCK);
   while (pos < size) {
     delta = size - pos;
     if (delta > blocksize)
       delta = blocksize;
     if (delta != READ(fd,
-                     block,
+                     &block[1],
                      delta)) {
       LOG_FILE_STRERROR(LOG_ERROR, "read", fn);
       CLOSE(fd);





reply via email to

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