gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r36178 - gnunet/src/fs
Date: Mon, 3 Aug 2015 11:35:48 +0200

Author: grothoff
Date: 2015-08-03 11:35:48 +0200 (Mon, 03 Aug 2015)
New Revision: 36178

Modified:
   gnunet/src/fs/fs_test_lib.c
   gnunet/src/fs/fs_test_lib.h
   gnunet/src/fs/gnunet-download.c
   gnunet/src/fs/gnunet-search.c
   gnunet/src/fs/gnunet-unindex.c
   gnunet/src/fs/perf_gnunet_service_fs_p2p.c
   gnunet/src/fs/perf_gnunet_service_fs_p2p_respect.c
   gnunet/src/fs/test_fs_download.c
   gnunet/src/fs/test_fs_download_persistence.c
   gnunet/src/fs/test_fs_list_indexed.c
   gnunet/src/fs/test_fs_namespace.c
   gnunet/src/fs/test_fs_publish.c
   gnunet/src/fs/test_fs_search.c
   gnunet/src/fs/test_fs_search_persistence.c
   gnunet/src/fs/test_fs_search_probes.c
   gnunet/src/fs/test_fs_search_with_and.c
   gnunet/src/fs/test_fs_test_lib.c
   gnunet/src/fs/test_fs_unindex.c
   gnunet/src/fs/test_fs_unindex_persistence.c
   gnunet/src/fs/test_gnunet_service_fs_migration.c
   gnunet/src/fs/test_gnunet_service_fs_p2p.c
Log:
-use simpler, modern scheduler API

Modified: gnunet/src/fs/fs_test_lib.c
===================================================================
--- gnunet/src/fs/fs_test_lib.c 2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/fs_test_lib.c 2015-08-03 09:35:48 UTC (rev 36178)
@@ -245,8 +245,8 @@
     po->publish_timeout_task = NULL;
     po->publish_uri =
         GNUNET_FS_uri_dup (info->value.publish.specifics.completed.chk_uri);
-    GNUNET_SCHEDULER_add_continuation (&report_uri, po,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&report_uri,
+                              po);
     break;
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
     if (po->verbose)
@@ -490,10 +490,10 @@
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
               "Timeout while trying to download file\n");
   dop->download_timeout_task = NULL;
-  GNUNET_FS_download_stop (dop->download_context, GNUNET_YES);
-  GNUNET_SCHEDULER_add_continuation (dop->download_cont,
-                                     dop->download_cont_cls,
-                                     GNUNET_SCHEDULER_REASON_TIMEOUT);
+  GNUNET_FS_download_stop (dop->download_context,
+                           GNUNET_YES);
+  GNUNET_SCHEDULER_add_now (dop->download_cont,
+                            dop->download_cont_cls);
   GNUNET_TESTBED_operation_done (dop->fs_op);
   GNUNET_FS_uri_destroy (dop->uri);
   GNUNET_free (dop);
