gnunet-svn
[Top][All Lists]
Advanced

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

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


From: grothoff
Subject: [GNUnet-SVN] r3517 - in GNUnet/src/applications/fs: ecrs fsui
Date: Fri, 20 Oct 2006 20:30:13 -0700 (PDT)

Author: grothoff
Date: 2006-10-20 20:30:07 -0700 (Fri, 20 Oct 2006)
New Revision: 3517

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/ecrs/unindex.c
   GNUnet/src/applications/fs/fsui/deserialize.c
   GNUnet/src/applications/fs/fsui/download.c
   GNUnet/src/applications/fs/fsui/downloadtest.c
   GNUnet/src/applications/fs/fsui/serialize.c
Log:
fixes

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2006-10-20 23:52:31 UTC (rev 
3516)
+++ GNUnet/src/applications/fs/ecrs/download.c  2006-10-21 03:30:07 UTC (rev 
3517)
@@ -1311,6 +1311,8 @@
   top->level = computeDepth(ctx.total);
   if (NO == checkPresent(top))
     addRequest(rm, top);
+  else
+    FREE(top);  
   while ( (OK == tt(ttClosure)) &&
          (rm->abortFlag == NO) &&
          (rm->requestListIndex != 0) ) {
@@ -1327,13 +1329,14 @@
     ret = OK;
   } else {
 #if 0
-    GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
-       "Download ends prematurely: %d %llu == %llu %d TT: %d\n",
-       rm->requestListIndex,
-       ctx.completed,
-       ctx.total,
-       rm->abortFlag,
-       tt(ttClosure));
+    GE_LOG(ectx, 
+          GE_ERROR | GE_BULK | GE_USER,
+          "Download ends prematurely: %d %llu == %llu %d TT: %d\n",
+          rm->requestListIndex,
+          ctx.completed,
+          ctx.total,
+          rm->abortFlag,
+          tt(ttClosure));
 #endif
     ret = SYSERR;
   }
@@ -1343,11 +1346,12 @@
   else
     freeIOC(&ioc, NO); /* aborted */
 #if DEBUG_DOWNLOAD
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "`%s' terminating for file `%s' with result %s\n",
-      __FUNCTION__,
-      filename,
-      ret == OK ? "SUCCESS" : "INCOMPLETE");
+  GE_LOG(ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "`%s' terminating for file `%s' with result %s\n",
+        __FUNCTION__,
+        filename,
+        ret == OK ? "SUCCESS" : "INCOMPLETE");
 #endif
   return ret;
 }

Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c   2006-10-20 23:52:31 UTC (rev 
3516)
+++ GNUnet/src/applications/fs/ecrs/unindex.c   2006-10-21 03:30:07 UTC (rev 
3517)
@@ -335,8 +335,8 @@
                    * (double)filesize);
   }
   if (tt != NULL)
-    if (OK != tt(ttClosure))
-      goto FAILURE;
+    if (OK != tt(ttClosure)) 
+      goto FAILURE;    
   for (i=0;i<treedepth;i++) {
     size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
     db = (DBlock*) &iblocks[i][1];
@@ -397,7 +397,7 @@
   connection_destroy(sock);
   return OK;
  FAILURE:
-  for (i=0;i<treedepth;i++)
+  for (i=0;i<=treedepth;i++)
     FREENONNULL(iblocks[i]);
   FREE(iblocks);
   FREE(dblock);

Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c       2006-10-20 23:52:31 UTC 
(rev 3516)
+++ GNUnet/src/applications/fs/fsui/deserialize.c       2006-10-21 03:30:07 UTC 
(rev 3517)
@@ -354,6 +354,7 @@
       GE_BREAK(NULL, 0);       
       break;
     }
+    printf("Reading URI: %s\n", buf);
     list->uri
       = ECRS_stringToUri(NULL, buf);
     FREE(buf);
@@ -435,27 +436,31 @@
   } /* end OUTER: 'while(1)' */
  ERR:
   /* error - deallocate 'list' */
