gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r25970 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r25970 - gnunet/src/fs
Date: Fri, 1 Feb 2013 09:48:47 +0100

Author: grothoff
Date: 2013-02-01 09:48:47 +0100 (Fri, 01 Feb 2013)
New Revision: 25970

Modified:
   gnunet/src/fs/fs_test_lib.c
   gnunet/src/fs/fs_test_lib.h
   gnunet/src/fs/perf_gnunet_service_fs_p2p.c
   gnunet/src/fs/perf_gnunet_service_fs_p2p_respect.c
   gnunet/src/fs/test_fs_test_lib.c
   gnunet/src/fs/test_gnunet_service_fs_migration.c
   gnunet/src/fs/test_gnunet_service_fs_p2p.c
Log:
-fix non-terminating index test --- do not remove file early

Modified: gnunet/src/fs/fs_test_lib.c
===================================================================
--- gnunet/src/fs/fs_test_lib.c 2013-01-31 20:11:04 UTC (rev 25969)
+++ gnunet/src/fs/fs_test_lib.c 2013-02-01 08:48:47 UTC (rev 25970)
@@ -190,9 +190,14 @@
 
   GNUNET_FS_publish_stop (po->publish_context);
   GNUNET_TESTBED_operation_done (po->fs_op);
-  po->publish_cont (po->publish_cont_cls, po->publish_uri);
+  po->publish_cont (po->publish_cont_cls, 
+                   po->publish_uri,
+                   (GNUNET_YES == po->do_index) 
+                   ? po->publish_tmp_file
+                   : NULL);
   GNUNET_FS_uri_destroy (po->publish_uri);
-  (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
+  if (GNUNET_YES != po->do_index)
+    (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
   GNUNET_free_non_null (po->publish_tmp_file);
   GNUNET_free (po);
 }
@@ -217,7 +222,7 @@
   else
     GNUNET_TESTBED_operation_done (po->fs_op);
   GNUNET_FS_publish_stop (po->publish_context);
-  po->publish_cont (po->publish_cont_cls, NULL);
+  po->publish_cont (po->publish_cont_cls, NULL, NULL);
   (void) GNUNET_DISK_directory_remove (po->publish_tmp_file);
   GNUNET_free_non_null (po->publish_tmp_file);
   GNUNET_free (po);
@@ -370,7 +375,7 @@
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect to FS for 
publishing: %s\n", emsg);
       po->publish_cont (po->publish_cont_cls,
-                       NULL);
+                       NULL, NULL);
       GNUNET_TESTBED_operation_done (po->fs_op);
       GNUNET_free (po);
       return;

Modified: gnunet/src/fs/fs_test_lib.h
===================================================================
--- gnunet/src/fs/fs_test_lib.h 2013-01-31 20:11:04 UTC (rev 25969)
+++ gnunet/src/fs/fs_test_lib.h 2013-02-01 08:48:47 UTC (rev 25970)
@@ -39,10 +39,13 @@
  *
  * @param cls closure (user defined)
  * @param uri a URI, NULL for errors
+ * @param fn name of the file on disk to be removed upon
+ *           completion, or NULL for inserted files (also NULL on error)
  */
 typedef void (*GNUNET_FS_TEST_UriContinuation) (void *cls,
                                                 const struct GNUNET_FS_Uri *
-                                                uri);
+                                                uri,
+                                               const char *fn);
 
 
 /**

Modified: gnunet/src/fs/perf_gnunet_service_fs_p2p.c
===================================================================
--- gnunet/src/fs/perf_gnunet_service_fs_p2p.c  2013-01-31 20:11:04 UTC (rev 
25969)
+++ gnunet/src/fs/perf_gnunet_service_fs_p2p.c  2013-02-01 08:48:47 UTC (rev 
25970)
@@ -234,18 +234,25 @@
 static void
 do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  char *fn = cls;
   struct GNUNET_TIME_Relative del;
   char *fancy;
   struct StatMaster *sm;
 
+  if (NULL != fn)
+  {
+    GNUNET_DISK_directory_remove (fn);
+    GNUNET_free (fn);
+  }
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) 
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Timeout during download, shutting down with error\n");
     ok = 1;
-    GNUNET_SCHEDULER_shutdown ();
+    GNUNET_SCHEDULER_shutdown ();   
     return;
   }
+
   del = GNUNET_TIME_absolute_get_duration (start_time);
   if (del.rel_value == 0)
     del.rel_value = 1;
@@ -269,7 +276,9 @@
 
 
 static void
-do_download (void *cls, const struct GNUNET_FS_Uri *uri)
+do_download (void *cls, 
+            const struct GNUNET_FS_Uri *uri,
+            const char *fn)
 {
   int anonymity;
 
@@ -289,7 +298,8 @@
   else
     anonymity = 1;
   GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE,
-                           &do_report, NULL);
+                           &do_report, 
+                          (NULL == fn) ? NULL : GNUNET_strdup (fn));
 }
 
 

Modified: gnunet/src/fs/perf_gnunet_service_fs_p2p_respect.c
===================================================================
--- gnunet/src/fs/perf_gnunet_service_fs_p2p_respect.c  2013-01-31 20:11:04 UTC 
(rev 25969)
+++ gnunet/src/fs/perf_gnunet_service_fs_p2p_respect.c  2013-02-01 08:48:47 UTC 
(rev 25970)
@@ -86,7 +86,10 @@
 
 static struct GNUNET_FS_Uri *uri2;
 
+static char *fn1;
 
+static char *fn2;
+
 /**
  * Master context for 'stat_run'.
  */
