gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r6006 - in GNUnet/src: applications/datastore applications/


From: gnunet
Subject: [GNUnet-SVN] r6006 - in GNUnet/src: applications/datastore applications/fs applications/fs/module applications/stats include
Date: Fri, 21 Dec 2007 15:28:13 -0700 (MST)

Author: grothoff
Date: 2007-12-21 15:28:12 -0700 (Fri, 21 Dec 2007)
New Revision: 6006

Modified:
   GNUnet/src/applications/datastore/datastore.c
   GNUnet/src/applications/fs/ecrs_core.c
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/applications/fs/module/migration.c
   GNUnet/src/applications/fs/module/ondemand.c
   GNUnet/src/applications/stats/sqstats.c
   GNUnet/src/include/gnunet_protocols.h
Log:
fixing alignment issue in on-demand code for 64 bit archs

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2007-12-21 19:38:14 UTC 
(rev 6005)
+++ GNUnet/src/applications/datastore/datastore.c       2007-12-21 22:28:12 UTC 
(rev 6006)
@@ -292,9 +292,12 @@
   cls.exists = GNUNET_NO;
   cls.value = value;
   sq->get (key, ntohl (value->type), &checkExists, &cls);
-  if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_DATA)
+  if ( (! cls.exists) &&
+       (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_DATA) )
     sq->get (key, GNUNET_ECRS_BLOCKTYPE_ONDEMAND, &checkExists, &cls);
