gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3419 - in GNUnet: . src/applications/fs/ecrs src/applicati


From: grothoff
Subject: [GNUnet-SVN] r3419 - in GNUnet: . src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/uritrack src/util/disk src/util/os
Date: Thu, 28 Sep 2006 22:23:34 -0700 (PDT)

Author: grothoff
Date: 2006-09-28 22:23:26 -0700 (Thu, 28 Sep 2006)
New Revision: 3419

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/ecrs/search.c
   GNUnet/src/applications/fs/ecrs/upload.c
   GNUnet/src/applications/fs/fsui/download.c
   GNUnet/src/applications/fs/fsui/downloadtest.c
   GNUnet/src/applications/fs/fsui/fsui.c
   GNUnet/src/applications/fs/fsui/search.c
   GNUnet/src/applications/fs/fsui/searchtest.c
   GNUnet/src/applications/fs/fsui/upload.c
   GNUnet/src/applications/fs/uritrack/file_info.c
   GNUnet/src/util/disk/storage.c
   GNUnet/src/util/os/semaphore.c
   GNUnet/todo
Log:
fixes

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2006-09-27 19:51:34 UTC (rev 
3418)
+++ GNUnet/src/applications/fs/ecrs/download.c  2006-09-29 05:23:26 UTC (rev 
3419)
@@ -1006,6 +1006,8 @@
       requestManagerEndgame(node->ctx->rm);
     }
   }
+  GE_ASSERT(node->ctx->rm->ectx, 
+           node->ctx->rm->requestThread != NULL);
   PTHREAD_STOP_SLEEP(node->ctx->rm->requestThread);
   FREE(data);
   FREE(node);

Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c    2006-09-27 19:51:34 UTC (rev 
3418)
+++ GNUnet/src/applications/fs/ecrs/search.c    2006-09-29 05:23:26 UTC (rev 
3419)
@@ -31,7 +31,7 @@
 #include "ecrs_core.h"
 #include "ecrs.h"
 
-#define DEBUG_SEARCH YES
+#define DEBUG_SEARCH NO
 
 typedef struct {
 

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2006-09-27 19:51:34 UTC (rev 
3418)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2006-09-29 05:23:26 UTC (rev 
3419)
@@ -152,6 +152,7 @@
   EncName enc;
 #endif
 
+  GE_ASSERT(ectx, cfg != NULL);
   start = get_time();
   memset(&chk, 0, sizeof(CHK));
   if (YES != disk_file_test(ectx,

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2006-09-27 19:51:34 UTC (rev 
3418)
+++ GNUnet/src/applications/fs/fsui/download.c  2006-09-29 05:23:26 UTC (rev 
3419)
@@ -34,7 +34,7 @@
 #include "gnunet_fsui_lib.h"
 #include "fsui.h"
 
-#define DEBUG_DTM NO
+#define DEBUG_DTM YES
 
 /**
  * Start to download a file.
@@ -368,6 +368,7 @@
   unsigned long long totalBytes;
 
   GE_ASSERT(NULL, ctx != NULL);
+  GE_ASSERT(NULL, parent != NULL);
   if (! (ECRS_isFileUri(uri) ||
         ECRS_isLocationUri(uri)) ) {
     GE_BREAK(NULL, 0); /* wrong type of URI! */
@@ -386,8 +387,8 @@
   dl->uri = ECRS_dupUri(uri);
   dl->total = ECRS_fileSize(uri);
   dl->next = parent->child;
+  parent->child = dl;  
   totalBytes = ECRS_fileSize(uri);
-  parent->child = dl;
 
   root = dl;
   while ( (root->parent != NULL) &&
@@ -419,7 +420,7 @@
                      doRecursive,
                      uri,
                      filename,
-                     NULL);
+                     &ctx->activeDownloads);
   MUTEX_UNLOCK(ctx->lock);
   return ret;
 }
@@ -489,6 +490,7 @@
           list->ctx->threadPoolSize);
 #endif
     list->state = FSUI_DOWNLOAD_SUSPENDING;
+    GE_ASSERT(ectx, list->handle != NULL);
     PTHREAD_STOP_SLEEP(list->handle);
     PTHREAD_JOIN(list->handle,
                 &unused);
