gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3422 - GNUnet/src/applications/fs/fsui


From: grothoff
Subject: [GNUnet-SVN] r3422 - GNUnet/src/applications/fs/fsui
Date: Sat, 30 Sep 2006 18:34:24 -0700 (PDT)

Author: grothoff
Date: 2006-09-30 18:34:20 -0700 (Sat, 30 Sep 2006)
New Revision: 3422

Modified:
   GNUnet/src/applications/fs/fsui/download.c
   GNUnet/src/applications/fs/fsui/fsui.h
   GNUnet/src/applications/fs/fsui/searchtest.c
   GNUnet/src/applications/fs/fsui/unindex.c
   GNUnet/src/applications/fs/fsui/upload.c
Log:
fx

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2006-10-01 01:14:18 UTC (rev 
3421)
+++ GNUnet/src/applications/fs/fsui/download.c  2006-10-01 01:34:20 UTC (rev 
3422)
@@ -445,7 +445,7 @@
 #if DEBUG_DTM
   GE_LOG(ectx, 
         GE_DEBUG | GE_REQUEST | GE_USER,
-        "Download thread manager investigates pending downlod of file `%s' 
(%u/%u downloads)\n",
+        "Download thread manager investigates pending download of file `%s' 
(%u/%u downloads)\n",
         list->filename,
         list->ctx->activeDownloadThreads,
         list->ctx->threadPoolSize);
@@ -460,7 +460,7 @@
 #if DEBUG_DTM
     GE_LOG(ectx, 
           GE_DEBUG | GE_REQUEST | GE_USER,
-          "Download thread manager starts downlod of file `%s'\n",
+          "Download thread manager starts download of file `%s'\n",
           list->filename);
 #endif
     list->state = FSUI_DOWNLOAD_ACTIVE;

Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h      2006-10-01 01:14:18 UTC (rev 
3421)
+++ GNUnet/src/applications/fs/fsui/fsui.h      2006-10-01 01:34:20 UTC (rev 
3422)
@@ -53,6 +53,7 @@
    * Set to YES by an FSUI thread upon exit.
    */
   int isDone;
+
 } FSUI_ThreadList;
 
 /**
@@ -61,12 +62,6 @@
 typedef struct {
 
   /**
-   * For how many keys (hash of keyword) did we
-   * get this result?
-   */
-  unsigned int matchingKeyCount;
-
-  /**
    * What are these keys?
    */
   HashCode512 * matchingKeys;
@@ -75,6 +70,13 @@
    * What info do we have about this result?
    */
   ECRS_FileInfo fi;
+
+  /**
+   * For how many keys (hash of keyword) did we
+   * get this result?
+   */
+  unsigned int matchingKeyCount;
+
 } ResultPending;
 
 /**
@@ -98,17 +100,24 @@
   struct PTHREAD * handle;
 
   /**
+   * Which URI are we searching?
+   */
+  struct ECRS_URI * uri;
+
+  /**
+   * List of all results found so far.
+   */
+  ECRS_FileInfo * resultsReceived;
+
+  ResultPending * unmatchedResultsReceived;
+
+  /**
    * Set this to YES to signal the search thread that
    * termination is desired.  Then join on handle.
    */
   int signalTerminate;
 
   /**
-   * Which URI are we searching?
-   */
-  struct ECRS_URI * uri;
-
-  /**
    * Desired anonymity level for this search
    */
   unsigned int anonymityLevel;
@@ -125,19 +134,12 @@
   unsigned int sizeResultsReceived;
 
   /**
-   * List of all results found so far.
-   */
-  ECRS_FileInfo * resultsReceived;
-
-  /**
    * Size of the queue of results that matched at least
    * one of the queries in the boolean query, but not
    * yet all of them.
    */
   unsigned int sizeUnmatchedResultsReceived;
 
