gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r308 - in GNUnet/src: applications/fs/ecrs applications/fs/


From: grothoff
Subject: [GNUnet-SVN] r308 - in GNUnet/src: applications/fs/ecrs applications/fs/lib applications/sqstore_mysql include
Date: Fri, 25 Feb 2005 03:27:02 -0800 (PST)

Author: grothoff
Date: 2005-02-25 03:26:59 -0800 (Fri, 25 Feb 2005)
New Revision: 308

Modified:
   GNUnet/src/applications/fs/ecrs/search.c
   GNUnet/src/applications/fs/ecrs/unindex.c
   GNUnet/src/applications/fs/ecrs/upload.c
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/applications/sqstore_mysql/mysql.c
   GNUnet/src/include/gnunet_sqstore_service.h
Log:
fixes

Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c    2005-02-25 10:33:56 UTC (rev 
307)
+++ GNUnet/src/applications/fs/ecrs/search.c    2005-02-25 11:26:59 UTC (rev 
308)
@@ -110,6 +110,8 @@
   
   void * spcbClosure;
 
+  int aborted;
+
   Mutex lock;
 
 } SendQueriesContext;
@@ -287,7 +289,12 @@
   uri.type = sks;
   uri.data.sks.namespace = nb->namespace;
   uri.data.sks.identifier = nb->rootEntry;
-  ret = sqc->spcb(&fi, key, sqc->spcbClosure);
+  if (sqc->spcb != NULL) {
+    ret = sqc->spcb(&fi, key, sqc->spcbClosure);
+    if (ret == SYSERR)
+      sqc->aborted = YES;
+  } else
+    ret = OK;
   ECRS_freeMetaData(fi.meta);
   return ret;
 }
@@ -360,12 +367,14 @@
          ECRS_freeMetaData(fi.meta);
          return SYSERR;
        }
-       printf("ECRS Search Result...\n");
-       ret = sqc->spcb(&fi, 
-                       &ps->decryptKey,
-                       sqc->spcbClosure);
-       printf("ECRS Search Result: %d\n",
-              ret);
+       if (sqc->spcb != NULL) {
+         ret = sqc->spcb(&fi, 
+                         &ps->decryptKey,
+                         sqc->spcbClosure);
+         if (ret == SYSERR)
+           sqc->aborted = YES;
+       } else
+         ret = OK;
        ECRS_freeUri(fi.uri);
        ECRS_freeMetaData(fi.meta);
        return ret;      
@@ -434,7 +443,12 @@
          ECRS_freeMetaData(fi.meta);
          return SYSERR;
        }
-       ret = sqc->spcb(&fi, NULL, sqc->spcbClosure);
+       if (sqc->spcb != NULL) {
+         ret = sqc->spcb(&fi, NULL, sqc->spcbClosure);
+         if (ret == SYSERR)
+           sqc->aborted = YES;
+       } else
+         ret = OK;
        ECRS_freeUri(fi.uri);
        ECRS_freeMetaData(fi.meta);
 
@@ -498,12 +512,14 @@
   ctx.queries = NULL;
   ctx.spcb = spcb;
   ctx.spcbClosure = spcbClosure;
+  ctx.aborted = NO;
   MUTEX_CREATE_RECURSIVE(&ctx.lock);
   ctx.sctx = FS_SEARCH_makeContext(&ctx.lock);
   addQueryForURI(uri,
                 &ctx);
   while ( (OK == tt(ttClosure)) &&
-         (timeout > now) ) {
+         (timeout > now) &&
+         (ctx.aborted == NO) ) {
     remTime = timeout - now;
 
     MUTEX_LOCK(&ctx.lock);

Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c   2005-02-25 10:33:56 UTC (rev 
307)
+++ GNUnet/src/applications/fs/ecrs/unindex.c   2005-02-25 11:26:59 UTC (rev 
308)
@@ -40,6 +40,8 @@
 #include "fs.h"
 #include "tree.h"
 
+#define STRICT_CHECKS NO
+
 /**
  * Append the given key and query to the iblock[level].
  * If iblock[level] is already full, compute its chk
@@ -74,17 +76,25 @@
     if (OK != pushBlock(sock, 
                        &ichk,
                        level+1, 
-                       iblocks))
+                       iblocks)) {
+      BREAK();
       return SYSERR;
+    }
     fileBlockEncode(db,
                    size,
                    &ichk.query,
                    &value);
-    if (OK != FS_delete(sock,
-                       value)) {
+#if STRICT_CHECKS
+    if (SYSERR == FS_delete(sock,
+                           value)) {
       FREE(value);
+      BREAK();
       return SYSERR;
     }
+#else
+    FS_delete(sock,
+             value);
+#endif    
     FREE(value);
     size = sizeof(DBlock);
   }
@@ -256,6 +266,7 @@
   if (SYSERR == getFileHash(filename,
                            &fileId)) {
     releaseClientSocket(sock);
+    BREAK();
     return SYSERR;
   }
   cronTime(&now);
@@ -278,11 +289,13 @@
   if (OK != writeToSocket(sock,
                          &rti.header)) {
     releaseClientSocket(sock);
+    BREAK();
     return SYSERR;
   }
   if (OK != readTCPResult(sock,
                          &wasIndexed)) {
     releaseClientSocket(sock);
+    BREAK();
     return SYSERR;
   }
 
@@ -319,7 +332,7 @@
     if (upcb != NULL)
       upcb(filesize, pos, eta, upcbClosure);
     if (tt != NULL)
-      if (OK != tt(ttClosure))
+      if (OK != tt(ttClosure)) 
        goto FAILURE;
     size = DBLOCK_SIZE;
     if (size > filesize - pos) {
@@ -328,6 +341,7 @@
             0, 
             DBLOCK_SIZE);
     }
+    dblock->size = htonl(sizeof(Datastore_Value) + size + sizeof(DBlock));
     if (size != READ(fd, 
                     &db[1], 
                     size)) {
@@ -348,19 +362,27 @@
     if (OK != pushBlock(sock,
                        &chk,
                        0, /* dblocks are on level 0 */
-                       iblocks))
+                       iblocks)) {
+      BREAK();
       goto FAILURE;
+    }
     if (! wasIndexed) {
       fileBlockEncode(db,
                      size,
                      &chk.query,
                      &value);
       *value = *dblock; /* copy options! */
+#if STRICT_CHECKS
       if (OK != FS_delete(sock,
                          value)) {
        FREE(value);
+       BREAK();
        goto FAILURE;
       }
+#else
+      FS_delete(sock,
+               value);
+#endif     
       FREE(value);
     }
     pos += size;