@@ -537,17 +539,16 @@
   /* first, find our predecessor and
      unlink us from the tree! */
   dpos = list->parent;
-  if (dpos != NULL) {
-    if (dpos->child == list) {
-      dpos->child = list->next;
-    } else {
-      dpos = dpos->child;
-      while ( (dpos != NULL) &&
-             (dpos->next != list) )
-       dpos = dpos->next;
-      GE_ASSERT(NULL, dpos != NULL);
-      dpos->next = list->next;
-    }
+  GE_ASSERT(NULL, dpos != NULL);
+  if (dpos->child == list) {
+    dpos->child = list->next;
+  } else {
+    dpos = dpos->child;
+    while ( (dpos != NULL) &&
+           (dpos->next != list) )
+      dpos = dpos->next;
+    GE_ASSERT(NULL, dpos != NULL);
+    dpos->next = list->next;    
   }
 
   /* then, free all of our children */
@@ -577,6 +578,10 @@
   unsigned int backup;
 
   ectx = ctx->ectx;
+  if (dl == NULL) {
+    GE_BREAK(ectx, 0);
+    return SYSERR;
+  }
   GE_LOG(ectx,
         GE_DEBUG | GE_REQUEST | GE_USER,
         "FSUI_stopDownload called.\n");
@@ -593,14 +598,6 @@
           "FSUI_stopDownload failed to locate download.\n");
     return SYSERR;
   }
-  if (prev == dl) { /* first */
-    if (dl->parent != NULL)
-      dl->parent->child = dl->next;
-    else
-      ctx->activeDownloads.child = dl->next;
-  } else { 
-    prev->next = dl->next; /* unlink */    
-  }
   backup = ctx->threadPoolSize;
   ctx->threadPoolSize = 0;
   updateDownloadThread(dl);

Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c      2006-09-27 19:51:34 UTC 
(rev 3418)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c      2006-09-29 05:23:26 UTC 
(rev 3419)
@@ -73,7 +73,33 @@
 
   switch(event->type) {
   case FSUI_search_result:
+#if DEBUG_VERBOSE
     printf("Received search result\n");
+#endif
+    if (download == NULL) {
+      char * u;
+      
+      if (! ECRS_equalsUri(upURI,
+                          event->data.SearchResult.fi.uri)) {
+       printf("Received search result for different file (download not 
started).\n");
+       return NULL; /* ignore */
+      }
+      fn = makeName(43);
+      u = ECRS_uriToString(event->data.SearchResult.fi.uri);
+      printf("Download started: %s.\n", u);
+      FREE(u);
+      download = FSUI_startDownload(ctx,
+                                   0,
+                                   NO,
+                                   event->data.SearchResult.fi.uri,
+                                   fn);
+      if (download == NULL) {
+       GE_BREAK(ectx, 0);
+       return NULL;
+      }
+      FREE(fn);
+      suspendRestart = 4;
+    }
     break;
   case FSUI_upload_progress:
 #if DEBUG_VERBOSE
@@ -123,6 +149,14 @@
   case FSUI_gnunetd_connected:
   case FSUI_gnunetd_disconnected:
     break;
+  case FSUI_unindex_suspending:
+  case FSUI_upload_suspending:
+  case FSUI_download_suspending:
+  case FSUI_search_suspending:
+    fprintf(stderr,
+           "Received SUSPENDING: %d\n",
+           event->type);
+    break;
   default:
     printf("Unexpected event: %d\n",
           event->type);
@@ -131,28 +165,6 @@
   if (lastEvent == waitForEvent)
     return NULL; /* ignore all other events */
   lastEvent = event->type;
-  if (event->type == FSUI_search_result) {
-    char * u;
-
-    if (! ECRS_equalsUri(upURI,
-                        event->data.SearchResult.fi.uri))
-      return NULL; /* ignore */
-    fn = makeName(43);
-    u = ECRS_uriToString(event->data.SearchResult.fi.uri);
-    printf("Download started: %s.\n", u);
-    FREE(u);
-    download = FSUI_startDownload(ctx,
-                                 0,
-                                 NO,
-                                 event->data.SearchResult.fi.uri,
-                                 fn);
-    if (download == NULL) {
-      GE_BREAK(ectx, 0);
-      return NULL;
-    }
-    FREE(fn);
-    suspendRestart = 4;
-  }
   return NULL;
 }
 