-
+  if ( (! cls.exists) &&
+       (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_DATA) )
+    sq->get (key, GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD, &checkExists, &cls);
   if (cls.exists)
     {
       if ((ntohl (value->prio) == 0) &&

Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c      2007-12-21 19:38:14 UTC (rev 
6005)
+++ GNUnet/src/applications/fs/ecrs_core.c      2007-12-21 22:28:12 UTC (rev 
6006)
@@ -256,6 +256,7 @@
         return GNUNET_OK;
       }
     case GNUNET_ECRS_BLOCKTYPE_ONDEMAND:
+    case GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD:
       {
         GNUNET_GE_BREAK (NULL, 0);      /* should never be used here! */
         return GNUNET_SYSERR;

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2007-12-21 19:38:14 UTC (rev 
6005)
+++ GNUnet/src/applications/fs/module/fs.c      2007-12-21 22:28:12 UTC (rev 
6006)
@@ -803,7 +803,8 @@
   GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
                  "Converting reply for query `%s' for gap.\n", &enc);
 #endif
-  if (ntohl (invalue->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND)
+  if ( (ntohl (invalue->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND) ||
+       (ntohl (invalue->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD) )
     {
       if (GNUNET_OK != ONDEMAND_getIndexed (datastore, invalue, key, &xvalue))
         return GNUNET_SYSERR;
@@ -947,6 +948,11 @@
     ret = datastore->get (&keys[0],
                           GNUNET_ECRS_BLOCKTYPE_ONDEMAND,
                           &gapGetConverter, &myClosure);
+  if ( (myClosure.count == 0) &&
+       (type == GNUNET_ECRS_BLOCKTYPE_DATA) )
+    ret = datastore->get (&keys[0],
+                          GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD,
+                          &gapGetConverter, &myClosure);
   if (myClosure.count == 0)
     ret = datastore->get (&keys[0], type, &gapGetConverter, &myClosure);
   if (ret != GNUNET_SYSERR)

Modified: GNUnet/src/applications/fs/module/migration.c
===================================================================
--- GNUnet/src/applications/fs/module/migration.c       2007-12-21 19:38:14 UTC 
(rev 6005)
+++ GNUnet/src/applications/fs/module/migration.c       2007-12-21 22:28:12 UTC 
(rev 6006)
@@ -266,7 +266,8 @@
                  "Migration: random lookup in datastore returned type %d.\n",
                  ntohl (value->type));
 #endif
-  if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND)
+  if ( (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND) ||
+       (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD) )
     {
       if (ONDEMAND_getIndexed (datastore,
                                value, &content[entry].key, &enc) != GNUNET_OK)

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2007-12-21 19:38:14 UTC 
(rev 6005)
+++ GNUnet/src/applications/fs/module/ondemand.c        2007-12-21 22:28:12 UTC 
(rev 6006)
@@ -38,21 +38,63 @@
 #define TRACKFILE "indexed_requests.txt"
 
 /**
+ * Use GNUnet 0.7.2 compatibility mode?
+ */
+#define MIG72 GNUNET_YES
+
+/**
  * Format of an on-demand block.
  */
 typedef struct
 {
+  /**
+   * 
+   */ 
   GNUNET_DatastoreValue header;
 
   unsigned int type;
 
   /**
+   * Size of the on-demand encoded part of the file
+   * that this Block represents.
+   */
+  unsigned int blockSize;
+
+  /**
    * At what offset in the plaintext file is
    * this content stored?
    */
   unsigned long long fileOffset;
 
   /**
+   * What is the GNUNET_hash of the file that contains
+   * this block?  Used to determine the name
+   * of the file in the on-demand datastore.
+   */
+  GNUNET_HashCode fileId;
+
+} OnDemandBlock;
+
+#if MIG72
+/**
+ * Format of an OLD on-demand block.
+ */
+typedef struct
+{
+  /**
+   * 
+   */ 
+  GNUNET_DatastoreValue header;
+
+  unsigned int type;
+
+  /**
+   * At what offset in the plaintext file is
+   * this content stored?
+   */
+  unsigned long long fileOffset;
+
+  /**
    * Size of the on-demand encoded part of the file
    * that this Block represents.
    */
@@ -65,7 +107,8 @@
    */
   GNUNET_HashCode fileId;
 
-} OnDemandBlock;
+} OnDemandBlock72;
+#endif
 
 static char *index_directory;
 
@@ -324,15 +367,42 @@
   int blen;
   int fileHandle;
   int ret;
-  OnDemandBlock *odb;
+  const OnDemandBlock *odb;
   DBlock *db;
 
+#if MIG72
+  const OnDemandBlock72 * odb_old;
+  OnDemandBlock odb_stack;
   if (ntohl (dbv->size) != sizeof (OnDemandBlock))
     {
+      if (ntohl(dbv->size) != sizeof (OnDemandBlock72))
+       {
+         GNUNET_GE_BREAK (ectx, 0);
+         return GNUNET_SYSERR;
+       }
+      else
+       {
+         odb_old = (OnDemandBlock72*) dbv;
+         odb_stack.header = odb_old->header;
+         odb_stack.type = odb_old->type;
+         odb_stack.fileOffset = odb_old->fileOffset;
+         odb_stack.blockSize = odb_old->blockSize;
+         odb_stack.fileId = odb_old->fileId;
+         odb = &odb_stack;
+       }
+    }
+  else
+    {
+      odb = (const OnDemandBlock *) dbv;
+    }  
+#else
+  if (ntohl (dbv->size) != sizeof (OnDemandBlock))
+    {
       GNUNET_GE_BREAK (ectx, 0);
       return GNUNET_SYSERR;
     }
-  odb = (OnDemandBlock *) dbv;
+  odb = (const OnDemandBlock *) dbv;
+#endif  
   fn = getOnDemandFile (&odb->fileId);
   if ((GNUNET_YES != GNUNET_disk_file_test (ectx,
                                             fn)) ||
@@ -527,10 +597,26 @@
 {
   GNUNET_DatastoreValue *comp = closure;
 
+#if MIG72
+  const OnDemandBlock72 * odb1 = (const OnDemandBlock72*) &value[1];
+  const OnDemandBlock72 * odb2 = (const OnDemandBlock72*) &comp[1];
+  if ( (comp->size != value->size) ||
+       ( ( (ntohl(value->size) - sizeof(GNUNET_DatastoreValue) != 
sizeof(OnDemandBlock72)) ||
+          (odb1->type != odb2->type) ||
+          (odb1->fileOffset != odb2->fileOffset) ||
+          (odb1->blockSize != odb2->blockSize) ||
+          (0 != memcmp(&odb1->fileId,
+                       &odb2->fileId,
+                       sizeof(GNUNET_HashCode)) ) ) &&
+        (0 != memcmp (&value[1],
+                      &comp[1],
+                      ntohl (value->size) - sizeof (GNUNET_DatastoreValue)))) 
)    
+#else
   if ((comp->size != value->size) ||
       (0 != memcmp (&value[1],
                     &comp[1],
                     ntohl (value->size) - sizeof (GNUNET_DatastoreValue))))
+#endif
     {
 #if DEBUG_ONDEMAND
       GNUNET_GE_LOG (ectx,
@@ -568,6 +654,9 @@
   int fd;
   int ret;
   OnDemandBlock odb;
+#if MIG72
+  OnDemandBlock72 odb_old;
+#endif
   GNUNET_HashCode key;
   unsigned long long pos;
   unsigned long long size;
@@ -627,7 +716,28 @@
         ret = datastore->del (&key, &odb.header);
       else                      /* not found */
         ret = GNUNET_SYSERR;
+#if MIG72
       if (ret == GNUNET_SYSERR)
+       {
+         memset(&odb_old,
+                0,
+                sizeof(OnDemandBlock72));
+         odb_old.header.size = htonl (sizeof (OnDemandBlock));
+         odb_old.header.type = htonl (GNUNET_ECRS_BLOCKTYPE_ONDEMAND);
+         odb_old.header.prio = 0;
+         odb_old.header.anonymityLevel = 0;
+         odb_old.header.expirationTime = 0;
+         odb_old.type = htonl (GNUNET_ECRS_BLOCKTYPE_ONDEMAND);
+         odb_old.fileOffset = GNUNET_htonll (pos);
+         odb_old.blockSize = htonl (delta);
+         odb_old.fileId = *fileId;
+         if (GNUNET_SYSERR == datastore->get (&key, 
GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD, &completeValue, &odb_old.header))  /* 
aborted == found! */
+           ret = datastore->del (&key, &odb_old.header);
+         else                      /* not found */
+           ret = GNUNET_SYSERR;
+       }
+#endif
+      if (ret == GNUNET_SYSERR)
         {
           IF_GELOG (cectx,
                     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,

Modified: GNUnet/src/applications/stats/sqstats.c
===================================================================
--- GNUnet/src/applications/stats/sqstats.c     2007-12-21 19:38:14 UTC (rev 
6005)
+++ GNUnet/src/applications/stats/sqstats.c     2007-12-21 22:28:12 UTC (rev 
6006)
@@ -79,6 +79,7 @@
       data->stat_block[5]++;
       break;
     case GNUNET_ECRS_BLOCKTYPE_ONDEMAND:
+    case GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD:
       data->stat_block[6]++;
       break;
     default:

Modified: GNUnet/src/include/gnunet_protocols.h
===================================================================
--- GNUnet/src/include/gnunet_protocols.h       2007-12-21 19:38:14 UTC (rev 
6005)
+++ GNUnet/src/include/gnunet_protocols.h       2007-12-21 22:28:12 UTC (rev 
6006)
@@ -465,6 +465,11 @@
 #define GNUNET_ECRS_BLOCKTYPE_KEYWORD_FOR_NAMESPACE 5
 
 /**
+ * Type of OnDemand encoded blocks.
+ */
+#define GNUNET_ECRS_BLOCKTYPE_ONDEMAND 6
+
+/**
  * DHT String2String (for dht-testing)
  */
 #define GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING 7
@@ -475,9 +480,9 @@
 #define GNUNET_ECRS_BLOCKTYPE_RESERVED 0xFFFFFFFE
 
 /**
- * Type of OnDemand encoded blocks.
+ * Type of OLD OnDemand encoded blocks.
  */
-#define GNUNET_ECRS_BLOCKTYPE_ONDEMAND 0xFFFFFFFF
+#define GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD 0xFFFFFFFF
 
 
 





reply via email to

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