@@ -132,6 +135,23 @@
 };
 
 
+static void
+cleanup ()
+{
+  GNUNET_SCHEDULER_shutdown ();
+  if (NULL != fn1)
+  {
+    GNUNET_DISK_directory_remove (fn1);
+    GNUNET_free (fn1);
+  }
+  if (NULL != fn2)
+  {
+    GNUNET_DISK_directory_remove (fn2);
+    GNUNET_free (fn2);
+  }
+}
+
+
 /**
  * Callback function to process statistic values.
  *
@@ -244,7 +264,7 @@
   if (NUM_DAEMONS == sm->daemon)
   {
     GNUNET_free (sm);
-    GNUNET_SCHEDULER_shutdown ();
+    cleanup ();
     return;
   }
   sm->op =
@@ -273,7 +293,7 @@
                 "Timeout during download for type `%s', shutting down with 
error\n",
                 type);
     ok = 1;
-    GNUNET_SCHEDULER_shutdown ();
+    cleanup ();
     return;
   }
   del = GNUNET_TIME_absolute_get_duration (start_time);
@@ -301,19 +321,22 @@
 
 
 static void
-do_downloads (void *cls, const struct GNUNET_FS_Uri *u2)
+do_downloads (void *cls, const struct GNUNET_FS_Uri *u2,
+             const char *fn)
 {
   int anonymity;
   unsigned int i;
 
   if (NULL == u2)
   {
-    GNUNET_SCHEDULER_shutdown ();
+    cleanup ();
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Timeout during upload attempt, shutting down with error\n");
     ok = 1;
     return;
   }
+  if (NULL != fn)
+    fn2 = GNUNET_strdup (fn);
   uri2 = GNUNET_FS_uri_dup (u2);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
               (unsigned long long) FILESIZE);
@@ -340,19 +363,22 @@
 
 static void
 do_publish2 (void *cls,             
-            const struct GNUNET_FS_Uri *u1)
+            const struct GNUNET_FS_Uri *u1,
+            const char *fn)
 {
   int do_index;
   int anonymity;
 
   if (NULL == u1)
-    {
-    GNUNET_SCHEDULER_shutdown ();
+  {
+    cleanup ();
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Timeout during upload attempt, shutting down with error\n");
     ok = 1;
     return;
   }
+  if (NULL != fn)
+    fn1 = GNUNET_strdup (fn);
   uri1 = GNUNET_FS_uri_dup (u1);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
               (unsigned long long) FILESIZE);
@@ -383,7 +409,7 @@
   GNUNET_TESTBED_operation_done (op);
   if (NULL != emsg)
   {
-    GNUNET_SCHEDULER_shutdown ();
+    cleanup ();
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error trying to connect: %s\n", 
emsg);
     ok = 1;
     return;

Modified: gnunet/src/fs/test_fs_test_lib.c
===================================================================
--- gnunet/src/fs/test_fs_test_lib.c    2013-01-31 20:11:04 UTC (rev 25969)
+++ gnunet/src/fs/test_fs_test_lib.c    2013-02-01 08:48:47 UTC (rev 25970)
@@ -50,6 +50,8 @@
 static void
 do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  char *fn = cls;
+
   if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
   {
     GNUNET_break (0);
@@ -60,12 +62,18 @@
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
                 (unsigned long long) FILESIZE);
   }
+  if (NULL != fn)
+  {
+    GNUNET_DISK_directory_remove (fn);
+    GNUNET_free (fn);
+  }
   GNUNET_SCHEDULER_shutdown ();
 }
 
 
 static void
-do_download (void *cls, const struct GNUNET_FS_Uri *uri)
+do_download (void *cls, const struct GNUNET_FS_Uri *uri,
+            const char *fn)
 {
   if (NULL == uri)
   {
@@ -77,7 +85,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
               (unsigned long long) FILESIZE);
   GNUNET_FS_TEST_download (the_peers[0], TIMEOUT, 1, SEED, uri, VERBOSE, 
&do_stop,
-                           NULL);
+                           (NULL == fn) ? NULL : GNUNET_strdup (fn));
 }
 
 

Modified: gnunet/src/fs/test_gnunet_service_fs_migration.c
===================================================================
--- gnunet/src/fs/test_gnunet_service_fs_migration.c    2013-01-31 20:11:04 UTC 
(rev 25969)
+++ gnunet/src/fs/test_gnunet_service_fs_migration.c    2013-02-01 08:48:47 UTC 
(rev 25970)
@@ -55,6 +55,14 @@
 static struct GNUNET_TESTBED_Operation *op;
 
 
+struct DownloadContext
+{
+  char *fn;
+
+  struct GNUNET_FS_Uri *uri;
+};
+
+
 static void
 do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -88,10 +96,17 @@
 do_download (void *cls, 
             const char *emsg)
 {
-  struct GNUNET_FS_Uri *uri = cls;
+  struct DownloadContext *dc = cls;
+  struct GNUNET_FS_Uri *uri = dc->uri;
 
   GNUNET_TESTBED_operation_done (op);
   op = NULL;
+  if (NULL != dc->fn)
+  {
+    GNUNET_DISK_directory_remove (dc->fn);
+    GNUNET_free (dc->fn);
+  }
+  GNUNET_free (dc);
   if (NULL != emsg)
   {
     GNUNET_SCHEDULER_shutdown ();
@@ -113,18 +128,19 @@
 static void
 stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  struct GNUNET_FS_Uri *uri = cls;
+  struct DownloadContext *dc = cls;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n");
-  op = GNUNET_TESTBED_peer_stop (daemons[1], &do_download, uri);
+  op = GNUNET_TESTBED_peer_stop (daemons[1], &do_download, dc);
   GNUNET_assert (NULL != op);
 }
 
 
 static void
-do_wait (void *cls, const struct GNUNET_FS_Uri *uri)
+do_wait (void *cls, const struct GNUNET_FS_Uri *uri,
+        const char *fn)
 {
-  struct GNUNET_FS_Uri *d;
+  struct DownloadContext *dc;
 
   if (NULL == uri)
   {
@@ -135,8 +151,11 @@
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to 
migrate\n");
-  d = GNUNET_FS_uri_dup (uri);
-  (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, d);
+  dc = GNUNET_malloc (sizeof (struct DownloadContext));
+  dc->uri = GNUNET_FS_uri_dup (uri);
+  if (NULL != fn)
+    dc->fn = GNUNET_strdup (fn);
+  (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, dc);
 }
 
 

Modified: gnunet/src/fs/test_gnunet_service_fs_p2p.c
===================================================================
--- gnunet/src/fs/test_gnunet_service_fs_p2p.c  2013-01-31 20:11:04 UTC (rev 
25969)
+++ gnunet/src/fs/test_gnunet_service_fs_p2p.c  2013-02-01 08:48:47 UTC (rev 
25970)
@@ -56,6 +56,7 @@
 static void
 do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  char *fn = cls;
   struct GNUNET_TIME_Relative del;
   char *fancy;
 
@@ -79,11 +80,17 @@
                 "Timeout during download, shutting down with error\n");
     ok = 1;
   }
+  if (NULL != fn)
+  {
+    GNUNET_DISK_directory_remove (fn);
+    GNUNET_free (fn);
+  }
 }
 
 
 static void
-do_download (void *cls, const struct GNUNET_FS_Uri *uri)
+do_download (void *cls, const struct GNUNET_FS_Uri *uri,
+            const char *fn)
 {
   if (NULL == uri)
   {
@@ -99,7 +106,9 @@
   GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 
                           anonymity_level, SEED, uri, 
                           VERBOSE, &do_stop,
-                           NULL);
+                           (NULL == fn) 
+                          ? NULL
+                          : GNUNET_strdup (fn));
 }
 
 




reply via email to

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