@@ -300,8 +312,9 @@
     FSUI_stopSearch(ctx,
                    search);
     fn = makeName(43);
-    FSUI_stopDownload(ctx,
-                     download);
+    if (download != NULL)
+      FSUI_stopDownload(ctx,
+                       download);
     FREE(fn);
     FSUI_stop(ctx);
   }

Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c      2006-09-27 19:51:34 UTC (rev 
3418)
+++ GNUnet/src/applications/fs/fsui/fsui.c      2006-09-29 05:23:26 UTC (rev 
3419)
@@ -29,7 +29,7 @@
 #include "gnunet_directories.h"
 #include "fsui.h"
 
-#define DEBUG_PERSISTENCE NO
+#define DEBUG_PERSISTENCE YES
 
 #define FSUI_UDT_FREQUENCY (2 * cronSECONDS)
 
@@ -92,7 +92,7 @@
     GE_BREAK(ectx, 0);
     return NULL;
   }
-  if (zaro == '\0')
+  if (zaro == '\0') 
     return NULL;
   ret = MALLOC(sizeof(FSUI_DownloadList));
   memset(ret,
@@ -174,9 +174,8 @@
 #if DEBUG_PERSISTENCE
   GE_LOG(ectx, 
         GE_DEBUG | GE_REQUEST | GE_USER,
-        "FSUI persistence: restoring download `%s': %s (%llu, %llu)\n",
+        "FSUI persistence: restoring download `%s': (%llu, %llu)\n",
         ret->filename,
-        ret->finished == YES ? "finished" : "pending",
         ret->completed,
         ret->total);
 #endif
@@ -189,10 +188,10 @@
     if (ret->completedDownloads[i] != NULL)
       ECRS_freeUri(ret->completedDownloads[i]);
   }
-
   FREE(ret);
-  GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-      _("FSUI persistence: error restoring download\n"));
+  GE_LOG(ectx,
+        GE_WARNING | GE_BULK | GE_USER,
+        _("FSUI persistence: error restoring download\n"));
   return NULL;
 }
 
@@ -241,9 +240,8 @@
 #if DEBUG_PERSISTENCE
   GE_LOG(ectx,
         GE_DEBUG | GE_REQUEST | GE_USER,
-        "Serializing download state of download `%s': %s (%llu, %llu)\n",
+        "Serializing download state of download `%s': (%llu, %llu)\n",
         list->filename,
-        list->finished == YES ? "finished" : "pending",
         list->completed,
         list->total);
 #endif
@@ -356,8 +354,9 @@
   dpos = ctx->activeDownloads.child;
 #if DEBUG_PERSISTENCE
   if (dpos != NULL)
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-       "Download thread manager schedules pending downloads...\n");
+    GE_LOG(ctx->ectx, 
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          "Download thread manager schedules pending downloads...\n");
 #endif
   while (dpos != NULL) {
     updateDownloadThread(dpos);
@@ -389,18 +388,21 @@
   int fd;
   int i;
 
+  GE_ASSERT(ectx, cfg != NULL);
   ret = MALLOC(sizeof(FSUI_Context));
   memset(ret, 0, sizeof(FSUI_Context));
   ret->activeDownloads.state
     = FSUI_DOWNLOAD_PENDING; /* !? */
   ret->activeDownloads.ctx
     = ret;
+  ret->cfg
+    = cfg;
 
-  GC_get_configuration_value_string(cfg,
-                                   "GNUNET",
-                                   "GNUNET_HOME",
-                                   GNUNET_HOME_DIRECTORY,
-                                   &gh);
+  GC_get_configuration_value_filename(cfg,
+                                     "GNUNET",
+                                     "GNUNET_HOME",
+                                     GNUNET_HOME_DIRECTORY,
+                                     &gh);
   fn = MALLOC(strlen(gh) + strlen(name) + 2 + 5);
   strcpy(fn, gh);
   FREE(gh);
@@ -411,13 +413,17 @@
     ret->ipc = IPC_SEMAPHORE_CREATE(ectx,
                                    fn,
                                    1);
+#if DEBUG_PERSISTENCE
     GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER,
        "Getting IPC lock for FSUI (%s).\n",
        fn);