-  for (i=0;i<list->sizeResultsReceived;i++) {
-    if (list->resultsReceived[i].uri != NULL)
-      ECRS_freeUri(list->resultsReceived[i].uri);
-    if (list->resultsReceived[i].meta != NULL)
-      ECRS_freeMetaData(list->resultsReceived[i].meta);        
+  if (list->resultsReceived != NULL) {
+    for (i=0;i<list->sizeResultsReceived;i++) {
+      if (list->resultsReceived[i].uri != NULL)
+       ECRS_freeUri(list->resultsReceived[i].uri);
+      if (list->resultsReceived[i].meta != NULL)
+       ECRS_freeMetaData(list->resultsReceived[i].meta);       
+    }
+    GROW(list->resultsReceived,
+        list->sizeResultsReceived,
+        0);
   }
-  GROW(list->resultsReceived,
-       list->sizeResultsReceived,
-       0);
-  for (i=0;i<list->sizeUnmatchedResultsReceived;i++) {
-    rp = &list->unmatchedResultsReceived[i];
-    
-    if (rp->fi.uri != NULL)
-      ECRS_freeUri(rp->fi.uri);
-    if (rp->fi.meta != NULL)
-      ECRS_freeMetaData(rp->fi.meta);
-    FREENONNULL(rp->matchingKeys);
+  if (list->unmatchedResultsReceived != NULL) {
+    for (i=0;i<list->sizeUnmatchedResultsReceived;i++) {
+      rp = &list->unmatchedResultsReceived[i];
+      
+      if (rp->fi.uri != NULL)
+       ECRS_freeUri(rp->fi.uri);
+      if (rp->fi.meta != NULL)
+       ECRS_freeMetaData(rp->fi.meta);
+      FREENONNULL(rp->matchingKeys);
+    }
+    GROW(list->resultsReceived,
+        list->sizeResultsReceived,
+        0);  
   }
-  GROW(list->resultsReceived,
-       list->sizeResultsReceived,
-       0);  
   if (list->uri != NULL)
     ECRS_freeUri(list->uri);  
   FREE(list);
@@ -536,6 +541,7 @@
                       struct FSUI_Context * ctx) {
   int big;
   struct FSUI_UploadShared * shared;
+  struct FSUI_UploadShared sshared;
 
   memset(&ctx->activeUploads,
         0,
@@ -544,20 +550,40 @@
     READINT(big);
     if (big == 0) 
       return OK;
-    if (big != 2) {
+    if ( (big != 2) && (big != 3) ) {
       GE_BREAK(NULL, 0);
       break;
     }
-    shared = MALLOC(sizeof(FSUI_UploadShared));
-    memset(shared,
+    memset(&sshared,
           0,
           sizeof(FSUI_UploadShared));   
-    shared->extractor_config = NULL;   
+    READINT(sshared.doIndex);
+    READINT(sshared.anonymityLevel);
+    READINT(sshared.priority);
+    READINT(sshared.individualKeywords);
+    READLONG(sshared.expiration);
+    if (big == 2) 
+      READSTRING(sshared.extractor_config, 1024*1024);
+    shared = MALLOC(sizeof(FSUI_UploadShared));
+    memcpy(shared,
+          &sshared,
+          sizeof(FSUI_UploadShared));
     if (OK != readUploadList(ctx,
                             &ctx->activeUploads,
                             fd,
-                            shared)) 
+                            shared)) {
+#if 0
+      /* cannot do this, readUploadList
+        may have added *some* uploads that
+        still reference shared -- need to
+        find and cleanup those first,
+        or at least detect their presence 
+        and not free */
+      FREE(shared->extractor_config);
+      FREE(shared);
+#endif
       break;
+    }
   }
   return SYSERR;
 }

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2006-10-20 23:52:31 UTC (rev 
3516)
+++ GNUnet/src/applications/fs/fsui/download.c  2006-10-21 03:30:07 UTC (rev 
3517)
@@ -253,7 +253,7 @@
                 &event);      
   } else {
     /* else: suspended */
-    GE_ASSERT(NULL, dl->state == FSUI_PENDING);
+    GE_ASSERT(NULL, dl->state == FSUI_SUSPENDING);
   }
 
 

Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c      2006-10-20 23:52:31 UTC 
(rev 3516)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c      2006-10-21 03:30:07 UTC 
(rev 3517)
@@ -35,7 +35,7 @@
 #include "gnunet_util_network_client.h"
 #include "gnunet_util_crypto.h"
 