@@ -512,10 +512,10 @@
 {
   struct TestDownloadOperation *dop = cls;
 
-  GNUNET_FS_download_stop (dop->download_context, GNUNET_YES);
-  GNUNET_SCHEDULER_add_continuation (dop->download_cont,
-                                     dop->download_cont_cls,
-                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+  GNUNET_FS_download_stop (dop->download_context,
+                           GNUNET_YES);
+  GNUNET_SCHEDULER_add_now (dop->download_cont,
+                            dop->download_cont_cls);
   GNUNET_TESTBED_operation_done (dop->fs_op);
   GNUNET_FS_uri_destroy (dop->uri);
   GNUNET_free (dop);
@@ -529,7 +529,8 @@
  * @param info information about the event
  */
 static void *
-download_progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
+download_progress_cb (void *cls,
+                      const struct GNUNET_FS_ProgressInfo *info)
 {
   struct TestDownloadOperation *dop = cls;
 
@@ -537,7 +538,8 @@
   {
   case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
     if (dop->verbose)
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n",
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "Download at %llu/%llu bytes\n",
                   (unsigned long long) info->value.download.completed,
                   (unsigned long long) info->value.download.size);
     break;
@@ -544,8 +546,7 @@
   case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
     GNUNET_SCHEDULER_cancel (dop->download_timeout_task);
     dop->download_timeout_task = NULL;
-    GNUNET_SCHEDULER_add_continuation (&report_success, dop,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&report_success, dop);
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
   case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:

Modified: gnunet/src/fs/fs_test_lib.h
===================================================================
--- gnunet/src/fs/fs_test_lib.h 2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/fs_test_lib.h 2015-08-03 09:35:48 UTC (rev 36178)
@@ -42,10 +42,10 @@
  * @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,
-                                               const char *fn);
+typedef void
+(*GNUNET_FS_TEST_UriContinuation) (void *cls,
+                                   const struct GNUNET_FS_Uri *uri,
+                                   const char *fn);
 
 
 /**
@@ -55,20 +55,24 @@
  * @param timeout if this operation cannot be completed within the
  *                given period, call the continuation with an error code
  * @param anonymity option for publication
- * @param do_index GNUNET_YES for index, GNUNET_NO for insertion,
- *                GNUNET_SYSERR for simulation
+ * @param do_index #GNUNET_YES for index, #GNUNET_NO for insertion,
+ *                #GNUNET_SYSERR for simulation
  * @param size size of the file to publish
  * @param seed seed to use for file generation
  * @param verbose how verbose to be in reporting
  * @param cont function to call when done
- * @param cont_cls closure for cont
+ * @param cont_cls closure for @a cont
  */
 void
 GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer,
-                        struct GNUNET_TIME_Relative timeout, uint32_t 
anonymity,
-                        int do_index, uint64_t size, uint32_t seed,
+                        struct GNUNET_TIME_Relative timeout,
+                        uint32_t anonymity,
+                        int do_index,
+                        uint64_t size,
+                        uint32_t seed,
                         unsigned int verbose,
-                        GNUNET_FS_TEST_UriContinuation cont, void *cont_cls);
+                        GNUNET_FS_TEST_UriContinuation cont,
+                        void *cont_cls);
 
 
 /**
@@ -82,14 +86,17 @@
  * @param uri URI of file to download (CHK/LOC only)
  * @param verbose how verbose to be in reporting
  * @param cont function to call when done
- * @param cont_cls closure for cont
+ * @param cont_cls closure for @a cont
  */
 void
 GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer,
                          struct GNUNET_TIME_Relative timeout,
-                         uint32_t anonymity, uint32_t seed,
-                         const struct GNUNET_FS_Uri *uri, unsigned int verbose,
-                         GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls);
+                         uint32_t anonymity,
+                         uint32_t seed,
+                         const struct GNUNET_FS_Uri *uri,
+                         unsigned int verbose,
+                         GNUNET_SCHEDULER_TaskCallback cont,
+                         void *cont_cls);
 
 
 

Modified: gnunet/src/fs/gnunet-download.c
===================================================================
--- gnunet/src/fs/gnunet-download.c     2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/gnunet-download.c     2015-08-03 09:35:48 UTC (rev 36178)
@@ -199,8 +199,7 @@
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
     if (info->value.download.dc == dc)
-      GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&cleanup_task, NULL);
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
   case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:

Modified: gnunet/src/fs/gnunet-search.c
===================================================================
--- gnunet/src/fs/gnunet-search.c       2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/gnunet-search.c       2015-08-03 09:35:48 UTC (rev 36178)
@@ -199,8 +199,7 @@
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_SEARCH_STOPPED:
-    GNUNET_SCHEDULER_add_continuation (&clean_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&clean_task, NULL);
     break;
   default:
     FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);

Modified: gnunet/src/fs/gnunet-unindex.c
===================================================================
--- gnunet/src/fs/gnunet-unindex.c      2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/gnunet-unindex.c      2015-08-03 09:35:48 UTC (rev 36178)
@@ -101,8 +101,7 @@
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_UNINDEX_STOPPED:
-    GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&cleanup_task, NULL);
     break;
   default:
     FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);