-  ResultPending * unmatchedResultsReceived;
-
 } FSUI_SearchList;
 
 /**
@@ -201,7 +203,34 @@
  * @brief list of active downloads
  */
 typedef struct FSUI_DownloadList {
+
   /**
+   * How many bytes is this download in total
+   * (including files in directory).
+   */
+  unsigned long long total;
+
+  /**
+   * How many bytes have been retrieved so far?
+   */
+  unsigned long long completed;
+
+  /**
+   * How many bytes have been retrieved so far for this particular file only.
+   */
+  unsigned long long completedFile;
+
+  /**
+   * URI for this download.
+   */
+  struct ECRS_URI * uri;
+
+  /**
+   * Filename for this download.
+   */
+  char * filename;
+
+  /**
    * Next in the linked list of all downloads
    * kept in FSUI context.
    */
@@ -231,54 +260,28 @@
   void * cctx;
 
   /**
-   * State of the download.
-   */
-  FSUI_DownloadState state;
-
-  /**
    * Currently assigned thread (if any).
    */
   struct PTHREAD * handle;
 
   /**
-   * How many bytes is this download in total
-   * (including files in directory).
+   * FIs of completed sub-downloads.
    */
-  unsigned long long total;
+  struct ECRS_URI ** completedDownloads;
 
   /**
-   * How many bytes have been retrieved so far?
+   * When did the download start?  Note that if a download is resumed,
+   * this time is set such that the total time is accurate, not the
+   * absolute start time.
    */
-  unsigned long long completed;
+  cron_t startTime;
 
   /**
-   * How many bytes have been retrieved so far for this particular file only.
-   */
-  unsigned long long completedFile;
-
-  /**
-   * URI for this download.
-   */
-  struct ECRS_URI * uri;
-
-  /**
-   * Filename for this download.
-   */
-  char * filename;
-
-  /**
    * Is this a recursive download? (YES/NO)
    */
   int is_recursive;
 
   /**
-   * When did the download start?  Note that if a download is resumed,
-   * this time is set such that the total time is accurate, not the
-   * absolute start time.
-   */
-  cron_t startTime;
-
-  /**
    * Is this file a directory?  Set to YES either if the first block
    * contains the correct directory MAGIC, or if the mime-type in the
    * meta-data was saying that the file is a directory.  Set to SYSERR
@@ -301,14 +304,14 @@
   unsigned int anonymityLevel;
 
   /**
-   * FIs of completed sub-downloads.
+   * Number of completed sub-downloads.
    */
-  struct ECRS_URI ** completedDownloads;
-
+  unsigned int completedDownloadsCount;
+  
   /**
-   * Number of completed sub-downloads.
+   * State of the download.
    */
-  unsigned int completedDownloadsCount;
+  FSUI_DownloadState state;
 
 } FSUI_DownloadList;
 
@@ -317,6 +320,8 @@
  */
 typedef struct FSUI_UnindexList {
 
+  cron_t start_time;
+
   struct FSUI_UnindexList * next;
 
   struct PTHREAD * handle;
@@ -325,8 +330,6 @@
 
   struct FSUI_Context * ctx;
 
-  cron_t start_time;
-
   int force_termination;
 
 } FSUI_UnindexList;
@@ -344,22 +347,25 @@
  * Context for the upload thread.
  */
 typedef struct FSUI_UploadList {
-  struct FSUI_UploadList * next;
 
-  struct PTHREAD * handle;
+  unsigned long long main_completed;
 
-  void * cctx;
+  unsigned long long main_total;
 
-  int isRecursive;
+  cron_t expiration;
 
-  int doIndex;
+  cron_t start_time;
 
-  unsigned int anonymityLevel;
+  EXTRACTOR_ExtractorList * extractors;
 
-  unsigned int priority;
+  struct FSUI_Context * ctx;
 
-  cron_t expiration;
+  struct FSUI_UploadList * next;
 
+  DirTrack * dir;
+
+  struct PTHREAD * handle;
+
   struct ECRS_MetaData * meta;
 
   struct ECRS_URI * uri;
@@ -370,20 +376,20 @@
 
   char * main_filename;
 
-  unsigned long long main_completed;
+  void * cctx;
 
-  unsigned long long main_total;
+  int isRecursive;
 
-  EXTRACTOR_ExtractorList * extractors;
+  int doIndex;
 
-  struct FSUI_Context * ctx;
+  unsigned int anonymityLevel;
 
-  cron_t start_time;
+  unsigned int priority;
 
-  DirTrack * dir;
-
   int individualKeywords;
 
+  int force_termination;
+
 } FSUI_UploadList;
 
 /**
@@ -445,14 +451,14 @@
    */
   FSUI_UnindexList * unindexOperations;
 