+#endif
     IPC_SEMAPHORE_DOWN(ret->ipc, YES);
+#if DEBUG_PERSISTENCE
     GE_LOG(ectx, 
           GE_INFO | GE_REQUEST | GE_USER,
           "Aquired IPC lock.\n");
+#endif
     fd = -1;
     strcat(fn, ".res");
     if (0 == ACCESS(fn, R_OK))
@@ -610,8 +616,9 @@
          = ret;
        /* start search thread! */
 #if DEBUG_PERSISTENCE
-       GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-           "FSUI persistence: restarting search\n");
+       GE_LOG(ectx, 
+              GE_DEBUG | GE_REQUEST | GE_USER,
+              "FSUI persistence: restarting search\n");
 #endif
        list->handle = PTHREAD_CREATE(&searchThread,
                                      list,
@@ -663,8 +670,8 @@
     WARN:
       GE_LOG(ectx, 
             GE_WARNING | GE_BULK | GE_USER,
-         _("FSUI state file `%s' had syntax error at offset %u.\n"),
-         fn,
+            _("FSUI state file `%s' had syntax error at offset %u.\n"),
+            fn,
          lseek(fd, 0, SEEK_CUR));
     END:
       CLOSE(fd);

Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c    2006-09-27 19:51:34 UTC (rev 
3418)
+++ GNUnet/src/applications/fs/fsui/search.c    2006-09-29 05:23:26 UTC (rev 
3419)
@@ -317,6 +317,7 @@
   pos->next = NULL;
   pos->signalTerminate = YES;
   /* send signal to terminate sleep! */
+  GE_ASSERT(ctx->ectx, pos->handle != NULL);
   PTHREAD_STOP_SLEEP(pos->handle);
   PTHREAD_JOIN(pos->handle,
               &unused);

Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c        2006-09-27 19:51:34 UTC 
(rev 3418)
+++ GNUnet/src/applications/fs/fsui/searchtest.c        2006-09-29 05:23:26 UTC 
(rev 3419)
@@ -68,6 +68,13 @@
     return &unused;
   case FSUI_search_result:
     printf("Received search result\n");
+    fn = makeName(43);
+    FSUI_startDownload(ctx,
+                      0,
+                      NO,
+                      event->data.SearchResult.fi.uri,
+                      fn);
+    FREE(fn);
     break;
   case FSUI_upload_complete:
     printf("Upload complete.\n");
@@ -84,15 +91,6 @@
   if (lastEvent == FSUI_download_complete)
     return NULL; /* ignore all other events */
   lastEvent = event->type;
-  if (event->type == FSUI_search_result) {
-    fn = makeName(43);
-    FSUI_startDownload(ctx,
-                      0,
-                      NO,
-                      event->data.SearchResult.fi.uri,
-                      fn);
-    FREE(fn);
-  }
   return NULL;
 }
 

Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c    2006-09-27 19:51:34 UTC (rev 
3418)
+++ GNUnet/src/applications/fs/fsui/upload.c    2006-09-29 05:23:26 UTC (rev 
3419)
@@ -524,7 +524,7 @@
   char * config;
   struct GE_Context * ectx;
 
-  ectx = utc->ctx->ectx;
+  ectx = ctx->ectx;
   utc = MALLOC(sizeof(FSUI_UploadList));
   utc->dir = NULL;
   utc->anonymityLevel = anonymityLevel;

Modified: GNUnet/src/applications/fs/uritrack/file_info.c
===================================================================
--- GNUnet/src/applications/fs/uritrack/file_info.c     2006-09-27 19:51:34 UTC 
(rev 3418)
+++ GNUnet/src/applications/fs/uritrack/file_info.c     2006-09-29 05:23:26 UTC 
(rev 3419)
@@ -111,6 +111,11 @@
 
   tn = getToggleName(ectx,
                     cfg);