Modified: gnunet/src/fs/perf_gnunet_service_fs_p2p.c
===================================================================
--- gnunet/src/fs/perf_gnunet_service_fs_p2p.c  2015-08-03 09:31:58 UTC (rev 
36177)
+++ gnunet/src/fs/perf_gnunet_service_fs_p2p.c  2015-08-03 09:35:48 UTC (rev 
36178)
@@ -51,7 +51,9 @@
 
 static const char *progname;
 
+static struct GNUNET_TIME_Absolute start_time;
 
+
 /**
  * Master context for 'stat_run'.
  */
@@ -105,8 +107,8 @@
  * @param subsystem name of subsystem that created the statistic
  * @param name the name of the datum
  * @param value the current value
- * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
- * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
+ * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if 
not
+ * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
  */
 static int
 print_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
@@ -114,8 +116,12 @@
 {
   struct StatMaster *sm = cls;
 
-  FPRINTF (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem,
-           name, (unsigned long long) value);
+  FPRINTF (stderr,
+           "Peer %2u: %12s/%50s = %12llu\n",
+           sm->daemon,
+           subsystem,
+           name,
+           (unsigned long long) value);
   return GNUNET_OK;
 }
 
@@ -232,7 +238,8 @@
 
 
 static void
-do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_report (void *cls,
+           const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   char *fn = cls;
   struct GNUNET_TIME_Relative del;
@@ -244,7 +251,9 @@
     GNUNET_DISK_directory_remove (fn);
     GNUNET_free (fn);
   }
-  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
+  if (0 ==
+      GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time,
+                                                                    
TIMEOUT)).rel_value_us)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Timeout during download, shutting down with error\n");
@@ -297,7 +306,13 @@
     anonymity = 0;
   else
     anonymity = 1;