+  FSUI_UploadList * activeUploads;
+
   /**
    * Root of the tree of downloads.  On shutdown,
    * FSUI must abort each of these downloads.
    */
   FSUI_DownloadList activeDownloads;
 
-  FSUI_UploadList * activeUploads;
-
   /**
    * Target size of the thread pool for parallel
    * downloads.

Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c        2006-10-01 01:14:18 UTC 
(rev 3421)
+++ GNUnet/src/applications/fs/fsui/searchtest.c        2006-10-01 01:34:20 UTC 
(rev 3422)
@@ -32,6 +32,9 @@
 
 #define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
 
+static struct FSUI_SearchList * search;
+
+
 static char * makeName(unsigned int i) {
   char * name;
   char * fn;
@@ -68,6 +71,8 @@
     return &unused;
   case FSUI_search_result:
     printf("Received search result\n");
+    FSUI_stopSearch(ctx,
+                   search);
     fn = makeName(43);
     FSUI_startDownload(ctx,
                       0,
@@ -88,8 +93,6 @@
   default:
     break;
   }
-  if (lastEvent == FSUI_download_complete)
-    return NULL; /* ignore all other events */
   lastEvent = event->type;
   return NULL;
 }
@@ -110,7 +113,8 @@
   struct ECRS_MetaData * meta;
   struct ECRS_URI * kuri;
   struct GC_Configuration * cfg;
-  struct FSUI_SearchList * search;
+  struct FSUI_UploadList * upload;
+  struct FSUI_UnindexList * unindex;
 
   cfg = GC_create_C_impl();
   if (-1 == GC_parse_configuration(cfg,
@@ -167,7 +171,7 @@
   kuri = ECRS_parseListKeywordURI(NULL,
                                  2,
                                  (const char**)keywords);
-  CHECK(NULL !=
+  upload = 
        FSUI_startUpload(ctx,
                         fn,
                         0,
@@ -177,16 +181,17 @@
                         NO,
                         meta,
                         kuri,
-                        kuri));
+                        kuri);
+  CHECK(NULL != upload);
   ECRS_freeUri(kuri);
   ECRS_freeMetaData(meta);
   prog = 0;
   while (lastEvent != FSUI_upload_complete) {
     prog++;
     CHECK(prog < 10000)
-
     PTHREAD_SLEEP(50 * cronMILLIS);
   }
+  FSUI_stopUpload(ctx, upload);
 
   prog = 0;
   while (lastEvent != FSUI_download_complete) {
@@ -194,16 +199,15 @@
     CHECK(prog < 10000);
     PTHREAD_SLEEP(50 * cronMILLIS);
   }
-  FSUI_stopSearch(ctx,
-                 search);
-  CHECK(NULL != FSUI_unindex(ctx, fn));
-
+  unindex = FSUI_unindex(ctx, fn);
+  CHECK(NULL != unindex);
   prog = 0;
   while (lastEvent != FSUI_unindex_complete) {
     prog++;
     CHECK(prog < 10000);
     PTHREAD_SLEEP(50 * cronMILLIS);
   }
+  FSUI_stopUnindex(ctx, unindex);
 
   /* END OF TEST CODE */
  FAILURE:

Modified: GNUnet/src/applications/fs/fsui/unindex.c
===================================================================
--- GNUnet/src/applications/fs/fsui/unindex.c   2006-10-01 01:14:18 UTC (rev 
3421)
+++ GNUnet/src/applications/fs/fsui/unindex.c   2006-10-01 01:34:20 UTC (rev 
3422)
@@ -88,8 +88,6 @@
   }
   utc->ctx->ecb(utc->ctx->ecbClosure,
                &event);