+  if (YES != disk_file_test(ectx,
+                           tn)) {
+    FREE(tn);
+    return NO; /* default: off */
+  }
   if ( (sizeof(int) != disk_file_read(ectx,
                                      tn,
                                      sizeof(int),

Modified: GNUnet/src/util/disk/storage.c
===================================================================
--- GNUnet/src/util/disk/storage.c      2006-09-27 19:51:34 UTC (rev 3418)
+++ GNUnet/src/util/disk/storage.c      2006-09-29 05:23:26 UTC (rev 3419)
@@ -241,13 +241,8 @@
     }
     return NO;
   }
-  if (!S_ISDIR(filestat.st_mode)) {
-    GE_LOG(ectx,
-          GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST, 
-          _("Expected `%s' to be a directory\n"),
-          fil);
-    return SYSERR;
-  }
+  if (! S_ISDIR(filestat.st_mode)) 
+    return NO;
   if (ACCESS(fil, R_OK | X_OK) < 0 ) {
     GE_LOG_STRERROR_FILE(ectx,
                         GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST, 
@@ -280,13 +275,8 @@
     }
     return NO;
   }
-  if (! S_ISREG(filestat.st_mode)) {
-    GE_LOG(ectx,
-          GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST, 
-          _("Expected `%s' to be a regular file\n"),
-          fil);
-    return SYSERR;
-  }
+  if (! S_ISREG(filestat.st_mode)) 
+    return NO;
   if (ACCESS(fil, R_OK) < 0 ) {
     GE_LOG_STRERROR_FILE(ectx,
                         GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST, 

Modified: GNUnet/src/util/os/semaphore.c
===================================================================
--- GNUnet/src/util/os/semaphore.c      2006-09-27 19:51:34 UTC (rev 3418)
+++ GNUnet/src/util/os/semaphore.c      2006-09-29 05:23:26 UTC (rev 3419)
@@ -156,7 +156,7 @@
 
   ret = MALLOC(sizeof(struct IPC_SEMAPHORE));
   ret->ectx = ectx;
-  noslashBasename = STRDUP(basename);
+  noslashBasename = string_expandFileName(ectx, basename);
   for (i=strlen(noslashBasename);i>0;i--)
     if (noslashBasename[i] == '/')
       noslashBasename[i] = '.'; /* first character MUST be /, but Solaris
@@ -192,7 +192,7 @@
 
   ret = MALLOC(sizeof(struct IPC_SEMAPHORE));
   ret->ectx = ectx;
-  noslashBasename = STRDUP(basename);
+  noslashBasename = string_expandFileName(ectx, basename);
   for (i=strlen(noslashBasename);i>0;i--)
     if (noslashBasename[i] == '\\')
       noslashBasename[i] = '.'; /* must not contain backslashes */
@@ -228,21 +228,24 @@
   key_t key;
   FILE * fp;
   int pcount;
+  char * ebasename;
 
   ret = MALLOC(sizeof(struct IPC_SEMAPHORE));
   ret->ectx = ectx;
-  fp = FOPEN(basename, "a+");
+  ebasename = string_expandFileName(ectx, basename);
+  fp = FOPEN(ebasename, "a+");
   if (NULL == fp) {
     GE_LOG_STRERROR_FILE(ectx,
                         GE_ERROR | GE_USER | GE_BULK,
                         "fopen",
-                        basename);
+                        ebasename);
     FREE(ret);
+    FREE(ebasename);
     return NULL;
   }
   fclose(fp);
 
-  key = ftok(basename,'g');
+  key = ftok(ebasename,'g');
 
 again:
   ret->internal = semget(key,
@@ -295,7 +298,7 @@
     GE_DIE_STRERROR(ectx, 
                    GE_FATAL | GE_USER | GE_IMMEDIATE, 
                    "semop");
-  ret->filename = STRDUP(basename);
+  ret->filename = ebasename;
   return ret;
 #elif SOMEBSD
   int fd;

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-09-27 19:51:34 UTC (rev 3418)
+++ GNUnet/todo 2006-09-29 05:23:26 UTC (rev 3419)
@@ -18,7 +18,7 @@
     + loggers: SMTP logger
     + use new loggers in for CS error reporting
   * make testcases compile & pass again:
-    + fs/fsui -- compiles; did not try to run yet      
+    + fs/fsui -- compiles; did not try to run yet
     + dht/tools, dht/module
   * transports:
     + SMTP/HTTP: do not yet compile (commented out from build)





reply via email to

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