-  GNUNET_FS_TEST_download (daemons[0], TIMEOUT, anonymity, SEED, uri, VERBOSE,
+  start_time = GNUNET_TIME_absolute_get ();
+  GNUNET_FS_TEST_download (daemons[0],
+                           TIMEOUT,
+                           anonymity,
+                           SEED,
+                           uri,
+                           VERBOSE,
                            &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  2015-08-03 09:31:58 UTC 
(rev 36177)
+++ gnunet/src/fs/perf_gnunet_service_fs_p2p_respect.c  2015-08-03 09:35:48 UTC 
(rev 36178)
@@ -287,7 +287,9 @@
   char *fancy;
   struct StatMaster *sm;
 
-  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+  if (0 ==
+      GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time,
+                                                                    
TIMEOUT)).rel_value_us)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Timeout during download for type `%s', shutting down with 
error\n",
@@ -362,7 +364,7 @@
 
 
 static void
-do_publish2 (void *cls,        
+do_publish2 (void *cls,
             const struct GNUNET_FS_Uri *u1,
             const char *fn)
 {

Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c    2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/test_fs_download.c    2015-08-03 09:35:48 UTC (rev 36178)
@@ -198,8 +198,7 @@
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     GNUNET_SCHEDULER_shutdown ();
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
@@ -235,8 +234,7 @@
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
     GNUNET_assert (download == event->value.download.dc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
     printf ("Unexpected event: %d\n", event->status);

Modified: gnunet/src/fs/test_fs_download_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_download_persistence.c        2015-08-03 09:31:58 UTC 
(rev 36177)
+++ gnunet/src/fs/test_fs_download_persistence.c        2015-08-03 09:35:48 UTC 
(rev 36178)
@@ -202,8 +202,7 @@
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
     FPRINTF (stderr, "Error downloading file: %s\n",
@@ -265,8 +264,7 @@
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
     GNUNET_assert (download == event->value.download.dc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     download = NULL;
     break;
   default:

Modified: gnunet/src/fs/test_fs_list_indexed.c
===================================================================
--- gnunet/src/fs/test_fs_list_indexed.c        2015-08-03 09:31:58 UTC (rev 
36177)
+++ gnunet/src/fs/test_fs_list_indexed.c        2015-08-03 09:35:48 UTC (rev 
36178)
@@ -76,11 +76,10 @@
 
 
 static void
-list_indexed_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+list_indexed_task (void *cls,
+                   const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-
-  GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+  GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
 }
 
 
@@ -100,8 +99,7 @@
                                    GNUNET_TIME_absolute_get_duration
                                    (start).rel_value_us) / 1024));
     if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx))
-      GNUNET_SCHEDULER_add_continuation (&list_indexed_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&list_indexed_task, NULL);
 
     break;
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
@@ -124,8 +122,7 @@
              event->value.publish.specifics.error.message);
     err = 1;
     if (0 == strcmp ("list_indexed-context-dir", event->value.publish.cctx))
-      GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_START:
     ret = event->value.publish.cctx;

Modified: gnunet/src/fs/test_fs_namespace.c
===================================================================
--- gnunet/src/fs/test_fs_namespace.c   2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/test_fs_namespace.c   2015-08-03 09:35:48 UTC (rev 36178)
@@ -118,8 +118,7 @@
         FPRINTF (stderr, "%s",  "Wrong result for ksk search!\n");
         err = 1;
       }
-      GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&abort_ksk_search_task, NULL);
     }
     else
     {
@@ -131,11 +130,9 @@
     FPRINTF (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
     if (sks_search == event->value.search.sc)
-      GNUNET_SCHEDULER_add_continuation (&abort_sks_search_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&abort_sks_search_task, NULL);
     else if (ksk_search == event->value.search.sc)
-      GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&abort_ksk_search_task, NULL);
     else
       GNUNET_break (0);
     break;

Modified: gnunet/src/fs/test_fs_publish.c
===================================================================
--- gnunet/src/fs/test_fs_publish.c     2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/test_fs_publish.c     2015-08-03 09:35:48 UTC (rev 36178)
@@ -87,8 +87,7 @@
                                    GNUNET_TIME_absolute_get_duration
                                    (start).rel_value_us) / 1024));
     if (0 == strcmp ("publish-context-dir", event->value.publish.cctx))
-      GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_PROGRESS:
     ret = event->value.publish.cctx;
@@ -113,8 +112,7 @@
     {
       FPRINTF (stderr, "Scheduling abort task for error on `%s'\n",
                (const char *) event->value.publish.cctx);
-      GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     }
     break;
   case GNUNET_FS_STATUS_PUBLISH_START:

Modified: gnunet/src/fs/test_fs_search.c
===================================================================
--- gnunet/src/fs/test_fs_search.c      2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/test_fs_search.c      2015-08-03 09:35:48 UTC (rev 36178)
@@ -137,21 +137,18 @@
   case GNUNET_FS_STATUS_SEARCH_RESULT:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Search complete.\n");