-  FREE(utc->filename);
-  FREE(utc);
   GE_LOG(utc->ctx->ectx, 
         GE_DEBUG | GE_REQUEST | GE_USER,
         "FSUI unindexThread exits.\n");
@@ -149,7 +147,6 @@
                     struct FSUI_UnindexList * dl) {
   FSUI_UnindexList * prev;
   struct GE_Context * ectx;
-  unsigned int backup;
   void * unused;
 
   ectx = ctx->ectx;

Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c    2006-10-01 01:14:18 UTC (rev 
3421)
+++ GNUnet/src/applications/fs/fsui/upload.c    2006-10-01 01:34:20 UTC (rev 
3422)
@@ -485,16 +485,6 @@
   if (uri != NULL)
     ECRS_freeUri(uri);
 
-  FREE(utc->main_filename);
-  if (utc->meta != NULL)
-    ECRS_freeMetaData(utc->meta);
-  if (utc->uri != NULL)
-    ECRS_freeUri(utc->uri);
-  if (utc->globalUri != NULL)
-    ECRS_freeUri(utc->globalUri);
-  EXTRACTOR_removeAll(utc->extractors);
-  utc->extractors = NULL;
-  FREE(utc);
   FREENONNULL(inboundFN);
   return NULL;
 }
@@ -553,6 +543,7 @@
   utc->meta = ECRS_dupMetaData(md);
   utc->doIndex = doIndex;
   utc->individualKeywords = NO;
+  utc->force_termination = NO;
   utc->handle = PTHREAD_CREATE(&uploadThread,
                               utc,
                               128 * 1024);
@@ -563,6 +554,7 @@
     FREE(utc->main_filename);
     ECRS_freeMetaData(utc->meta);
     ECRS_freeUri(utc->uri);
+    EXTRACTOR_removeAll(utc->extractors);
     FREE(utc);
     return NULL;
   }
@@ -583,7 +575,50 @@
  */
 int FSUI_stopUpload(struct FSUI_Context * ctx,
                    struct FSUI_UploadList * ul) {
-  return SYSERR;
+  void * unused;
+  FSUI_UploadList * prev;
+  struct GE_Context * ectx;
+  void * unused;
+
+  ectx = ctx->ectx;
+  if (dl == NULL) {
+    GE_BREAK(ectx, 0);
+    return SYSERR;
+  }
+  GE_LOG(ectx,
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "FSUI_stopUpload called.\n");
+  MUTEX_LOCK(ctx->lock);
+  prev = ctx->uploadOperations;
+  while ( (prev != ul) &&
+         (prev != NULL) &&
+         (prev->next != ul) ) 
+    prev = prev->next;
+  if (prev == NULL) {
+    MUTEX_UNLOCK(ctx->lock);
+    GE_LOG(ectx, 
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          "FSUI_stopUpload failed to locate deletion operation.\n");
+    return SYSERR;
+  }
+  if (prev == ul) {
+    ctx->uploadOperations = ul->next;
+  } else {
+    prev->next = ul->next;
+  }
+  MUTEX_UNLOCK(ctx->lock);
+  ul->force_termination = YES;
+  PTHREAD_STOP_SLEEP(ul->handle);
+  PTHREAD_JOIN(ul->handle,
+              &unused);
+  FREE(ul->main_filename);
+  ECRS_freeMetaData(ul->meta);
+  ECRS_freeUri(ul->uri);
+  if (ul->globalUri != NULL)
+    ECRS_freeUri(ul->globalUri);
+  EXTRACTOR_removeAll(ul->extractors);
+  FREE(ul);
+  return OK;
 }
 
 /* end of upload.c */





reply via email to

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