@@ -374,27 +396,35 @@
       goto FAILURE;  
   for (i=0;i<treedepth;i++) {
     size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
-    db = (DBlock*) &iblocks[i];
+    db = (DBlock*) &iblocks[i][1];
     fileBlockGetKey(db,
-                   size + sizeof(DBlock),
+                   size,
                    &chk.key);
     fileBlockGetQuery(db,
-                     size + sizeof(DBlock),
+                     size,
                      &chk.query);   
     if (OK != pushBlock(sock, 
                        &chk,
                        i+1, 
-                       iblocks))
+                       iblocks)) {
+      BREAK();
       goto FAILURE;
+    }
     fileBlockEncode(db,
                    size,
                    &chk.query,
                    &value);
+#if STRICT_CHECKS
     if (OK != FS_delete(sock,
                        value)) {
       FREE(value);
+      BREAK();
       goto FAILURE;
     }
+#else
+    FS_delete(sock,
+             value);
+#endif    
     FREE(value);
     FREE(iblocks[i]);
     iblocks[i] = NULL;
@@ -406,10 +436,14 @@
                             sock)) {
       if (OK != FS_unindex(sock,
                           DBLOCK_SIZE,
-                          &fileId))
+                          &fileId)) {
+       BREAK();
        goto FAILURE;
-    } else
+      }
+    } else {
+      BREAK();
       goto FAILURE;
+    }
   }
 
   /* free resources */

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2005-02-25 10:33:56 UTC (rev 
307)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2005-02-25 11:26:59 UTC (rev 
308)
@@ -316,7 +316,9 @@
     if (size != READ(fd, 
                     &db[1], 
                     size)) {
-      LOG_FILE_STRERROR(LOG_WARNING, "READ", filename);
+      LOG_FILE_STRERROR(LOG_WARNING, 
+                       "READ",
+                       filename);
       goto FAILURE;
     }   
     if (tt != NULL)

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2005-02-25 10:33:56 UTC (rev 
307)
+++ GNUnet/src/applications/fs/lib/fslib.c      2005-02-25 11:26:59 UTC (rev 
308)
@@ -98,11 +98,9 @@
            memcpy(&value[1],
                   &rep[1],
                   size);
-           printf("FSLIB calls callback!\n");
            if (SYSERR == ctx->handles[i]->callback(&query,
                                                    value,
                                                    ctx->handles[i]->closure)) {
-             printf("FSLIB callback returned SYSERR, nulling!\n");
              ctx->handles[i]->callback = NULL;
            }
            FREE(value);
@@ -362,12 +360,15 @@
   if (OK != writeToSocket(sock,
                          &rd->header)) {
     FREE(rd);
+    BREAK();
     return SYSERR; 
   }
   FREE(rd);
   if (OK != readTCPResult(sock,
-                         &ret))
+                         &ret)) {
+    BREAK();
     return SYSERR;
+  }
   return ret;
 }
 

Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c       2005-02-25 10:33:56 UTC 
(rev 307)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c       2005-02-25 11:26:59 UTC 
(rev 308)
@@ -975,7 +975,7 @@
   if(value == NULL) {
     SNPRINTF(scratch, 
             n,
-            "DELETE FROM gn070 WHERE hash='%s'",       
+            "DELETE FROM gn070 WHERE hash='%s' ORDER BY prio ASC LIMIT 1",     
             escapedHash);
   } else {
     /* FIXME: type/prio/anon=%d since the value is a
@@ -986,7 +986,7 @@
             "DELETE FROM gn070 WHERE hash='%s'"
             " AND size=%u AND type=%d AND prio=%d"
             " AND anonLevel=%d AND expire=%lld"
-            " AND value='%s'",
+            " AND value='%s' ORDER BY prio ASC LIMIT 1",
             escapedHash,
             ntohl(value->size),
             ntohl(value->type),

Modified: GNUnet/src/include/gnunet_sqstore_service.h
===================================================================
--- GNUnet/src/include/gnunet_sqstore_service.h 2005-02-25 10:33:56 UTC (rev 
307)
+++ GNUnet/src/include/gnunet_sqstore_service.h 2005-02-25 11:26:59 UTC (rev 
308)
@@ -140,7 +140,7 @@
    *   
    * @param value maybe NULL, then all items under the
    *        given key are deleted
-   * @return the number of items deleted, 0 if
+   * @return the number of items deleted (at most 1!), 0 if
    *        none were found, SYSERR on errors
    */
   int (*del)(const HashCode160 * key, 





reply via email to

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