-    GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
     FPRINTF (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
-    GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_START:
     GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
@@ -176,8 +173,7 @@
     break;
   case GNUNET_FS_STATUS_SEARCH_STOPPED:
     GNUNET_assert (search == event->value.search.sc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
     FPRINTF (stderr, "Unexpected event: %d\n", event->status);

Modified: gnunet/src/fs/test_fs_search_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_search_persistence.c  2015-08-03 09:31:58 UTC (rev 
36177)
+++ gnunet/src/fs/test_fs_search_persistence.c  2015-08-03 09:35:48 UTC (rev 
36178)
@@ -183,21 +183,18 @@
      * search result since we exit here after the first one... */
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Search complete.\n");
-    GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
     FPRINTF (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
-    GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_SUSPEND:
     if (event->value.search.sc == search)
@@ -235,8 +232,7 @@
     break;
   case GNUNET_FS_STATUS_SEARCH_STOPPED:
     GNUNET_assert (search == event->value.search.sc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     search = NULL;
     break;
   default:

Modified: gnunet/src/fs/test_fs_search_probes.c
===================================================================
--- gnunet/src/fs/test_fs_search_probes.c       2015-08-03 09:31:58 UTC (rev 
36177)
+++ gnunet/src/fs/test_fs_search_probes.c       2015-08-03 09:35:48 UTC (rev 
36178)
@@ -140,14 +140,12 @@
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
     FPRINTF (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
-    GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_START:
     GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
@@ -177,11 +175,12 @@
     break;
   case GNUNET_FS_STATUS_SEARCH_STOPPED:
     GNUNET_assert (search == event->value.search.sc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
-    FPRINTF (stderr, "Unexpected event: %d\n", event->status);
+    FPRINTF (stderr,
+             "Unexpected event: %d\n",
+             event->status);
     break;
   }
   return NULL;

Modified: gnunet/src/fs/test_fs_search_with_and.c
===================================================================
--- gnunet/src/fs/test_fs_search_with_and.c     2015-08-03 09:31:58 UTC (rev 
36177)
+++ gnunet/src/fs/test_fs_search_with_and.c     2015-08-03 09:35:48 UTC (rev 
36178)
@@ -138,7 +138,7 @@
          char *emsg = NULL;
          kuri = GNUNET_FS_uri_ksk_create ("+down_foo +down_bar", &emsg);
       GNUNET_assert (kuri != NULL);
-               
+
       start = GNUNET_TIME_absolute_get ();
       search =
           GNUNET_FS_search_start (fs, kuri, 1, GNUNET_FS_SEARCH_OPTION_NONE,
@@ -150,21 +150,18 @@
   case GNUNET_FS_STATUS_SEARCH_RESULT:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Search complete.\n");
-    GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_ERROR:
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_SEARCH_ERROR:
     FPRINTF (stderr, "Error searching file: %s\n",
              event->value.search.specifics.error.message);
-    GNUNET_SCHEDULER_add_continuation (&abort_search_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_search_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_START:
     GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
@@ -189,8 +186,7 @@
     break;
   case GNUNET_FS_STATUS_SEARCH_STOPPED:
     GNUNET_assert (search == event->value.search.sc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
     FPRINTF (stderr, "Unexpected event: %d\n", event->status);
@@ -220,7 +216,7 @@
   fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL,
                         GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
   GNUNET_assert (NULL != fs);
-  
+
   processed_files = 0;
   for(j = 0; j < NUM_FILES; j++){
    buf = GNUNET_malloc (FILESIZE);
@@ -244,8 +240,8 @@
                                 GNUNET_FS_PUBLISH_OPTION_NONE);
    GNUNET_assert (publish != NULL);
   }
-  
-  
+
+
   timeout_task = GNUNET_SCHEDULER_add_delayed (LIFETIME,
                                               &abort_error, NULL);
 }

Modified: gnunet/src/fs/test_fs_test_lib.c
===================================================================
--- gnunet/src/fs/test_fs_test_lib.c    2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/test_fs_test_lib.c    2015-08-03 09:35:48 UTC (rev 36178)
@@ -44,15 +44,20 @@
 
 static struct GNUNET_TESTBED_Peer *the_peers[NUM_DAEMONS];
 
+static struct GNUNET_TIME_Absolute start_time;
+
 static int ret;
 
 
 static void
-do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_stop (void *cls,
+         const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   char *fn = cls;
 
-  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+  if (0 ==
+      GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time,
+                                                                    
TIMEOUT)).rel_value_us)
   {
     GNUNET_break (0);
     ret = 1;
@@ -59,7 +64,8 @@
   }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Finished download, shutting down\n",
                 (unsigned long long) FILESIZE);
   }
   if (NULL != fn)
@@ -72,7 +78,8 @@
 
 
 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)
@@ -82,9 +89,15 @@
     ret = 1;
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
+  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,
+  start_time = GNUNET_TIME_absolute_get ();
+  GNUNET_FS_TEST_download (the_peers[0],
+                           TIMEOUT, 1, SEED,
+                           uri,
+                           VERBOSE,
+                           &do_stop,
                            (NULL == fn) ? NULL : GNUNET_strdup (fn));
 }
 

Modified: gnunet/src/fs/test_fs_unindex.c
===================================================================
--- gnunet/src/fs/test_fs_unindex.c     2015-08-03 09:31:58 UTC (rev 36177)
+++ gnunet/src/fs/test_fs_unindex.c     2015-08-03 09:35:48 UTC (rev 36178)
@@ -108,8 +108,7 @@
                                   (1 +
                                    GNUNET_TIME_absolute_get_duration
                                    (start).rel_value_us) / 1024));
