gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3427 - in GNUnet: . src/applications/fs/fsui


From: grothoff
Subject: [GNUnet-SVN] r3427 - in GNUnet: . src/applications/fs/fsui
Date: Sat, 30 Sep 2006 21:15:22 -0700 (PDT)

Author: grothoff
Date: 2006-09-30 21:15:18 -0700 (Sat, 30 Sep 2006)
New Revision: 3427

Modified:
   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/fsui.h
   GNUnet/src/applications/fs/fsui/search.c
   GNUnet/todo
Log:
fixing downloadtest

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2006-10-01 03:30:37 UTC (rev 
3426)
+++ GNUnet/src/applications/fs/fsui/download.c  2006-10-01 04:15:18 UTC (rev 
3427)
@@ -105,11 +105,11 @@
       fullName);
 #endif
   startDownload(parent->ctx,
-                    parent->anonymityLevel,
-                    YES,
-                    fi->uri,
-                    fullName,
-                    parent);
+               parent->anonymityLevel,
+               YES,
+               fi->uri,
+               fullName,
+               parent);
   FREE(fullName);
   return OK;
 }
@@ -386,6 +386,7 @@
   dl->filename = STRDUP(filename);
   dl->uri = ECRS_dupUri(uri);
   dl->total = ECRS_fileSize(uri);
+  dl->child = NULL;
   dl->next = parent->child;
   parent->child = dl;  
   totalBytes = ECRS_fileSize(uri);
@@ -577,6 +578,7 @@
   struct GE_Context * ectx;
   unsigned int backup;
 