-#define DEBUG_VERBOSE NO
+#define DEBUG_VERBOSE YES
 
 #define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
 
@@ -210,7 +210,7 @@
 
 #define FILESIZE (1024 * 1024 * 2)
 
-#define START_DAEMON 1
+#define START_DAEMON 0
 
 int main(int argc, char * argv[]){
 #if START_DAEMON
@@ -295,7 +295,7 @@
   prog = 0;
   while (lastEvent != FSUI_upload_completed) {
     prog++;
-    CHECK(prog < 1000);
+    CHECK(prog < 5000);
     PTHREAD_SLEEP(50 * cronMILLIS);
     if (GNUNET_SHUTDOWN_TEST() == YES)
       break;
@@ -323,7 +323,7 @@
     PTHREAD_SLEEP(50 * cronMILLIS);
     if ( (suspendRestart > 0) &&
         (weak_randomi(4) == 0) ) {
-#if 0
+#if 1
 #if DEBUG_VERBOSE
       printf("Testing FSUI suspend-resume\n");
 #endif
@@ -355,7 +355,7 @@
   prog = 0;
   while (lastEvent != FSUI_unindex_completed) {
     prog++;
-    CHECK(prog < 1000);
+    CHECK(prog < 5000);
     PTHREAD_SLEEP(50 * cronMILLIS);
     CHECK(lastEvent != FSUI_unindex_error);
     if (GNUNET_SHUTDOWN_TEST() == YES)
@@ -364,10 +364,6 @@
   CHECK(lastEvent == FSUI_unindex_completed);
   /* END OF TEST CODE */
  FAILURE:
-  if (fn != NULL) {
-    UNLINK(fn);
-    FREE(fn);
-  }
   if (ctx != NULL) {
     if (unindex != NULL)
       FSUI_stopUnindex(ctx,
@@ -377,6 +373,10 @@
                        download);
     FSUI_stop(ctx);
   }
+  if (fn != NULL) {
+    UNLINK(fn);
+    FREE(fn);
+  }
   if (uri != NULL)
     ECRS_freeUri(uri);
   if (kuri != NULL)

Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2006-10-20 23:52:31 UTC (rev 
3516)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2006-10-21 03:30:07 UTC (rev 
3517)
@@ -61,6 +61,7 @@
 
 static void WRITESTRING(int fd,
                        const char * name) {
+  GE_BREAK(NULL, name != NULL);
   WRITEINT(fd,
           strlen(name));
   WRITE(fd,
@@ -177,6 +178,7 @@
     WRITEINT(fd, spos->sizeUnmatchedResultsReceived);
     tmp = ECRS_uriToString(spos->uri);
     GE_ASSERT(NULL, tmp != NULL);
+    printf("Writing URI: %s\n", tmp);
     WRITESTRING(fd, tmp);
     FREE(tmp);
     for (i=0;i<spos->sizeResultsReceived;i++)
@@ -230,13 +232,17 @@
   while (upos != NULL) {
     if (upos->parent == &ctx->activeUploads) {
       shared = upos->shared;
-      WRITEINT(fd, 2);
-      WRITESTRING(fd, shared->extractor_config);
+      if (shared->extractor_config != NULL)
+       WRITEINT(fd, 2);
+      else
+       WRITEINT(fd, 3);
       WRITEINT(fd, shared->doIndex);
       WRITEINT(fd, shared->anonymityLevel);
       WRITEINT(fd, shared->priority);
       WRITEINT(fd, shared->individualKeywords);        
       WRITELONG(fd, shared->expiration);
+      if (shared->extractor_config != NULL)
+       WRITESTRING(fd, shared->extractor_config);
     } else {
       WRITEINT(fd, 1);
       WRITEINT(fd, 1);





reply via email to

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