-    GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL);
     break;
   case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
     GNUNET_assert (unindex == event->value.unindex.uc);
@@ -125,14 +124,12 @@
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_UNINDEX_ERROR:
     FPRINTF (stderr, "Error unindexing file: %s\n",
              event->value.unindex.specifics.error.message);
-    GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_START:
     GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
@@ -157,8 +154,7 @@
     break;
   case GNUNET_FS_STATUS_UNINDEX_STOPPED:
     GNUNET_assert (unindex == event->value.unindex.uc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
     printf ("Unexpected event: %d\n", event->status);

Modified: gnunet/src/fs/test_fs_unindex_persistence.c
===================================================================
--- gnunet/src/fs/test_fs_unindex_persistence.c 2015-08-03 09:31:58 UTC (rev 
36177)
+++ gnunet/src/fs/test_fs_unindex_persistence.c 2015-08-03 09:35:48 UTC (rev 
36178)
@@ -150,8 +150,7 @@
                                   (1 +
                                    GNUNET_TIME_absolute_get_duration
                                    (start).rel_value_us) / 1024));
-    GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL);
     break;
   case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
     consider_restart (event->status);
@@ -187,15 +186,13 @@
     FPRINTF (stderr, "Error publishing file: %s\n",
              event->value.publish.specifics.error.message);
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   case GNUNET_FS_STATUS_UNINDEX_ERROR:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Error unindexing file: %s\n",
                event->value.unindex.specifics.error.message);
-    GNUNET_SCHEDULER_add_continuation (&abort_unindex_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_unindex_task, NULL);
     break;
   case GNUNET_FS_STATUS_PUBLISH_START:
     GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
@@ -221,8 +218,7 @@
     break;
   case GNUNET_FS_STATUS_UNINDEX_STOPPED:
     GNUNET_assert (unindex == event->value.unindex.uc);
-    GNUNET_SCHEDULER_add_continuation (&abort_publish_task, NULL,
-                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+    GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL);
     break;
   default:
     printf ("Unexpected event: %d\n", event->status);

Modified: gnunet/src/fs/test_gnunet_service_fs_migration.c
===================================================================
--- gnunet/src/fs/test_gnunet_service_fs_migration.c    2015-08-03 09:31:58 UTC 
(rev 36177)
+++ gnunet/src/fs/test_gnunet_service_fs_migration.c    2015-08-03 09:35:48 UTC 
(rev 36178)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2010, 2012 Christian Grothoff (and other contributing 
authors)
+     Copyright (C) 2010, 2012, 2015 Christian Grothoff (and other contributing 
authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -64,14 +64,23 @@
 
 
 static void
-do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_stop (void *cls,
+         const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_TIME_Relative del;
   char *fancy;
 
   GNUNET_SCHEDULER_shutdown ();
-  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
+  if (0 ==
+      GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time,
+                                                                    
TIMEOUT)).rel_value_us)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Timeout during download, shutting down with error\n");
+    ok = 1;
+  }
+  else
+  {
     del = GNUNET_TIME_absolute_get_duration (start_time);
     if (del.rel_value_us == 0)
       del.rel_value_us = 1;
@@ -78,17 +87,14 @@
     fancy =
         GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
                                         1000000LL / del.rel_value_us);