+  printf("Stop download %p\n", dl);
   ectx = ctx->ectx;
   if (dl == NULL) {
     GE_BREAK(ectx, 0);

Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c      2006-10-01 03:30:37 UTC 
(rev 3426)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c      2006-10-01 04:15:18 UTC 
(rev 3427)
@@ -43,8 +43,6 @@
 
 static struct GE_Context * ectx;
 
-static struct FSUI_DownloadList * download;
-
 static char * makeName(unsigned int i) {
   char * name;
   char * fn;
@@ -66,12 +64,26 @@
 static volatile enum FSUI_EventType waitForEvent;
 static struct FSUI_Context * ctx;
 static struct ECRS_URI * upURI;
+static struct FSUI_SearchList * search;
+static struct FSUI_DownloadList * download;
 
 static void * eventCallback(void * cls,
                            const FSUI_Event * event) {
   char * fn;
 
   switch(event->type) {
+  case FSUI_search_resuming:
+#if DEBUG_VERBOSE
+    printf("Search resuming\n"); 
+#endif
+    search = event->data.SearchResuming.sc.pos;
+    break;
+  case FSUI_download_resuming: 
+#if DEBUG_VERBOSE
+    printf("Download resuming\n");
+#endif
+   download = event->data.DownloadResuming.dc.pos;
+    break;
   case FSUI_search_result:
 #if DEBUG_VERBOSE
     printf("Received search result\n");
@@ -81,12 +93,16 @@
       
       if (! ECRS_equalsUri(upURI,
                           event->data.SearchResult.fi.uri)) {
+#if DEBUG_VERBOSE
        printf("Received search result for different file (download not 
started).\n");
+#endif
        return NULL; /* ignore */
       }
       fn = makeName(43);
       u = ECRS_uriToString(event->data.SearchResult.fi.uri);
+#if DEBUG_VERBOSE
       printf("Download started: %s.\n", u);
+#endif
       FREE(u);
       download = FSUI_startDownload(ctx,
                                    0,
@@ -110,10 +126,14 @@
     break;
   case FSUI_upload_complete:
     upURI = ECRS_dupUri(event->data.UploadComplete.uri);
+#if DEBUG_VERBOSE
     printf("Upload complete.\n");
+#endif
     break;
   case FSUI_download_complete:
+#if DEBUG_VERBOSE
     printf("Download complete.\n");
+#endif
     break;
   case FSUI_download_progress:
 #if DEBUG_VERBOSE
@@ -130,7 +150,9 @@
 #endif
     break;
   case FSUI_unindex_complete:
+#if DEBUG_VERBOSE
     printf("Unindex complete.\n");
+#endif
     break;
   case FSUI_unindex_error:
   case FSUI_upload_error:
@@ -153,9 +175,11 @@
   case FSUI_upload_suspending:
   case FSUI_download_suspending:
   case FSUI_search_suspending:
+#if DEBUG_VERBOSE
     fprintf(stderr,
            "Received SUSPENDING: %d\n",
            event->type);
+#endif
     break;
   default:
     printf("Unexpected event: %d\n",
@@ -188,7 +212,6 @@
   struct ECRS_MetaData * meta;
   struct ECRS_URI * kuri = NULL;
   struct GC_Configuration * cfg;
-  struct FSUI_SearchList * search = NULL;
   struct FSUI_UnindexList * unindex = NULL;
   struct FSUI_UploadList * upload = NULL;
 
@@ -251,7 +274,8 @@
     prog++;
     CHECK(prog < 1000);
     PTHREAD_SLEEP(50 * cronMILLIS);
-    printf("U\n");
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
   }
   FSUI_stopUpload(ctx, upload);
   SNPRINTF(keyword,
@@ -280,6 +304,11 @@
 #endif
       FSUI_stop(ctx); /* download possibly incomplete
                         at this point, thus testing resume */
+      /* FIXME: this should be done in 
+        "suspend" event handler -- once event is implemented! */
+      search = NULL;
+      download = NULL;
+      
       ctx = FSUI_start(NULL,
                       cfg,
                       "fsuidownloadtest",
@@ -293,10 +322,11 @@
 #endif
       suspendRestart--;
     }
-    printf("R\n");
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
   }
-  CHECK(OK == FSUI_stopSearch(ctx,
-                             search));
+  CHECK(search != NULL);
+  CHECK(download != NULL);
   waitForEvent = FSUI_unindex_complete;
   unindex = FSUI_unindex(ctx, fn);
   CHECK(unindex != NULL);
@@ -306,7 +336,8 @@
     CHECK(prog < 1000);
     PTHREAD_SLEEP(50 * cronMILLIS);
     CHECK(lastEvent != FSUI_unindex_error);
-    printf("D\n");
+    if (GNUNET_SHUTDOWN_TEST() == YES)
+      break;
   }
   CHECK(lastEvent == FSUI_unindex_complete);
   /* END OF TEST CODE */

Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c      2006-10-01 03:30:37 UTC (rev 
3426)
+++ GNUnet/src/applications/fs/fsui/fsui.c      2006-10-01 04:15:18 UTC (rev 
3427)
@@ -22,6 +22,11 @@
  * @file applications/fs/fsui/fsui.c
  * @brief main FSUI functions
  * @author Christian Grothoff
+ *
+ * TODO:
+ * - upload suspend/resume
+ * - unindex suspend/resume
+ * - events for suspend (!)
  */
 
 #include "platform.h"
@@ -29,7 +34,7 @@
 #include "gnunet_directories.h"
 #include "fsui.h"
 
-#define DEBUG_PERSISTENCE YES
+#define DEBUG_PERSISTENCE NO
 
 #define FSUI_UDT_FREQUENCY (2 * cronSECONDS)
 
@@ -86,6 +91,7 @@
   unsigned long long bigl;
   int i;
   int ok;
+  FSUI_Event event;
 
   GE_ASSERT(ectx, ctx != NULL);
   if (1 != READ(fd, &zaro, sizeof(char))) {
@@ -179,6 +185,19 @@
         ret->completed,
         ret->total);
 #endif
+  /* signal event handler! */
+  event.type = FSUI_download_resuming;
+  event.data.DownloadResuming.dc.pos = ret;
+  event.data.DownloadResuming.dc.cctx = NULL;
+  event.data.DownloadResuming.dc.ppos = ret->parent;
+  event.data.DownloadResuming.dc.pcctx = NULL; /* not yet available */
+  event.data.DownloadResuming.eta = get_time(); /* best guess */
+  event.data.DownloadResuming.total = ret->total;
+  event.data.DownloadResuming.completed = ret->completedFile;
+  event.data.DownloadResuming.anonymityLevel = ret->anonymityLevel;
+  event.data.DownloadResuming.uri = ret->uri;
+  ret->cctx = ctx->ecb(ctx->ecbClosure, &event);
+
   return ret;
  ERR:
   FREENONNULL(ret->filename);
@@ -380,6 +399,7 @@
                                 int doResume,
                                 FSUI_EventCallback cb,
                                 void * closure) {
+  FSUI_Event event;
   FSUI_Context * ret;
   FSUI_SearchList * list;
   ResultPending * rp;
@@ -397,6 +417,12 @@
     = ret;
   ret->cfg
     = cfg;
+  ret->ecb = cb;
+  ret->ecbClosure = closure;
+  ret->threadPoolSize = threadPoolSize;
+  if (ret->threadPoolSize == 0)
+    ret->threadPoolSize = 32;
+  ret->activeDownloadThreads = 0;
 
   GC_get_configuration_value_filename(cfg,
                                      "GNUNET",
@@ -414,9 +440,10 @@
                                    fn,
                                    1);
 #if DEBUG_PERSISTENCE
-    GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER,
-       "Getting IPC lock for FSUI (%s).\n",
-       fn);
+    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
@@ -633,6 +660,15 @@
          = ret->activeSearches;
        ret->activeSearches
          = list;
+       /* then: signal event handler! */
+       event.type = FSUI_search_resuming;
+       event.data.SearchResuming.sc.pos = list;
+       event.data.SearchResuming.sc.cctx = NULL;
+       event.data.SearchResuming.fis = list->resultsReceived;
+       event.data.SearchResuming.fisSize = list->sizeResultsReceived;
+       event.data.SearchResuming.anonymityLevel = list->anonymityLevel;
+       event.data.SearchResuming.searchURI = list->uri;
+       list->cctx = cb(closure, &event);       
       }
       memset(&ret->activeDownloads,
             0,
@@ -687,12 +723,6 @@
     ret->ipc = NULL;
   }
   ret->lock = MUTEX_CREATE(YES);
-  ret->ecb = cb;
-  ret->ecbClosure = closure;
-  ret->threadPoolSize = threadPoolSize;
-  if (ret->threadPoolSize == 0)
-    ret->threadPoolSize = 32;
-  ret->activeDownloadThreads = 0;
   ret->cron = cron_create(ectx);  
   cron_add_job(ret->cron,
               &updateDownloadThreads,
@@ -872,8 +902,9 @@
   }
   if (fd != -1) {
 #if DEBUG_PERSISTENCE
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-       "Serializing FSUI state done.\n");
+    GE_LOG(ectx,
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          "Serializing FSUI state done.\n");
 #endif
     CLOSE(fd);
   }
@@ -888,8 +919,9 @@
   MUTEX_DESTROY(ctx->lock);
   FREE(ctx->name);
   FREE(ctx);
-  GE_LOG(ectx, GE_INFO | GE_REQUEST | GE_USER,
-      "FSUI shutdown complete.\n");
+  GE_LOG(ectx,
+        GE_INFO | GE_REQUEST | GE_USER,
+        "FSUI shutdown complete.\n");
 }
 
 

Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h      2006-10-01 03:30:37 UTC (rev 
3426)
+++ GNUnet/src/applications/fs/fsui/fsui.h      2006-10-01 04:15:18 UTC (rev 
3427)
@@ -140,6 +140,8 @@
    */
   unsigned int sizeUnmatchedResultsReceived;
 