-    FPRINTF (stdout, "Download speed was %s/s\n", fancy);
+    FPRINTF (stdout,
+             "Download speed was %s/s\n",
+             fancy);
     GNUNET_free (fancy);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Finished download, shutting down\n",
                 (unsigned long long) FILESIZE);
   }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Timeout during download, shutting down with error\n");
-    ok = 1;
-  }
 }
 
 
@@ -110,16 +116,24 @@
   if (NULL != emsg)
   {
     GNUNET_SCHEDULER_shutdown ();
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Failed to stop source daemon: %s\n",
                 emsg);
     GNUNET_FS_uri_destroy (uri);
     ok = 1;
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Downloading %llu bytes\n",
               (unsigned long long) FILESIZE);
   start_time = GNUNET_TIME_absolute_get ();
-  GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, 
&do_stop,
+  GNUNET_FS_TEST_download (daemons[0],
+                           TIMEOUT,
+                           1,
+                           SEED,
+                           uri,
+                           VERBOSE,
+                           &do_stop,
                            NULL);
   GNUNET_FS_uri_destroy (uri);
 }
@@ -126,11 +140,13 @@
 
 
 static void
-stop_source_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+stop_source_peer (void *cls,
+                  const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct DownloadContext *dc = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping source peer\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Stopping source peer\n");
   op = GNUNET_TESTBED_peer_stop (NULL, daemons[1], &do_download, dc);
   GNUNET_assert (NULL != op);
 }
@@ -137,7 +153,8 @@
 
 
 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 DownloadContext *dc;
@@ -150,7 +167,8 @@
     ok = 1;
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to 
migrate\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Waiting to allow content to migrate\n");
   dc = GNUNET_new (struct DownloadContext);
   dc->uri = GNUNET_FS_uri_dup (uri);
   if (NULL != fn)
@@ -172,7 +190,8 @@
   GNUNET_assert (2 == num_peers);
   for (i=0;i<num_peers;i++)
     daemons[i] = peers[i];
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing %llu bytes\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Publishing %llu bytes\n",
               (unsigned long long) FILESIZE);
   GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED,
                           VERBOSE, &do_wait, NULL);
@@ -180,7 +199,8 @@
 
 
 int
-main (int argc, char *argv[])
+main (int argc,
+      char *argv[])
 {
   (void) GNUNET_TESTBED_test_run ("test-gnunet-service-fs-migration",
                                   "fs_test_lib_data.conf",

Modified: gnunet/src/fs/test_gnunet_service_fs_p2p.c
===================================================================
--- gnunet/src/fs/test_gnunet_service_fs_p2p.c  2015-08-03 09:31:58 UTC (rev 
36177)
+++ gnunet/src/fs/test_gnunet_service_fs_p2p.c  2015-08-03 09:35:48 UTC (rev 
36178)
@@ -61,25 +61,30 @@
   char *fancy;
 
   GNUNET_SCHEDULER_shutdown ();
-  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
+  if (0 ==
+      GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_add (start_time,
+                                                                    
TIMEOUT)).rel_value_us)
   {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Timeout during download, shutting down with error\n");
+    ok = 1;
+  }
+  else
+  {
     del = GNUNET_TIME_absolute_get_duration (start_time);
-    if (del.rel_value_us == 0)
+    if (0 == del.rel_value_us)
       del.rel_value_us = 1;
     fancy =
       GNUNET_STRINGS_byte_size_fancy (((unsigned long long) FILESIZE) *
                                      1000000LL / del.rel_value_us);
-    FPRINTF (stdout, "Download speed was %s/s\n", fancy);
+    FPRINTF (stdout,
+             "Download speed was %s/s\n",
+             fancy);
     GNUNET_free (fancy);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Finished download, shutting down\n",
                 (unsigned long long) FILESIZE);
   }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Timeout during download, shutting down with error\n");
-    ok = 1;
-  }
   if (NULL != fn)
   {
     GNUNET_DISK_directory_remove (fn);




reply via email to

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