+  void * cctx;
+
 } FSUI_SearchList;
 
 /**

Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c    2006-10-01 03:30:37 UTC (rev 
3426)
+++ GNUnet/src/applications/fs/fsui/search.c    2006-10-01 04:15:18 UTC (rev 
3427)
@@ -57,6 +57,8 @@
   event.type = FSUI_search_result;
   event.data.SearchResult.fi = *fi;
   event.data.SearchResult.searchURI = pos->uri;
+  event.data.SearchResult.sc.pos = pos;
+  event.data.SearchResult.sc.cctx = pos->cctx;
   pos->ctx->ecb(pos->ctx->ecbClosure,
                &event);
 }

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-10-01 03:30:37 UTC (rev 3426)
+++ GNUnet/todo 2006-10-01 04:15:18 UTC (rev 3427)
@@ -18,7 +18,9 @@
     + 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:
+      - searchtest, downloadtest pass
+      - fsuitest, fsuitest2 -- to be done
     + dht/tools, dht/module
   * transports:
     + SMTP/HTTP: do not yet compile (commented out from build)
@@ -32,13 +34,16 @@
       - rpc
     + incomplete (API change-related fixes):
       - fs/fslib
+        * error handing
       - fs/module 
       - fs/ecrs
       - fs/uritrack 
       - fs/tools
       - fs/namespace,
       - fs/collection
-      - fs/fsui
+      - fs/fsui:
+        * events for suspend, abort
+        * make sure new event fields are set for all events
     + not compiling:
       - vpn
       - chat





reply via email to

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