bugfixes and redesigning scheduler API
authorChristian Grothoff <christian@grothoff.org>
Wed, 4 Nov 2009 14:10:32 +0000 (14:10 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 4 Nov 2009 14:10:32 +0000 (14:10 +0000)
64 files changed:
BUGS
src/arm/gnunet-arm.c
src/arm/gnunet-service-arm.c
src/core/core_api.c
src/core/gnunet-service-core.c
src/core/test_core_api.c
src/core/test_core_api_start_only.c
src/datastore/gnunet-service-datastore.c
src/datastore/perf_datastore_api.c
src/datastore/perf_plugin_datastore.c
src/datastore/plugin_datastore_sqlite.c
src/datastore/test_datastore_api.c
src/datastore/test_datastore_api_management.c
src/fs/fs_download.c
src/fs/fs_list_indexed.c
src/fs/fs_publish.c
src/fs/fs_search.c
src/fs/fs_tree.c
src/fs/fs_unindex.c
src/fs/gnunet-service-fs.c
src/fs/test_fs_download.c
src/fs/test_fs_list_indexed.c
src/fs/test_fs_publish.c
src/fs/test_fs_search.c
src/fs/test_fs_unindex.c
src/hostlist/gnunet-daemon-hostlist.c
src/hostlist/hostlist-client.c
src/hostlist/hostlist-server.c
src/hostlist/test_gnunet_daemon_hostlist.c
src/include/gnunet_crypto_lib.h
src/include/gnunet_scheduler_lib.h
src/include/gnunet_service_lib.h
src/nat/nat.c
src/nat/test_nat.c
src/peerinfo/gnunet-service-peerinfo.c
src/peerinfo/test_peerinfo_api.c
src/statistics/gnunet-service-statistics.c
src/template/gnunet-service-template.c
src/testing/testing.c
src/topology/gnunet-daemon-topology.c
src/topology/test_gnunet_service_topology.c
src/transport/gnunet-service-transport.c
src/transport/plugin_transport_tcp.c
src/transport/test_plugin_transport.c
src/transport/transport_api.c
src/util/client.c
src/util/connection.c
src/util/crypto_hash.c
src/util/disk.c
src/util/gnunet-service-resolver.c
src/util/resolver_api.c
src/util/scheduler.c
src/util/server.c
src/util/service.c
src/util/test_connection.c
src/util/test_connection_addressing.c
src/util/test_connection_receive_cancel.c
src/util/test_crypto_hash.c
src/util/test_scheduler.c
src/util/test_scheduler_delay.c
src/util/test_server.c
src/util/test_server_disconnect.c
src/util/test_server_with_client.c
src/util/test_service.c

diff --git a/BUGS b/BUGS
index f2af532411898a90edd03da62e084ae63628995e..504ff2c210bcce518db16646d15c9d4b3559a35e 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -2,6 +2,10 @@ This file lists minor work items (also possibly called "known bugs").
 We are not tracking them in Mantis yet since there are too many and no
 sane end-user should care about this codebase yet anyway.
 
+* TESTING:
+  - connection.c:553 fails when "make check" is run!
+    (check if this could be memory corruption).
+
 
 * UTIL:
   - container_bloomfilter: improve efficiency (see FIXME)
index 09a1305a5713995d550669e0a1bae5131fb3ec05..d0748f173000d626af4e01b389b25582bab04bbd 100644 (file)
@@ -123,7 +123,6 @@ confirm_cb (void *cls, int success)
       break;
     }
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -147,7 +146,6 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   else
     fprintf (stdout, _("Service `%s' is not running.\n"), service);
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -181,7 +179,6 @@ run (void *cls,
       return;
     }
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index ebb9c337e9fc899de4c3eb125a4c21d880975f6e..bfb3896bf99123f29f173ed8266f670e2fff2c91 100644 (file)
@@ -516,9 +516,6 @@ stop_service (struct GNUNET_SERVER_Client *client,
       pos->kill_continuation_cls = client;
       GNUNET_SERVER_client_keep (client);
       GNUNET_SCHEDULER_add_delayed (sched,
-                                   GNUNET_YES,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    MAINT_FAST_FREQUENCY, &maint, NULL);
     }
   else
@@ -641,9 +638,6 @@ maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     }
   if (cls == NULL)
     GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                 GNUNET_YES,
-                                 GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                 GNUNET_SCHEDULER_NO_TASK,
                                  MAINT_FREQUENCY, &maint, NULL);
 
   /* check for services that died (WAITPID) */
@@ -800,11 +794,9 @@ run (void *cls,
   GNUNET_SERVER_add_handlers (server, handlers);
 
   /* manage services */
-  GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
-                                MAINT_FREQUENCY, &maint, NULL);
+  GNUNET_SCHEDULER_add_with_priority (sched,
+                                     GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                     &maint, NULL);
 }
 
 
@@ -820,7 +812,7 @@ main (int argc, char *const *argv)
 {
   return (GNUNET_OK ==
           GNUNET_SERVICE_run (argc,
-                              argv, "arm", &run, NULL, NULL, NULL)) ? 0 : 1;
+                              argv, "arm", &run, NULL)) ? 0 : 1;
 }
 
 /* end of gnunet-service-arm.c */
index 1a74eb7d00e1ede7e83dfe7597ac03dfc8798623..91055dd03636634633bb82497925bcdbd1d2a06c 100644 (file)
@@ -320,9 +320,6 @@ request_start (void *cls, size_t size, void *buf)
     }
   /* create new timeout task (in case core takes too long to respond!) */
   th->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                                   GNUNET_NO,
-                                                   GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                   GNUNET_SCHEDULER_NO_TASK,
                                                    GNUNET_TIME_absolute_get_remaining
                                                    (th->timeout),
                                                    &timeout_request, th);
@@ -748,9 +745,7 @@ transmit_start (void *cls, size_t size, void *buf)
             h->startup_timeout =
               GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
           h->reconnect_task =
-            GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO,
-                                          GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                          GNUNET_SCHEDULER_NO_TASK,
+            GNUNET_SCHEDULER_add_delayed (h->sched, 
                                           delay, &reconnect_task, h);
           return 0;
         }
@@ -990,9 +985,6 @@ GNUNET_CORE_peer_configure (struct GNUNET_CORE_Handle *handle,
   th->info_cls = info_cls;
   th->timeout = GNUNET_TIME_relative_to_absolute (timeout);
   th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched,
-                                                   GNUNET_NO,
-                                                   GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                   GNUNET_SCHEDULER_NO_TASK,
                                                    timeout,
                                                    &timeout_request, th);
   th->msize = sizeof (struct RequestConfigureMessage);
@@ -1112,9 +1104,6 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
   th->peer = *target;
   th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay);
   th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched,
-                                                   GNUNET_NO,
-                                                   GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                   GNUNET_SCHEDULER_NO_TASK,
                                                    maxdelay,
                                                    &timeout_request, th);
   th->priority = priority;
index 1d272b873188a1484a3384e0c75da24948482d8f..839eb2727f3502fdd180670bcb47a43aaf6b7472 100644 (file)
@@ -1703,9 +1703,6 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
       /* no messages selected for sending, try again later... */
       n->retry_plaintext_task =
         GNUNET_SCHEDULER_add_delayed (sched,
-                                      GNUNET_NO,
-                                      GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                      GNUNET_SCHEDULER_NO_TASK,
                                       retry_time,
                                       &retry_plaintext_processing, n);
       return;
@@ -2154,9 +2151,6 @@ send_key (struct Neighbour *n)
   if (n->status != PEER_STATE_KEY_CONFIRMED)
     n->retry_set_key_task
       = GNUNET_SCHEDULER_add_delayed (sched,
-                                      GNUNET_NO,
-                                      GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                      GNUNET_SCHEDULER_NO_TASK,
                                       n->set_key_retry_frequency,
                                       &set_key_retry_task, n);
 }
@@ -2894,9 +2888,6 @@ schedule_quota_update (struct Neighbour *n)
                 GNUNET_SCHEDULER_NO_TASK);
   n->quota_update_task
     = GNUNET_SCHEDULER_add_delayed (sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    QUOTA_UPDATE_FREQUENCY,
                                    &neighbour_quota_update,
                                    n);
@@ -3114,6 +3105,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     }
   while (NULL != (c = clients))
     handle_client_disconnect (NULL, c->client_handle);
+  if (my_private_key != NULL)
+    GNUNET_CRYPTO_rsa_key_free (my_private_key);
 }
 
 
@@ -3198,9 +3191,6 @@ run (void *cls,
                                         &handle_transport_notify_disconnect);
   GNUNET_assert (NULL != transport);
   GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &cleaning_task, NULL);
   /* process client requests */
@@ -3210,17 +3200,6 @@ run (void *cls,
 }
 
 
-/**
- * Function called during shutdown.  Clean up our state.
- */
-static void
-cleanup (void *cls, 
-        const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-  if (my_private_key != NULL)
-    GNUNET_CRYPTO_rsa_key_free (my_private_key);
-}
-
 
 /**
  * The main function for the transport service.
@@ -3235,7 +3214,7 @@ main (int argc, char *const *argv)
   return (GNUNET_OK ==
           GNUNET_SERVICE_run (argc,
                               argv,
-                              "core", &run, NULL, &cleanup, NULL)) ? 0 : 1;
+                              "core", &run, NULL)) ? 0 : 1;
 }
 
 /* end of gnunet-service-core.c */
index 89aa34f5b99c284be72f6117a380ab56adc13a28..ebd4e8e993b6fef9f7dd9c64bcf71e781bcf725d 100644 (file)
@@ -172,9 +172,6 @@ process_mtype (void *cls,
   OKPP;
   GNUNET_SCHEDULER_cancel (sched, err_task);
   GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_ZERO, &terminate_task, NULL);
   return GNUNET_OK;
 }
@@ -201,9 +198,6 @@ transmit_ready (void *cls, size_t size, void *buf)
   m->size = htons (sizeof (struct GNUNET_MessageHeader));
   err_task = 
     GNUNET_SCHEDULER_add_delayed (sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                 GNUNET_SCHEDULER_NO_TASK,
                                  GNUNET_TIME_UNIT_MINUTES, &terminate_task_error, NULL);
 
   return sizeof (struct GNUNET_MessageHeader);
@@ -300,7 +294,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
                                         "-L", "DEBUG",
 #endif
                                         "-c", cfgname, NULL);
-  sleep (1);                    /* allow ARM to start */
 #endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
index ce2668b893851f8774cd4049a475491931cd10e9..5ca750664b9175edc221e675544ccf3ad635de56 100644 (file)
@@ -166,7 +166,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
                                         "-L", "DEBUG",
 #endif
                                         "-c", cfgname, NULL);
-  sleep (1);                    /* allow ARM to start */
 #endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
index 3a22f9bdaa606f57462c75a491f5e9595660470d..27b1cd58e2ec7420eb82498645205a61bbed52d6 100644 (file)
@@ -260,9 +260,6 @@ expired_processor (void *cls,
     {
       expired_kill_task 
        = GNUNET_SCHEDULER_add_delayed (sched,
-                                       GNUNET_NO,
-                                       GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                       GNUNET_SCHEDULER_NO_TASK,
                                        MAX_EXPIRE_DELAY,
                                        &delete_expired,
                                        NULL);
@@ -1209,7 +1206,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       GNUNET_CONTAINER_bloomfilter_free (filter);
       filter = NULL;
     }
//  GNUNET_ARM_stop_services (cfg, tc->sched, "statistics", NULL);
+  GNUNET_ARM_stop_services (cfg, tc->sched, "statistics", NULL);
 }
 
 
@@ -1307,28 +1304,22 @@ run (void *cls,
                  _("Failed to initialize bloomfilter.\n"));
       return;
     }
-//  GNUNET_ARM_start_services (cfg, sched, "statistics", NULL);
+  GNUNET_ARM_start_services (cfg, sched, "statistics", NULL);
   plugin = load_plugin ();
   if (NULL == plugin)
     {
       GNUNET_CONTAINER_bloomfilter_free (filter);
       filter = NULL;
-//      GNUNET_ARM_stop_services (cfg, sched, "statistics", NULL);
+      GNUNET_ARM_stop_services (cfg, sched, "statistics", NULL);
       return;
     }
   GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL);
   GNUNET_SERVER_add_handlers (server, handlers);
   expired_kill_task
-    = GNUNET_SCHEDULER_add_delayed (sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                   GNUNET_SCHEDULER_NO_TASK,
-                                   GNUNET_TIME_UNIT_ZERO,
-                                   &delete_expired, NULL);
+    = GNUNET_SCHEDULER_add_with_priority (sched,
+                                         GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                         &delete_expired, NULL);
   GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &cleaning_task, NULL);
   
@@ -1350,7 +1341,7 @@ main (int argc, char *const *argv)
   ret = (GNUNET_OK ==
          GNUNET_SERVICE_run (argc,
                              argv,
-                             "datastore", &run, NULL, NULL, NULL)) ? 0 : 1;
+                             "datastore", &run, NULL)) ? 0 : 1;
   return ret;
 }
 
index 2344dafe89e23d28438c6aef3fd5f0e38ebfce66..34adf0c7d30c576fbf04197365a6cdb348ec9fe9 100644 (file)
@@ -140,7 +140,6 @@ check_success (void *cls,
        crc->phase = RP_CUT;
     }
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -167,7 +166,6 @@ remove_next(void *cls,
 #endif
   GNUNET_assert (GNUNET_OK == success);
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -214,18 +212,15 @@ delete_value (void *cls,
        {
          crc->phase = RP_REPORT;
          GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                            GNUNET_NO,
                                             &run_continuation,
                                             crc,
                                             GNUNET_SCHEDULER_REASON_PREREQ_DONE);
          return;     
        }
-      GNUNET_SCHEDULER_add_after (crc->sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                 GNUNET_SCHEDULER_NO_TASK,
-                                 &do_delete,
-                                 crc);
+      GNUNET_SCHEDULER_add_with_priority (crc->sched,
+                                         GNUNET_SCHEDULER_PRIORITY_HIGH,
+                                         &do_delete,
+                                         crc);
       return;
     }
   stored_ops++;
@@ -303,7 +298,6 @@ run_continuation (void *cls,
       crc->phase = RP_PUT;
       crc->j = 0;
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -335,7 +329,6 @@ run (void *cls,
   crc->cfg = cfg;
   crc->phase = RP_PUT;
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -364,7 +357,6 @@ check ()
                                  "-L", "DEBUG",
 #endif
                                  "-c", "test_datastore_api_data.conf", NULL);
-  sleep (1);
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, "perf-datastore-api", "nohelp",
                       options, &run, NULL);
index b7bc9db31893f9834274edd34892d62527fe6a83..a23569875c04b555975f3e0530fe62f14f6145eb 100644 (file)
@@ -168,8 +168,6 @@ iterateDummy (void *cls,
            crc->phase = RP_PUT;
        }
       GNUNET_SCHEDULER_add_after (crc->sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
                                  GNUNET_SCHEDULER_NO_TASK,
                                  &test, crc);
       return GNUNET_OK;
@@ -254,8 +252,6 @@ test (void *cls,
       crc->i++;
       crc->phase = RP_LP_GET;
       GNUNET_SCHEDULER_add_after (crc->sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
                                  GNUNET_SCHEDULER_NO_TASK,
                                  &test, crc);
       break;
@@ -301,11 +297,8 @@ test (void *cls,
       break;
     case RP_DONE:
       crc->api->drop (crc->api->cls);
-      GNUNET_SCHEDULER_add_delayed (crc->sched,
-                                   GNUNET_YES,
+      GNUNET_SCHEDULER_add_with_priority (crc->sched,
                                    GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                   GNUNET_SCHEDULER_NO_TASK,
-                                   GNUNET_TIME_UNIT_ZERO,
                                    &cleaning_task, crc);
       break;
     }
@@ -364,8 +357,6 @@ run (void *cls,
   crc->cfg = c;
   crc->phase = RP_PUT;
   GNUNET_SCHEDULER_add_after (s,
-                             GNUNET_YES,
-                             GNUNET_SCHEDULER_PRIORITY_KEEP,
                              GNUNET_SCHEDULER_NO_TASK,
                              &test, crc);
 }
index e673bafa47eaefe289683daf62b60a9ba6fd504c..1607ba5e000d450acf263293a17f5b3682908477 100644 (file)
@@ -663,7 +663,6 @@ sqlite_next_request (void *next_cls,
   if (GNUNET_YES == end_it)
     nc->end_it = GNUNET_YES;
   GNUNET_SCHEDULER_add_continuation (nc->plugin->env->sched,
-                                    GNUNET_NO,
                                     &sqlite_next_request_cont,
                                     nc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index 605cb042d9f57b5f0d1d3ac7d03865e08536c9d9..5d4443cbedee63550d0026f0011d0e5345cb43d3 100644 (file)
@@ -145,7 +145,6 @@ check_success (void *cls,
   GNUNET_free_non_null (crc->data);
   crc->data = NULL;
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -164,7 +163,6 @@ get_reserved (void *cls,
   GNUNET_assert (0 < success);
   crc->rid = success;
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -193,7 +191,6 @@ check_value (void *cls,
          crc->i = ITERATIONS;
        }
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -226,7 +223,6 @@ delete_value (void *cls,
     {
       crc->phase = RP_DO_DEL;
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -259,7 +255,6 @@ check_nothing (void *cls,
       crc->phase = RP_RESERVE;   
     }
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -284,7 +279,6 @@ check_multiple (void *cls,
       GNUNET_assert (crc->phase == RP_GET_MULTIPLE_DONE);
       crc->phase = RP_UPDATE;
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -315,7 +309,6 @@ check_update (void *cls,
       GNUNET_assert (crc->phase == RP_UPDATE_DONE);
       crc->phase = RP_DONE;
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -542,7 +535,6 @@ run (void *cls,
   now = GNUNET_TIME_absolute_get ();
   datastore = GNUNET_DATASTORE_connect (cfg, sched);
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -572,7 +564,6 @@ check ()
                                  "-L", "DEBUG",
 #endif
                                  "-c", "test_datastore_api_data.conf", NULL);
-  sleep (1);
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, "test-datastore-api", "nohelp",
                       options, &run, NULL);
index 48daebb1df48b696801d9855211c92fd5723f029..cad789a6f8eea337967c1b0656811d3a5ded6029 100644 (file)
@@ -133,7 +133,6 @@ check_success (void *cls,
   GNUNET_free_non_null (crc->data);
   crc->data = NULL;
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -171,7 +170,6 @@ check_value (void *cls,
       if (0 == crc->i)
        crc->phase = RP_DONE;
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -206,7 +204,6 @@ check_nothing (void *cls,
   if (0 == --crc->i)
     crc->phase = RP_DONE;
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -310,7 +307,6 @@ run (void *cls,
   now = GNUNET_TIME_absolute_get ();
   datastore = GNUNET_DATASTORE_connect (cfg, sched);
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -340,7 +336,6 @@ check ()
                                  "-L", "DEBUG",
 #endif
                                  "-c", "test_datastore_api_data.conf", NULL);
-  sleep (1);
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, "test-datastore-api", "nohelp",
                       options, &run, NULL);
index e92eb85c1a6434b97c242ba4b796ab13d21cae78..4b3d960827cdc8d75d8b96b05a77f6237a2ea6a7 100644 (file)
@@ -718,9 +718,6 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc)
     }
   dc->task
     = GNUNET_SCHEDULER_add_delayed (dc->h->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_UNIT_SECONDS,
                                    &do_reconnect,
                                    dc);
index 9ef205ca0269553a4466be870b93d58edd603686..d182f9aa457e1417cb87da94696be4b00a66e404 100644 (file)
@@ -91,7 +91,6 @@ handle_index_info (void *cls,
                  "GET_INDEXED",
                  "fs");
       GNUNET_SCHEDULER_add_continuation (gic->h->sched,
-                                        GNUNET_NO,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -103,7 +102,6 @@ handle_index_info (void *cls,
     {
       /* normal end-of-list */
       GNUNET_SCHEDULER_add_continuation (gic->h->sched,
-                                        GNUNET_NO,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -124,7 +122,6 @@ handle_index_info (void *cls,
                  "GET_INDEXED",
                  "fs");
       GNUNET_SCHEDULER_add_continuation (gic->h->sched,
-                                        GNUNET_NO,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -138,7 +135,6 @@ handle_index_info (void *cls,
                     &iim->file_id))
     {
       GNUNET_SCHEDULER_add_continuation (gic->h->sched,
-                                        GNUNET_NO,
                                         gic->cont,
                                         gic->cont_cls,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -185,7 +181,6 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h,
                  _("Failed to not connect to `%s' service.\n"),
                  "fs");
       GNUNET_SCHEDULER_add_continuation (h->sched,
-                                        GNUNET_NO,
                                         cont,
                                         cont_cls,
                                         GNUNET_SCHEDULER_REASON_TIMEOUT);
index 721951970ef59f84a9365cb8b538e9960cdd9b12..bef03a45e9156b3f89fc9e492006ea3feafe5750 100644 (file)
@@ -185,13 +185,10 @@ ds_put_cont (void *cls,
   GNUNET_FS_file_information_sync (pcc->p);
   if (NULL != pcc->cont)
     pcc->sc->upload_task 
-      = GNUNET_SCHEDULER_add_delayed (pcc->sc->h->sched,
-                                     GNUNET_NO,
-                                     GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-                                     GNUNET_SCHEDULER_NO_TASK,
-                                     GNUNET_TIME_UNIT_ZERO,
-                                     pcc->cont,
-                                     pcc->cont_cls);
+      = GNUNET_SCHEDULER_add_with_priority (pcc->sc->h->sched,
+                                           GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
+                                           pcc->cont,
+                                           pcc->cont_cls);
   GNUNET_free (pcc);
 }
 
@@ -325,13 +322,10 @@ publish_kblocks_cont (void *cls,
     {
       signal_publish_error (p, sc, emsg);
       sc->upload_task 
-       = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
-                                       GNUNET_NO,
-                                       GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-                                       GNUNET_SCHEDULER_NO_TASK,
-                                       GNUNET_TIME_UNIT_ZERO,
-                                       &do_upload,
-                                       sc);
+       = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
+                                             GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
+                                             &do_upload,
+                                             sc);
       return;
     }
   GNUNET_FS_file_information_sync (p);
@@ -343,13 +337,10 @@ publish_kblocks_cont (void *cls,
   else
     sc->fi_pos = p->dir;
   sc->upload_task 
-    = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-                                   GNUNET_SCHEDULER_NO_TASK,
-                                   GNUNET_TIME_UNIT_ZERO,
-                                   &do_upload,
-                                   sc);
+    = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
+                                         GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
+                                         &do_upload,
+                                         sc);
 }
 
 
@@ -446,11 +437,8 @@ encode_cont (void *cls,
     }
   /* continue with main */
   sc->upload_task 
-    = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-                                   GNUNET_SCHEDULER_NO_TASK,
-                                   GNUNET_TIME_UNIT_ZERO,
+    = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
+                                         GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
                                    &do_upload,
                                    sc);
 }
@@ -486,11 +474,8 @@ block_proc (void *cls,
   if (NULL == sc->dsh)
     {
       sc->upload_task
-       = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
-                                       GNUNET_NO,
+       = GNUNET_SCHEDULER_add_with_priority (sc->h->sched,
                                        GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-                                       GNUNET_SCHEDULER_NO_TASK,
-                                       GNUNET_TIME_UNIT_ZERO,
                                        &do_upload,
                                        sc);
       return;
@@ -910,7 +895,6 @@ do_upload (void *cls,
       else
        GNUNET_CRYPTO_hash_file (sc->h->sched,
                                 GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_NO,
                                 p->data.file.filename,
                                 HASHING_BLOCKSIZE,
                                 &hash_for_index_cb,
@@ -1018,11 +1002,8 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h,
   // and reserve as first task (then trigger
   // "do_upload" from that continuation)!
   ret->upload_task 
-    = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                   GNUNET_NO,
+    = GNUNET_SCHEDULER_add_with_priority (h->sched,
                                    GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-                                   GNUNET_SCHEDULER_NO_TASK,
-                                   GNUNET_TIME_UNIT_ZERO,
                                    &do_upload,
                                    ret);
   return ret;
@@ -1217,7 +1198,6 @@ kb_put_cont (void *cls,
       return;
     }
   GNUNET_SCHEDULER_add_continuation (pkc->h->sched,
-                                    GNUNET_NO,
                                     &publish_ksk_cont,
                                     pkc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -1383,7 +1363,6 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
   pkc->cpy->purpose.purpose = htonl(GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK);
   pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
   GNUNET_SCHEDULER_add_continuation (h->sched,
-                                    GNUNET_NO,
                                     &publish_ksk_cont,
                                     pkc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index 8b986ec7cc206e092a0574a9b1e338cacdb97a23..5d03046e2e7d91d84be0b5ff361daff99f3389c7 100644 (file)
@@ -720,9 +720,6 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
     }
   sc->task
     = GNUNET_SCHEDULER_add_delayed (sc->h->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_UNIT_SECONDS,
                                    &do_reconnect,
                                    sc);
index 83da423f3c16aa6d433fbbfa52e5d4960e905e20..4d15d78f3399bb7f77aa04cbd344e1b34b3c3bef 100644 (file)
@@ -287,7 +287,6 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te)
                      &te->emsg))
        {
          GNUNET_SCHEDULER_add_continuation (te->h->sched,
-                                            GNUNET_NO,
                                             te->cont,
                                             te->cls,
                                             GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -309,7 +308,6 @@ void GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder * te)
       te->uri->data.chk.chk = te->chk_tree[0];
       te->uri->data.chk.file_length = GNUNET_htonll (te->size);
       GNUNET_SCHEDULER_add_continuation (te->h->sched,
-                                        GNUNET_NO,
                                         te->cont,
                                         te->cls,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index 0c3738753c5e19c83bff8295a561cb198f3b172b..243209b0e607e534a3b5c92390a035212838176c 100644 (file)
@@ -420,7 +420,6 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h,
               &pi);
   GNUNET_CRYPTO_hash_file (h->sched,
                           GNUNET_SCHEDULER_PRIORITY_IDLE,
-                          GNUNET_NO,
                           filename,
                           HASHING_BLOCKSIZE,
                           &process_hash,
index 5148c4675bf2fa945dfcd89ff70ea166d9385f5f..ca6b9b426c1bab003aacbbfe646b0360f790531d 100644 (file)
@@ -1075,7 +1075,6 @@ handle_index_start (void *cls,
   /* slow validation, need to hash full file (again) */
   GNUNET_CRYPTO_hash_file (sched,
                           GNUNET_SCHEDULER_PRIORITY_IDLE,
-                          GNUNET_NO,
                           fn,
                           HASHING_BLOCKSIZE,
                           &hash_for_index_val,
@@ -1287,9 +1286,6 @@ queue_ds_request (struct GNUNET_TIME_Relative deadline,
   if (deadline.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
     return e;
   e->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                         GNUNET_NO,
-                                         GNUNET_SCHEDULER_PRIORITY_BACKGROUND,
-                                         GNUNET_SCHEDULER_NO_TASK,
                                          deadline,
                                          &timeout_ds_request,
                                          e);
@@ -1718,13 +1714,10 @@ transmit_request_cb (void *cls,
   if (NULL == buf)
     {
       /* timeout, try another peer immediately again */
-      pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                              GNUNET_NO,
-                                              GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                              GNUNET_SCHEDULER_NO_TASK,
-                                              GNUNET_TIME_UNIT_ZERO,
-                                              &forward_request_task,
-                                              pr);
+      pr->task = GNUNET_SCHEDULER_add_with_priority (sched,
+                                                    GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                                    &forward_request_task,
+                                                    pr);
       return 0;
     }
   /* (2) build query message */
@@ -1751,9 +1744,6 @@ transmit_request_cb (void *cls,
   
   /* (3) schedule job to do it again (or another peer, etc.) */
   pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                          GNUNET_NO,
-                                          GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                          GNUNET_SCHEDULER_NO_TASK,
                                           get_processing_delay (), // FIXME!
                                           &forward_request_task,
                                           pr);
@@ -1797,9 +1787,6 @@ target_reservation_cb (void *cls,
     {
       /* try again later; FIXME: we may need to un-reserve "amount"? */
       pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                              GNUNET_NO,
-                                              GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                              GNUNET_SCHEDULER_NO_TASK,
                                               get_processing_delay (), // FIXME: longer?
                                               &forward_request_task,
                                               pr);
@@ -1821,9 +1808,6 @@ target_reservation_cb (void *cls,
     {
       /* try again later */
       pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                              GNUNET_NO,
-                                              GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                              GNUNET_SCHEDULER_NO_TASK,
                                               get_processing_delay (), // FIXME: longer?
                                               &forward_request_task,
                                               pr);
@@ -1854,9 +1838,6 @@ forward_request_task (void *cls,
     {
       /* we're busy transmitting a result, wait a bit */
       pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                              GNUNET_NO,
-                                              GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                              GNUNET_SCHEDULER_NO_TASK,
                                               get_processing_delay (), 
                                               &forward_request_task,
                                               pr);
@@ -1872,9 +1853,6 @@ forward_request_task (void *cls,
     {
       /* no possible target found, wait some time */
       pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                              GNUNET_NO,
-                                              GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                              GNUNET_SCHEDULER_NO_TASK,
                                               get_processing_delay (), // FIXME: exponential back-off? or at least wait longer...
                                               &forward_request_task,
                                               pr);
@@ -1998,9 +1976,6 @@ process_local_get_result (void *cls,
                                             pr,
                                             GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
          pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                                  GNUNET_NO,
-                                                  GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                  GNUNET_SCHEDULER_NO_TASK,
                                                   get_processing_delay (),
                                                   &forward_request_task,
                                                   pr);
@@ -2132,7 +2107,6 @@ transmit_local_get_ready (void *cls,
 
   GNUNET_assert (GNUNET_OK == ok);
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &transmit_local_get,
                                     lgc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -2514,9 +2488,6 @@ forward_get_request (void *cls,
       destroy_pending_request (eer);     
     }
   pr->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                          GNUNET_NO,
-                                          GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                          GNUNET_SCHEDULER_NO_TASK,
                                           get_processing_delay (),
                                           &forward_request_task,
                                           pr);
@@ -2617,7 +2588,6 @@ process_p2p_get_result (void *cls,
             (pgc->type == GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK) ) )
        {
          GNUNET_SCHEDULER_add_continuation (sched,
-                                            GNUNET_NO,
                                             &forward_get_request,
                                             pgc,
                                             GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -2942,7 +2912,6 @@ handle_p2p_get (void *cls,
                                 pgc);
   else
     GNUNET_SCHEDULER_add_continuation (sched,
-                                      GNUNET_NO,
                                       &forward_get_request,
                                       pgc,
                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -3338,9 +3307,6 @@ core_start_cb (void *cls,
   if (server == NULL)
     {
       GNUNET_SCHEDULER_add_delayed (sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_UNIT_SECONDS,
                                    &core_connect_task,
                                    NULL);
@@ -3412,9 +3378,6 @@ run (void *cls,
   GNUNET_SERVER_add_handlers (server, handlers);
   core_connect_task (NULL, NULL);
   GNUNET_SCHEDULER_add_delayed (sched,
-                               GNUNET_YES,
-                               GNUNET_SCHEDULER_PRIORITY_IDLE,
-                               GNUNET_SCHEDULER_NO_TASK,
                                GNUNET_TIME_UNIT_FOREVER_REL,
                                &shutdown_task,
                                NULL);
@@ -3434,7 +3397,7 @@ main (int argc, char *const *argv)
   return (GNUNET_OK ==
           GNUNET_SERVICE_run (argc,
                               argv,
-                              "fs", &run, NULL, NULL, NULL)) ? 0 : 1;
+                              "fs", &run, NULL)) ? 0 : 1;
 }
 
 /* end of gnunet-service-fs.c */
index 04cd3e5d8e3f9655a9af40c69cecfafbc004cf7b..4e73ef18292845d66c6ea1b61b4096d1d319123a 100644 (file)
@@ -29,7 +29,7 @@
 #include "gnunet_arm_service.h"
 #include "gnunet_fs_service.h"
 
-#define VERBOSE GNUNET_NO
+#define VERBOSE GNUNET_YES
 
 #define START_ARM GNUNET_YES
 
@@ -133,7 +133,6 @@ progress_cb (void *cls,
       printf ("Download complete,  %llu kbps.\n",
              (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_download_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -154,7 +153,6 @@ progress_cb (void *cls,
               event->value.publish.specifics.error.message);
       GNUNET_break (0);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_publish_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -164,7 +162,6 @@ progress_cb (void *cls,
               "Error downloading file: %s\n",
               event->value.download.specifics.error.message);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_download_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -196,7 +193,6 @@ progress_cb (void *cls,
     case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
       GNUNET_assert (download == event->value.download.dc);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_publish_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index 868c9d71ad5f2ba4094b596da430cd0870b0f30c..f9225e3cefeb38de9a5aa44bd1b48d2b08eac080 100644 (file)
@@ -97,7 +97,6 @@ list_indexed_task (void *cls,
 {
 
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &abort_publish_task,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -120,7 +119,6 @@ progress_cb (void *cls,
       if (0 == strcmp ("list_indexed-context-dir", 
                       event->value.publish.cctx))      
        GNUNET_SCHEDULER_add_continuation (sched,
-                                          GNUNET_NO,
                                           &list_indexed_task,
                                           NULL,
                                           GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -146,7 +144,6 @@ progress_cb (void *cls,
       if (0 == strcmp ("list_indexed-context-dir", 
                       event->value.publish.cctx))              
        GNUNET_SCHEDULER_add_continuation (sched,
-                                          GNUNET_NO,
                                           &abort_publish_task,
                                           NULL,
                                           GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index 1b79b941dd6252eabb692f9490e201ee36aa7209..a7bcd48d94e8476088fd558a10cc387eadcd82b4 100644 (file)
@@ -106,7 +106,6 @@ progress_cb (void *cls,
       if (0 == strcmp ("list_indexed-context-dir", 
                       event->value.publish.cctx))      
        GNUNET_SCHEDULER_add_continuation (sched,
-                                          GNUNET_NO,
                                           &abort_publish_task,
                                           NULL,
                                           GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -131,7 +130,6 @@ progress_cb (void *cls,
       if (0 == strcmp ("list_indexed-context-dir", 
                       event->value.publish.cctx))              
        GNUNET_SCHEDULER_add_continuation (sched,
-                                          GNUNET_NO,
                                           &abort_publish_task,
                                           NULL,
                                           GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -171,7 +169,6 @@ progress_cb (void *cls,
        {
          GNUNET_assert (publish == event->value.publish.sc);
          GNUNET_SCHEDULER_add_continuation (sched,
-                                            GNUNET_NO,
                                             &abort_publish_task,
                                             NULL,
                                             GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index d1b5f77aa331f5182d331fb6c192db2c70943792..e0961c4a799424d2d39c57d17135342971231cbb 100644 (file)
@@ -124,7 +124,6 @@ progress_cb (void *cls,
       printf ("Search complete.\n");
 #endif
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_search_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -135,7 +134,6 @@ progress_cb (void *cls,
               event->value.publish.specifics.error.message);
       GNUNET_break (0);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_publish_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -145,7 +143,6 @@ progress_cb (void *cls,
               "Error searching file: %s\n",
               event->value.search.specifics.error.message);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_search_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -174,7 +171,6 @@ progress_cb (void *cls,
     case GNUNET_FS_STATUS_SEARCH_STOPPED:
       GNUNET_assert (search == event->value.search.sc);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_publish_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index eb10c1db96a16a759e1e801990c0f7410cab1dd1..af9db740091226787fbaeedf0a7a7d1dcdde4a73 100644 (file)
@@ -121,7 +121,6 @@ progress_cb (void *cls,
       printf ("Unindex complete,  %llu kbps.\n",
              (unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_unindex_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -142,7 +141,6 @@ progress_cb (void *cls,
               event->value.publish.specifics.error.message);
       GNUNET_break (0);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_publish_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -152,7 +150,6 @@ progress_cb (void *cls,
               "Error unindexing file: %s\n",
               event->value.unindex.specifics.error.message);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_unindex_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -181,7 +178,6 @@ progress_cb (void *cls,
     case GNUNET_FS_STATUS_UNINDEX_STOPPED:
       GNUNET_assert (unindex == event->value.unindex.uc);
       GNUNET_SCHEDULER_add_continuation (sched,
-                                        GNUNET_NO,
                                         &abort_publish_task,
                                         NULL,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index 5aa4e70ea7e97f7cf7491d63ec9f2e97a989aab7..78584cac93dcc61f5ea8cd77d62d8e555edb4527 100644 (file)
@@ -177,9 +177,6 @@ run (void *cls,
                       NULL, GNUNET_NO,
                       handlers);
   GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &cleaning_task, NULL);
 }
index e0ff1f5a24b3098c488945240fe822ed19ea1958..8ef5c9895d4a49863d464801032d0a900dd57b36 100644 (file)
@@ -404,7 +404,6 @@ run_multi ()
   GNUNET_NETWORK_fdset_copy_native (gws, &ws, max);
   current_task 
     = GNUNET_SCHEDULER_add_select (sched,
-                                  GNUNET_NO,
                                   GNUNET_SCHEDULER_PRIORITY_DEFAULT,
                                   GNUNET_SCHEDULER_NO_TASK,
                                   GNUNET_TIME_UNIT_MINUTES,
@@ -549,9 +548,6 @@ schedule_hostlist_task ()
                         hostlist_delay.value,
                         GNUNET_YES);
   current_task = GNUNET_SCHEDULER_add_delayed (sched,
-                                              GNUNET_NO,
-                                              GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                              GNUNET_SCHEDULER_NO_TASK,
                                               delay,
                                               &check_task,
                                               NULL);
index 03e3c5d69dd85df8cbb09ebf2de6a9896add1e04..38e144a9d82d97c396f333c2e2cc840f46f1e83d 100644 (file)
@@ -92,9 +92,6 @@ finish_response (struct HostSet *results)
   GNUNET_free (results);
   /* schedule next update of the response */  
   GNUNET_SCHEDULER_add_delayed (sched,
-                               GNUNET_NO,
-                               GNUNET_SCHEDULER_PRIORITY_IDLE,
-                               GNUNET_SCHEDULER_NO_TASK,
                                RESPONSE_UPDATE_FREQUENCY,
                                &update_response,
                                NULL);
@@ -252,7 +249,6 @@ prepare_daemon ()
   GNUNET_NETWORK_fdset_copy_native (wes, &es, max);
   hostlist_task 
     = GNUNET_SCHEDULER_add_select (sched,
-                                  GNUNET_NO,
                                   GNUNET_SCHEDULER_PRIORITY_HIGH,
                                   GNUNET_SCHEDULER_NO_TASK,
                                   tv,
index d71340377cf15d07e9a2521ddbfbca11654a343c..ca7a2369a6f2991e50bc4ae03e6440a3c34724c4 100644 (file)
@@ -95,7 +95,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
                                         "-L", "DEBUG",
 #endif
                                         "-c", cfgname, NULL);
-  sleep (1);                    /* allow ARM to start */
 #endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
   GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
index 76d28ad574bf7cf7e122c8b399fabcf47da2a202..1dc9cb1aae92d660cd661aa362f7de85375dc369 100644 (file)
@@ -370,7 +370,6 @@ typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls,
  *
  * @param sched scheduler to use
  * @param priority scheduling priority to use
- * @param run_on_shutdown should we complete even on shutdown?
  * @param filename name of file to hash
  * @param blocksize number of bytes to process in one task
  * @param callback function to call upon completion
@@ -378,7 +377,6 @@ typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls,
  */
 void GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
                               enum GNUNET_SCHEDULER_Priority priority,
-                              int run_on_shutdown,
                               const char *filename,
                               size_t blocksize,
                               GNUNET_CRYPTO_HashCompletedCallback callback,
index 621e57fcf72b362fe62f2669940bc64b623f840f..760a674d5b03264af180c5db484e1903406230df 100644 (file)
@@ -197,21 +197,30 @@ typedef void (*GNUNET_SCHEDULER_Task) (void *cls,
 
 
 /**
- * Initialize and run scheduler.  This function will return when
- * either a shutdown was initiated (via signal) and all tasks marked
- * to "run_on_shutdown" have been completed or when all tasks in
- * general have been completed.
+ * Initialize and run scheduler.  This function will return when all
+ * tasks have completed.  On systems with signals, receiving a SIGTERM
+ * (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown"
+ * to be run after the active task is complete.  As a result, SIGTERM
+ * causes all active tasks to be scheduled with reason
+ * "GNUNET_SCHEDULER_REASON_SHUTDOWN".  (However, tasks added
+ * afterwards will execute normally!).  Note that any particular
+ * signal will only shut down one scheduler; applications should
+ * always only create a single scheduler.
  *
- * @param task task to run immediately
- * @param cls closure of task
+ * @param task task to run first (and immediately)
+ * @param task_cls closure of task
  */
-void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls);
+void GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls);
 
 
 /**
- * Request the shutdown of a scheduler.  This function can be used to
- * stop a scheduler, for example from within the signal
- * handler for signals causing shutdowns.
+ * Request the shutdown of a scheduler.  Marks all currently
+ * pending tasks as ready because of shutdown.  This will
+ * cause all tasks to run (as soon as possible, respecting
+ * priorities and prerequisite tasks).  Note that tasks
+ * scheduled AFTER this call may still be delayed arbitrarily.
+ *
+ * @param sched the scheduler
  */
 void GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched);
 
@@ -256,68 +265,70 @@ void *GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
  */
 void
 GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
-                                   int run_on_shutdown,
                                    GNUNET_SCHEDULER_Task main,
                                    void *cls,
                                    enum GNUNET_SCHEDULER_Reason reason);
 
 
 /**
- * Schedule a new task to be run after the specified
- * prerequisite task has completed.
+ * Schedule a new task to be run after the specified prerequisite task
+ * has completed. It will be run with the priority of the calling
+ * task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown?
- * @param prio how important is this task?
  * @param prerequisite_task run this task after the task with the given
  *        task identifier completes (and any of our other
  *        conditions, such as delay, read or write-readyness
  *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param main main function of the task
- * @param cls closure of task
+ *        on completion of other tasks (this will cause the task to run as
+ *        soon as possible).
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched,
-                            int run_on_shutdown,
-                            enum GNUNET_SCHEDULER_Priority prio,
                             GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
-                            GNUNET_SCHEDULER_Task main, void *cls);
+                            GNUNET_SCHEDULER_Task task,
+                           void *task_cls);
+
+
+/**
+ * Schedule a new task to be run with a specified priority.
+ *
+ * @param sched scheduler to use
+ * @param prio how important is the new task?
+ * @param task main function of the task
+ * @param task_cls closure of task
+ * @return unique task identifier for the job
+ *         only valid until "task" is started!
+ */
+GNUNET_SCHEDULER_TaskIdentifier
+GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched,
+                                   enum GNUNET_SCHEDULER_Priority prio,
+                                   GNUNET_SCHEDULER_Task task,
+                                   void *task_cls);
 
 
 /**
  * Schedule a new task to be run with a specified delay.  The task
- * will be scheduled for execution once the delay has expired and the
- * prerequisite task has completed.
+ * will be scheduled for execution once the delay has expired. It
+ * will be run with the priority of the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? You can use this
- *        argument to run a function only during shutdown
- *        by setting delay to -1.  Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
- * @param main main function of the task
- * @param cls closure of task
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
-                              int run_on_shutdown,
-                              enum GNUNET_SCHEDULER_Priority prio,
-                              GNUNET_SCHEDULER_TaskIdentifier
-                              prerequisite_task,
                               struct GNUNET_TIME_Relative delay,
-                              GNUNET_SCHEDULER_Task main, void *cls);
+                              GNUNET_SCHEDULER_Task task,
+                             void *task_cls);
 
 
 /**
@@ -325,32 +336,24 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
  * specified file descriptor is ready for reading.  The delay can be
  * used as a timeout on the socket being ready.  The task will be
  * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
+ * socket operation is ready.  It will be run with the priority of
+ * the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
  * @param rfd read file-descriptor
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
-                           int run_on_shutdown,
-                           enum GNUNET_SCHEDULER_Priority prio,
-                           GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
-                           struct GNUNET_TIME_Relative delay,
-                           struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_Task main, void *cls);
+                              struct GNUNET_TIME_Relative delay,
+                              struct GNUNET_NETWORK_Handle *rfd,
+                              GNUNET_SCHEDULER_Task task,
+                              void *task_cls);
 
 
 /**
@@ -358,32 +361,24 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
  * specified file descriptor is ready for writing.  The delay can be
  * used as a timeout on the socket being ready.  The task will be
  * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
+ * socket operation is ready.  It will be run with the priority of
+ * the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
  * @param wfd write file-descriptor
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
-                            int run_on_shutdown,
-                            enum GNUNET_SCHEDULER_Priority prio,
-                            GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
-                            struct GNUNET_TIME_Relative delay,
-                            struct GNUNET_NETWORK_Handle *wfd, GNUNET_SCHEDULER_Task main, void *cls);
+                               struct GNUNET_TIME_Relative delay,
+                               struct GNUNET_NETWORK_Handle *wfd, 
+                               GNUNET_SCHEDULER_Task task, 
+                               void *task_cls);
 
 
 /**
@@ -391,33 +386,24 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
  * specified file descriptor is ready for reading.  The delay can be
  * used as a timeout on the socket being ready.  The task will be
  * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
+ * socket operation is ready. It will be run with the priority of
+ * the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
  * @param rfd read file-descriptor
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
-                               int run_on_shutdown,
-                               enum GNUNET_SCHEDULER_Priority prio,
-                               GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
                                struct GNUNET_TIME_Relative delay,
                                const struct GNUNET_DISK_FileHandle *rfd, 
-                               GNUNET_SCHEDULER_Task main, void *cls);
+                               GNUNET_SCHEDULER_Task task,
+                               void *task_cls);
 
 
 /**
@@ -425,33 +411,24 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
  * specified file descriptor is ready for writing.  The delay can be
  * used as a timeout on the socket being ready.  The task will be
  * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
+ * socket operation is ready. It will be run with the priority of
+ * the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
  * @param wfd write file-descriptor
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
-                                int run_on_shutdown,
-                                enum GNUNET_SCHEDULER_Priority prio,
-                                GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
                                 struct GNUNET_TIME_Relative delay,
                                 const struct GNUNET_DISK_FileHandle *wfd,
-                                GNUNET_SCHEDULER_Task main, void *cls);
+                                GNUNET_SCHEDULER_Task task, 
+                                void *task_cls);
 
 
 /**
@@ -472,33 +449,31 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
  * </code>
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown?  Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
  * @param prio how important is this task?
  * @param prerequisite_task run this task after the task with the given
  *        task identifier completes (and any of our other
  *        conditions, such as delay, read or write-readyness
  *        are satisfied).  Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
  *        on completion of other tasks.
- * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever",
+ *        which means that the task will only be run after we receive SIGTERM
  * @param rs set of file descriptors we want to read (can be NULL)
  * @param ws set of file descriptors we want to write (can be NULL)
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched,
-                             int run_on_shutdown,
                              enum GNUNET_SCHEDULER_Priority prio,
                              GNUNET_SCHEDULER_TaskIdentifier
                              prerequisite_task,
                              struct GNUNET_TIME_Relative delay,
                              const struct GNUNET_NETWORK_FDSet * rs,
                             const struct GNUNET_NETWORK_FDSet * ws,
-                             GNUNET_SCHEDULER_Task main, void *cls);
+                             GNUNET_SCHEDULER_Task task, 
+                            void *task_cls);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
index 0c69d297cddca343be57b31762b96f9264454797..82089954edb497c78a6055d0edfcc93f6d1dfeee 100644 (file)
@@ -54,18 +54,6 @@ typedef void (*GNUNET_SERVICE_Main) (void *cls,
                                      cfg);
 
 
-/**
- * Function called when the service shuts
- * down to run service-specific teardown code.
- *
- * @param cls closure
- * @param cfg configuration to use
- */
-typedef void (*GNUNET_SERVICE_Term) (void *cls,
-                                     const struct GNUNET_CONFIGURATION_Handle *
-                                     cfg);
-
-
 /**
  * Run a standard GNUnet service startup sequence (initialize loggers
  * and configuration, parse options).
@@ -75,8 +63,6 @@ typedef void (*GNUNET_SERVICE_Term) (void *cls,
  * @param serviceName our service name
  * @param task main task of the service
  * @param task_cls closure for task
- * @param term termination task of the service
- * @param term_cls closure for term
  * @return GNUNET_SYSERR on error, GNUNET_OK
  *         if we shutdown nicely
  */
@@ -84,8 +70,7 @@ int GNUNET_SERVICE_run (int argc,
                         char *const *argv,
                         const char *serviceName,
                         GNUNET_SERVICE_Main task,
-                        void *task_cls,
-                        GNUNET_SERVICE_Term term, void *term_cls);
+                        void *task_cls);
 
 
 struct GNUNET_SERVICE_Context;
index 2a93d31a7b8e4a74bb1a3a085025557a2f019f00..151c526d48c3e2db3df54ca00d0d3ceabe3b503b 100644 (file)
@@ -285,9 +285,7 @@ nat_pulse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       notify_change (nat, ext_addr_natpmp, port_mapped);
     }
 
-  nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (nat->sched, GNUNET_NO,
-                                                   GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                                   GNUNET_SCHEDULER_NO_TASK,
+  nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (nat->sched, 
                                                    GNUNET_TIME_UNIT_SECONDS,
                                                    &nat_pulse, nat);
 }
@@ -335,9 +333,7 @@ GNUNET_NAT_register (struct GNUNET_SCHEDULER_Handle *sched,
   nat->natpmp = GNUNET_NAT_NATPMP_init (nat->local_addr, addrlen, nat->public_port);
   nat->upnp = GNUNET_NAT_UPNP_init (nat->local_addr, addrlen, nat->public_port);
 
-  nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO,
-                                                   GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                                   GNUNET_SCHEDULER_NO_TASK,
+  nat->pulse_timer = GNUNET_SCHEDULER_add_delayed (sched, 
                                                    GNUNET_TIME_UNIT_SECONDS,
                                                    &nat_pulse, nat);
 
index 2ff168c564e843e59fe950b7211344a725d58e2d..dc5112c368c7d346f7f0f177cf1a7b7ff292364a 100644 (file)
@@ -125,9 +125,7 @@ run (void *cls,
   nat = GNUNET_NAT_register (sched, addr, data.addrlen, addr_callback, NULL);
   GNUNET_free (addr);
 
-  GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                GNUNET_SCHEDULER_NO_TASK,
+  GNUNET_SCHEDULER_add_delayed (sched, 
                                 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, TIMEOUT),
                                 stop, nat);
 }
index 11e311c22f60d4b9ef515da62fe68395ce917af0..f5a60470e136ff4f43a5601bed15df36b18d57dd 100644 (file)
@@ -342,6 +342,8 @@ cron_scan_directory_data_hosts (void *cls,
   static unsigned int retries;
   unsigned int count;
 
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
   count = 0;
   GNUNET_DISK_directory_create (networkIdDirectory);
   GNUNET_DISK_directory_scan (networkIdDirectory,
@@ -351,9 +353,6 @@ cron_scan_directory_data_hosts (void *cls,
                 GNUNET_ERROR_TYPE_BULK,
                 _("Still no peers found in `%s'!\n"), networkIdDirectory);
   GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 DATA_HOST_FREQ,
                                 &cron_scan_directory_data_hosts, NULL);
 }
@@ -501,12 +500,10 @@ cron_flush_trust (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       flush_trust (pos);
       pos = pos->next;
     }
-  if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
-    GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                  GNUNET_YES,
-                                  GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                  GNUNET_SCHEDULER_NO_TASK,
-                                  TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
+  GNUNET_SCHEDULER_add_delayed (tc->sched,
+                               TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
 }
 
 
@@ -558,14 +555,13 @@ cron_clean_data_hosts (void *cls,
 {
   struct GNUNET_TIME_Absolute now;
 
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
   now = GNUNET_TIME_absolute_get ();
   GNUNET_DISK_directory_scan (networkIdDirectory,
                               &discard_hosts_helper, &now);
 
   GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 DATA_HOST_CLEAN_FREQ,
                                 &cron_clean_data_hosts, NULL);
 }
@@ -660,6 +656,7 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
 };
 
 
+
 /**
  * Process statistics requests.
  *
@@ -686,23 +683,15 @@ run (void *cls,
                                                           &trustDirectory));
   GNUNET_DISK_directory_create (networkIdDirectory);
   GNUNET_DISK_directory_create (trustDirectory);
-  GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
-                                GNUNET_TIME_UNIT_MILLISECONDS,
-                                &cron_scan_directory_data_hosts, NULL);
-  GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                GNUNET_SCHEDULER_NO_TASK,
-                                TRUST_FLUSH_FREQ, &cron_flush_trust, NULL);
-  GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
-                                DATA_HOST_CLEAN_FREQ,
-                                &cron_clean_data_hosts, NULL);
+  GNUNET_SCHEDULER_add_with_priority (sched,
+                                     GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                     &cron_scan_directory_data_hosts, NULL);
+  GNUNET_SCHEDULER_add_with_priority (sched,
+                                     GNUNET_SCHEDULER_PRIORITY_HIGH,
+                                     &cron_flush_trust, NULL);
+  GNUNET_SCHEDULER_add_with_priority (sched,
+                                     GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                     &cron_clean_data_hosts, NULL);
   GNUNET_SERVER_add_handlers (server, handlers);
 }
 
@@ -722,7 +711,7 @@ main (int argc, char *const *argv)
   ret = (GNUNET_OK ==
         GNUNET_SERVICE_run (argc,
                             argv,
-                              "peerinfo", &run, NULL, NULL, NULL)) ? 0 : 1;
+                              "peerinfo", &run, NULL)) ? 0 : 1;
   GNUNET_free_non_null (networkIdDirectory);
   GNUNET_free_non_null (trustDirectory);
   return ret;
index 2bae851bc6cb37e88e53d3edde93860e985a1676..a375ca40e19e440866dcfce3676221538f5fe2e0 100644 (file)
@@ -149,7 +149,6 @@ check ()
                                  "-L", "DEBUG",
 #endif
                                  "-c", "test_peerinfo_api_data.conf", NULL);
-  sleep (1);
   GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
                       argv, "test-peerinfo-api", "nohelp",
                       options, &run, &ok);
index 3221fe2ae03465231ff2cf8f197fc0459269f100..8de9a8047df7596e1428c896ac050109fc5d952b 100644 (file)
@@ -82,6 +82,11 @@ struct StatsEntry
 
 };
 
+/**
+ * Our configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
 /**
  * Linked list of our active statistics.
  */
@@ -96,10 +101,11 @@ static uint32_t uidgen;
  * Load persistent values from disk.  Disk format is
  * exactly the same format that we also use for
  * setting the values over the network.
+ *
+ * @param server handle to the server context
  */
 static void
-load (struct GNUNET_SERVER_Handle *server,
-      const struct GNUNET_CONFIGURATION_Handle *cfg)
+load (struct GNUNET_SERVER_Handle *server)
 {
   char *fn;
   struct GNUNET_DISK_FileHandle *fh;
@@ -153,16 +159,11 @@ load (struct GNUNET_SERVER_Handle *server,
   GNUNET_free (fn);
 }
 
-
 /**
  * Write persistent statistics to disk.
- *
- * @param cls closure
- * @param cfg configuration to use
  */
 static void
-save (void *cls, 
-      const struct GNUNET_CONFIGURATION_Handle *cfg)
+save ()       
 {
   struct StatsEntry *pos;
   char *fn;
@@ -434,22 +435,41 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
 };
 
 
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+shutdown_task (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  save ();
+}
+
+
 /**
  * Process statistics requests.
  *
  * @param cls closure
  * @param sched scheduler to use
  * @param server the initialized server
- * @param cfg configuration to use
+ * @param c configuration to use
  */
 static void
 run (void *cls,
      struct GNUNET_SCHEDULER_Handle *sched,
      struct GNUNET_SERVER_Handle *server,
-     const struct GNUNET_CONFIGURATION_Handle *cfg)
+     const struct GNUNET_CONFIGURATION_Handle *c)
 {
+  cfg = c;
   GNUNET_SERVER_add_handlers (server, handlers);
-  load (server, cfg);
+  load (server);
+  GNUNET_SCHEDULER_add_delayed (sched,
+                               GNUNET_TIME_UNIT_FOREVER_REL,
+                               &shutdown_task,
+                               NULL);
 }
 
 
@@ -466,7 +486,7 @@ main (int argc, char *const *argv)
   return (GNUNET_OK ==
           GNUNET_SERVICE_run (argc,
                               argv,
-                              "statistics", &run, NULL, &save, NULL)) ? 0 : 1;
+                              "statistics", &run, NULL)) ? 0 : 1;
 }
 
 /* end of gnunet-service-statistics.c */
index 3ab7d3dcc636200e338129fcffb101d21460b9fc..15ba94b7dfa5cda136a455e71fa6040d7fd04c68 100644 (file)
 #include "gnunet_getopt_lib.h"
 #include "gnunet_service_lib.h"
 
-/**
- * Do cleanup here.
- *
- * @param cls closure
- * @param cfg configuration to use
- */
-static void
-finish (void *cls, 
-       const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-  /* FIXME */
-}
-
 
 /**
  * List of handlers for the messages understood by this
@@ -50,6 +37,21 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
   {NULL, NULL, 0, 0}
 };
 
+
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+cleanup_task (void *cls,
+             const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  /* FIXME: do clean up here */
+}
+
+
 /**
  * Process template requests.
  *
@@ -66,6 +68,10 @@ run (void *cls,
 {
   /* FIXME: do setup here */
   GNUNET_SERVER_add_handlers (server, handlers);
+  GNUNET_SCHEDULER_add_delayed (sched,
+                               GNUNET_TIME_UNIT_FOREVER_REL,
+                               &cleanup_task,
+                               NULL);
 }
 
 
@@ -82,7 +88,7 @@ main (int argc, char *const *argv)
   return (GNUNET_OK ==
           GNUNET_SERVICE_run (argc,
                               argv,
-                              "template", &run, NULL, &finish, NULL)) ? 0 : 1;
+                              "template", &run, NULL)) ? 0 : 1;
 }
 
 /* end of gnunet-service-template.c */
index 2bd14095f2ca24d81b31616ec63141a59927e994..e34e7a9ac905f67f634b0d93f48314cd3bb9fa48 100644 (file)
@@ -306,9 +306,6 @@ start_fsm (void *cls,
          /* wait some more */
          d->task
            = GNUNET_SCHEDULER_add_delayed (d->sched, 
-                                           GNUNET_NO,
-                                           GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                           GNUNET_SCHEDULER_NO_TASK,
                                            GNUNET_CONSTANTS_EXEC_WAIT,
                                            &start_fsm,
                                            d);
@@ -392,9 +389,6 @@ start_fsm (void *cls,
       d->wait_runs = 0;
       d->task
        = GNUNET_SCHEDULER_add_delayed (d->sched, 
-                                       GNUNET_NO,
-                                       GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                       GNUNET_SCHEDULER_NO_TASK,
                                        GNUNET_CONSTANTS_EXEC_WAIT,
                                        &start_fsm,
                                        d);
@@ -423,9 +417,6 @@ start_fsm (void *cls,
          /* wait some more */
          d->task
            = GNUNET_SCHEDULER_add_delayed (d->sched, 
-                                           GNUNET_NO,
-                                           GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                           GNUNET_SCHEDULER_NO_TASK,
                                            GNUNET_CONSTANTS_EXEC_WAIT,
                                            &start_fsm,
                                            d);
@@ -474,9 +465,6 @@ start_fsm (void *cls,
          /* wait some more */
          d->task
            = GNUNET_SCHEDULER_add_delayed (d->sched, 
-                                           GNUNET_NO,
-                                           GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                           GNUNET_SCHEDULER_NO_TASK,
                                            GNUNET_CONSTANTS_EXEC_WAIT,
                                            &start_fsm,
                                            d);
@@ -528,9 +516,6 @@ start_fsm (void *cls,
          /* wait some more */
          d->task
            = GNUNET_SCHEDULER_add_delayed (d->sched, 
-                                           GNUNET_NO,
-                                           GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                           GNUNET_SCHEDULER_NO_TASK,
                                            GNUNET_CONSTANTS_EXEC_WAIT,
                                            &start_fsm,
                                            d);
@@ -675,9 +660,6 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
        }
       ret->task
        = GNUNET_SCHEDULER_add_delayed (sched, 
-                                       GNUNET_YES,
-                                       GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                       GNUNET_SCHEDULER_NO_TASK,
                                        GNUNET_CONSTANTS_EXEC_WAIT,
                                        &start_fsm,
                                        ret);
@@ -689,7 +671,6 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
 #endif
   ret->phase = SP_COPIED;
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &start_fsm,
                                     ret,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -781,9 +762,6 @@ void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
       d->dead_cb_cls = cb_cls;
       d->task
        = GNUNET_SCHEDULER_add_delayed (d->sched, 
-                                       GNUNET_YES,
-                                       GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                       GNUNET_SCHEDULER_NO_TASK,
                                        GNUNET_CONSTANTS_EXEC_WAIT,
                                        &start_fsm,
                                        d);
@@ -879,9 +857,6 @@ void GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
   d->update_cb_cls = cb_cls;
   d->task
     = GNUNET_SCHEDULER_add_delayed (d->sched, 
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_CONSTANTS_EXEC_WAIT,
                                    &start_fsm,
                                    d);
@@ -986,7 +961,6 @@ transmit_ready (void *cls, size_t size, void *buf)
   GNUNET_TRANSPORT_disconnect (ctx->d2th);
   ctx->d2th = NULL;
   GNUNET_SCHEDULER_add_continuation (ctx->d1->sched,
-                                    GNUNET_NO,
                                     &notify_connect_result,
                                     ctx,
                                     (buf == NULL) ? 
index b156ddfafc7cf2ebb7abd7ca9b5693a824c44589..cdf3da809f7865185383925213b7f064df4fa506 100644 (file)
@@ -523,9 +523,6 @@ schedule_peer_search ()
              (unsigned long long) delay.value);
 #endif 
   GNUNET_SCHEDULER_add_delayed (sched,
-                               GNUNET_NO,
-                               GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                               GNUNET_SCHEDULER_NO_TASK,
                                delay,
                                &find_more_peers,
                                NULL);
@@ -823,9 +820,6 @@ core_init (void *cls,
 #endif         
   if (autoconnect)
     GNUNET_SCHEDULER_add_delayed (sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                 GNUNET_SCHEDULER_NO_TASK,
                                  GNUNET_TIME_UNIT_SECONDS /* give core time to tell us about existing connections */,
                                  &find_more_peers,
                                  NULL);
@@ -1227,9 +1221,6 @@ run (void *cls,
                       handlers);
 
   GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &cleaning_task, NULL);
 }
index b2790c0c9d6d33344947066d77c115f422724c07..2536f5454553f9b8e42f3f9119e31a8c79a14f68 100644 (file)
@@ -26,7 +26,7 @@
 
 #define VERBOSE GNUNET_YES
 
-#define NUM_PEERS 10
+#define NUM_PEERS 4
 
 /**
  * How long until we give up on connecting the peers?
index 0dc3f859dcc3331073324b81e769a463ca064c3e..efe53e0215388c90c214f377540e225ca77e5ed1 100644 (file)
@@ -710,9 +710,9 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
       GNUNET_free (q);
       client->message_count--;
     }
-  GNUNET_assert (tsize > 0);
   if (NULL != q)
     {
+      GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
       th = GNUNET_SERVER_notify_transmit_ready (client->client,
                                                 msize,
                                                 GNUNET_TIME_UNIT_FOREVER_REL,
@@ -753,6 +753,7 @@ transmit_to_client (struct TransportClient *client,
     }
   client->message_count++;
   msize = ntohs (msg->size);
+  GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
   q = GNUNET_malloc (sizeof (struct ClientMessageQueueEntry) + msize);
   memcpy (&q[1], msg, msize);
   /* append to message queue */
@@ -1217,9 +1218,6 @@ update_addresses (struct TransportPlugin *plugin, int fresh)
   if (min_remaining.value < GNUNET_TIME_UNIT_FOREVER_REL.value)
     plugin->address_update_task
       = GNUNET_SCHEDULER_add_delayed (plugin->env.sched,
-                                      GNUNET_NO,
-                                      GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                      GNUNET_SCHEDULER_NO_TASK,
                                       min_remaining,
                                       &expire_address_task, plugin);
 
@@ -1527,9 +1525,6 @@ cleanup_validation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
          pos = pos->next;
        }
       GNUNET_SCHEDULER_add_delayed (sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_absolute_get_remaining (first),
                                    &cleanup_validation, NULL);
     }
@@ -1631,12 +1626,9 @@ plugin_env_notify_validation (void *cls,
                  GNUNET_i2s (peer));
 #endif
       pos->timeout.value = 0;
-      GNUNET_SCHEDULER_add_delayed (sched,
-                                    GNUNET_NO,
-                                    GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                    GNUNET_SCHEDULER_NO_TASK,
-                                    GNUNET_TIME_UNIT_ZERO,
-                                    &cleanup_validation, NULL);
+      GNUNET_SCHEDULER_add_with_priority (sched,
+                                         GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                         &cleanup_validation, NULL);
     }
   else
     {
@@ -1798,9 +1790,6 @@ check_hello_validated (void *cls,
       va = va->next;
     }
   GNUNET_SCHEDULER_add_delayed (sched,
-                               GNUNET_NO,
-                               GNUNET_SCHEDULER_PRIORITY_IDLE,
-                               GNUNET_SCHEDULER_NO_TASK,
                                GNUNET_TIME_absolute_get_remaining (chvc->e->timeout), 
                                &cleanup_validation, NULL);
   GNUNET_free (chvc);
@@ -2047,9 +2036,6 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer)
   n->quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000);
   add_plugins (n);
   n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
-                                                  GNUNET_NO,
-                                                  GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                                  GNUNET_SCHEDULER_NO_TASK,
                                                   GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
                                                   &neighbour_timeout_task, n);
   transmit_to_peer (NULL, 0,
@@ -2161,9 +2147,7 @@ plugin_env_receive (void *cls,
   n->peer_timeout =
     GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
   n->timeout_task =
-    GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO,
-                                  GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                  GNUNET_SCHEDULER_NO_TASK,
+    GNUNET_SCHEDULER_add_delayed (sched, 
                                   GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
                                   &neighbour_timeout_task, n);
   update_quota (n);
@@ -2698,9 +2682,6 @@ run (void *cls,
       GNUNET_free (plugs);
     }
   GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &unload_plugins, NULL);
   if (no_transports)
@@ -2728,7 +2709,7 @@ main (int argc, char *const *argv)
          GNUNET_SERVICE_run (argc,
                              argv,
                              "transport",
-                             &run, NULL, NULL, NULL)) ? 0 : 1;
+                             &run, NULL)) ? 0 : 1;
 }
 
 /* end of gnunet-service-transport.c */
index eeb333a531b9a75d5ee16812e30503838b03d6c2..a391b1b4219658cb65c1b30aa755992e5dca5f9d 100644 (file)
@@ -1898,9 +1898,6 @@ handle_tcp_data (void *cls,
     GNUNET_SERVER_receive_done (client, GNUNET_OK);
   else
     GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched,
-                                  GNUNET_NO,
-                                  GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                  GNUNET_SCHEDULER_NO_TASK,
                                   delay, &delayed_done, session);
 }
 
index ec1b6b76c87e1f295c839089ea043e70249abce0..856cadeaf097be6b293f1eb0018d1c4b15a5a79e 100644 (file)
@@ -179,7 +179,6 @@ validation_notification (void *cls,
      here will end the process. */
   ok = 0; /* if the last test succeeded, report success */
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &unload_task,
                                     (void*) cfg,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -236,9 +235,6 @@ test_validation ()
   /* add job to catch failure (timeout) */
   validation_timeout_task =
     GNUNET_SCHEDULER_add_delayed (sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                 GNUNET_SCHEDULER_NO_TASK,
                                  TIMEOUT,
                                  &validation_failed,
                                  NULL);
index 122950a74e14f1ebb000697602dd05d2791538e7..c98194da02a2f2e387d183c2b4edb42c34bcf048 100644 (file)
@@ -625,9 +625,6 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h,
   th->notify_size = size;
   th->notify_delay_task 
     = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    timeout,
                                    &peer_transmit_timeout, th);    
   if (at_head)
@@ -704,7 +701,6 @@ send_set_quota (void *cls, size_t size, void *buf)
   if (buf == NULL)
     {
       GNUNET_SCHEDULER_add_continuation (sqc->handle->sched,
-                                         GNUNET_NO,
                                          sqc->cont,
                                          sqc->cont_cls,
                                          GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -724,7 +720,6 @@ send_set_quota (void *cls, size_t size, void *buf)
   memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity));
   if (sqc->cont != NULL)
     GNUNET_SCHEDULER_add_continuation (sqc->handle->sched,
-                                       GNUNET_NO,
                                        sqc->cont,
                                        sqc->cont_cls,
                                        GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -802,9 +797,6 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                  GNUNET_TIME_absolute_get_remaining (hwl->timeout).value);
 #endif
       hwl->task = GNUNET_SCHEDULER_add_delayed (hwl->handle->sched,
-                                                GNUNET_YES,
-                                                GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                GNUNET_SCHEDULER_NO_TASK,
                                                 GNUNET_TIME_absolute_get_remaining (hwl->timeout),
                                                 &hello_wait_timeout, hwl);
       return;      
@@ -862,9 +854,6 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
       hwl->rec_cls = rec_cls;
       hwl->timeout = GNUNET_TIME_relative_to_absolute (timeout);
       hwl->task = GNUNET_SCHEDULER_add_delayed (handle->sched,
-                                                GNUNET_YES,
-                                                GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                GNUNET_SCHEDULER_NO_TASK,
                                                 timeout,
                                                 &hello_wait_timeout, hwl);
       return;
@@ -1018,9 +1007,6 @@ request_connect (void *cls, size_t size, void *buf)
   memcpy (&tcm->peer, &th->target, sizeof (struct GNUNET_PeerIdentity));
   th->notify_delay_task
     = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                    GNUNET_NO,
-                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                    GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_absolute_get_remaining
                                    (th->timeout),
                                    &peer_transmit_timeout, th);
@@ -1128,9 +1114,6 @@ remove_neighbour (struct GNUNET_TRANSPORT_Handle *h,
          GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task);
          th->notify_delay_task 
            = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                           GNUNET_NO,
-                                           GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                           GNUNET_SCHEDULER_NO_TASK,
                                            CONNECT_RETRY_TIMEOUT,
                                            &try_connect_task,
                                            th);
@@ -1214,9 +1197,6 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
   GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
   h->reconnect_task
     = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                    GNUNET_NO,
-                                    GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                    GNUNET_SCHEDULER_NO_TASK,
                                     h->reconnect_delay, &reconnect, h);
   h->reconnect_delay = GNUNET_TIME_UNIT_SECONDS;
 }
@@ -1318,9 +1298,6 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th)
 #endif
       th->notify_delay_task
         = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                        GNUNET_NO,
-                                        GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                        GNUNET_SCHEDULER_NO_TASK,
                                         duration, &transmit_ready, th);
       return;
     }
@@ -1340,9 +1317,6 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th)
 #endif
       th->notify_delay_task
         = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                        GNUNET_NO,
-                                        GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                        GNUNET_SCHEDULER_NO_TASK,
                                         GNUNET_TIME_absolute_get_remaining
                                         (th->timeout), &peer_transmit_timeout, th);
       return;
@@ -1593,9 +1567,6 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
              GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK);
              th->notify_delay_task 
                = GNUNET_SCHEDULER_add_delayed (h->sched,
-                                               GNUNET_NO,
-                                               GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                               GNUNET_SCHEDULER_NO_TASK,
                                                GNUNET_TIME_absolute_get_remaining(th->timeout),
                                                &peer_transmit_timeout, 
                                                th);    
@@ -1937,9 +1908,6 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
 #endif
       th->notify_delay_task
        = GNUNET_SCHEDULER_add_delayed (handle->sched,
-                                       GNUNET_NO,
-                                       GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                       GNUNET_SCHEDULER_NO_TASK,
                                        timeout, &peer_transmit_timeout, th);
       return th;
     }
index 60aa6f1017f8da92e542820aa855597fe912e036..05f579b9f5791509e6ccb7cde055b60fc7c214c4 100644 (file)
@@ -308,8 +308,6 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock)
     sock->in_receive = GNUNET_SYSERR;
   else
     GNUNET_SCHEDULER_add_after (sock->sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
                                 GNUNET_SCHEDULER_NO_TASK,
                                 &finish_cleanup, sock);
 }
@@ -353,8 +351,6 @@ receive_helper (void *cls,
   GNUNET_assert (conn->msg_complete == GNUNET_NO);
   if (GNUNET_SYSERR == conn->in_receive)
     GNUNET_SCHEDULER_add_after (conn->sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
                                 GNUNET_SCHEDULER_NO_TASK,
                                 &finish_cleanup, conn);
   conn->in_receive = GNUNET_NO;
@@ -412,8 +408,6 @@ receive_task (void *scls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   if (GNUNET_SYSERR == sock->in_receive)
     GNUNET_SCHEDULER_add_after (sock->sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
                                 GNUNET_SCHEDULER_NO_TASK,
                                 &finish_cleanup, sock);
   sock->in_receive = GNUNET_NO;
@@ -457,8 +451,6 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock,
   sock->in_receive = GNUNET_YES;
   if (GNUNET_YES == sock->msg_complete)
     GNUNET_SCHEDULER_add_after (sock->sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
                                 GNUNET_SCHEDULER_NO_TASK,
                                 &receive_task, sock);
   else
@@ -522,7 +514,6 @@ service_test_error (struct GNUNET_SCHEDULER_Handle *s,
                     GNUNET_SCHEDULER_Task task, void *task_cls)
 {
   GNUNET_SCHEDULER_add_continuation (s,
-                                     GNUNET_YES,
                                      task,
                                      task_cls,
                                      GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -549,7 +540,6 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg)
                   "Received confirmation that service is running.\n");
 #endif
       GNUNET_SCHEDULER_add_continuation (conn->sched,
-                                         GNUNET_YES,
                                          conn->test_cb,
                                          conn->test_cb_cls,
                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -719,9 +709,6 @@ client_notify (void *cls, size_t size, void *buf)
       GNUNET_assert (NULL != th->sock->sock);
       delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_SECONDS);
       th->task = GNUNET_SCHEDULER_add_delayed (th->sock->sched,
-                                               GNUNET_NO,
-                                               GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                               GNUNET_SCHEDULER_NO_TASK,
                                                delay,
                                                &client_delayed_retry, th);
       th->sock->th = th;
index 066b81bbe76154321cb86d8487d481388adfba51..9bf2aa975a2661b2f974b4dc3da1fae813a68ee3 100644 (file)
@@ -476,8 +476,6 @@ destroy_continuation (void *cls,
                   "Destroy waits for write_task to be done (%p)\n", sock);
 #endif
       GNUNET_SCHEDULER_add_after (sock->sched,
-                                  GNUNET_YES,
-                                  GNUNET_SCHEDULER_PRIORITY_KEEP,
                                   sock->write_task,
                                   &destroy_continuation, sock);
       return;
@@ -498,8 +496,6 @@ destroy_continuation (void *cls,
   if (sock->read_task != GNUNET_SCHEDULER_NO_TASK)
     {
       GNUNET_SCHEDULER_add_after (sock->sched,
-                                  GNUNET_YES,
-                                  GNUNET_SCHEDULER_PRIORITY_KEEP,
                                   sock->read_task,
                                   &destroy_continuation, sock);
       return;
@@ -569,8 +565,6 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
 #endif
       h->ccs -= COCO_RECEIVE_AGAIN;
       h->read_task = GNUNET_SCHEDULER_add_after (h->sched,
-                                                 GNUNET_NO,
-                                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
                                                  GNUNET_SCHEDULER_NO_TASK,
                                                  &receive_again, h);
     }
@@ -586,8 +580,6 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
       h->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
       h->ccs -= COCO_TRANSMIT_READY;
       h->write_task = GNUNET_SCHEDULER_add_after (h->sched,
-                                                  GNUNET_NO,
-                                                  GNUNET_SCHEDULER_PRIORITY_KEEP,
                                                   GNUNET_SCHEDULER_NO_TASK,
                                                   &transmit_ready, h);
     }
@@ -600,7 +592,6 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *h)
 #endif
       h->ccs -= COCO_DESTROY_CONTINUATION;
       GNUNET_SCHEDULER_add_continuation (h->sched,
-                                         GNUNET_NO,
                                          &destroy_continuation,
                                          h, GNUNET_SCHEDULER_REASON_TIMEOUT);
     }
@@ -630,8 +621,6 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
 #endif
       h->ccs -= COCO_RECEIVE_AGAIN;
       h->read_task = GNUNET_SCHEDULER_add_after (h->sched,
-                                                 GNUNET_NO,
-                                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
                                                  GNUNET_SCHEDULER_NO_TASK,
                                                  &receive_again, h);
     }
@@ -648,9 +637,6 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
       h->ccs -= COCO_TRANSMIT_READY;
       h->write_task =
         GNUNET_SCHEDULER_add_write_net (h->sched,
-                                        GNUNET_NO,
-                                        GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                        GNUNET_SCHEDULER_NO_TASK,
                                         GNUNET_TIME_absolute_get_remaining
                                         (h->nth.transmit_timeout), h->sock,
                                         &transmit_ready, h);
@@ -664,7 +650,6 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *h)
 #endif
       h->ccs -= COCO_DESTROY_CONTINUATION;
       GNUNET_SCHEDULER_add_continuation (h->sched,
-                                         GNUNET_NO,
                                          &destroy_continuation,
                                          h,
                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -808,9 +793,8 @@ try_connect_using_address (void *cls,
                                       GNUNET_TIME_absolute_get_remaining (h->
                                                                           receive_timeout));
   ap->task =
-    GNUNET_SCHEDULER_add_write_net (h->sched, GNUNET_NO,
-                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                    GNUNET_SCHEDULER_NO_TASK, delay, ap->sock,
+    GNUNET_SCHEDULER_add_write_net (h->sched, 
+                                    delay, ap->sock,
                                     &connect_probe_continuation, ap);
 }
 
@@ -956,8 +940,6 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *sock)
     }
   GNUNET_assert (sock->sched != NULL);
   GNUNET_SCHEDULER_add_after (sock->sched,
-                              GNUNET_YES,
-                              GNUNET_SCHEDULER_PRIORITY_KEEP,
                               GNUNET_SCHEDULER_NO_TASK,
                               &destroy_continuation, sock);
 }
@@ -1101,9 +1083,6 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (sh->sock != NULL);
   /* connect succeeded, wait for data! */
   sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched,
-                                                 GNUNET_YES,
-                                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                 GNUNET_SCHEDULER_NO_TASK,
                                                  GNUNET_TIME_absolute_get_remaining
                                                  (sh->receive_timeout),
                                                  sh->sock,
@@ -1406,9 +1385,6 @@ SCHEDULE_WRITE:
   if (sock->write_task == GNUNET_SCHEDULER_NO_TASK)
     sock->write_task =
       GNUNET_SCHEDULER_add_write_net (tc->sched,
-                                      GNUNET_NO,
-                                      GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                      GNUNET_SCHEDULER_NO_TASK,
                                       GNUNET_TIME_absolute_get_remaining
                                       (sock->nth.transmit_timeout),
                                       sock->sock, &transmit_ready, sock);
@@ -1453,9 +1429,6 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
       (sock->ap_head == NULL) && (sock->dns_active == NULL))
     {
       sock->write_task = GNUNET_SCHEDULER_add_delayed (sock->sched,
-                                                       GNUNET_NO,
-                                                       GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                       GNUNET_SCHEDULER_NO_TASK,
                                                        GNUNET_TIME_UNIT_ZERO,
                                                        &connect_error, sock);
       return &sock->nth;
@@ -1469,9 +1442,6 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
                   "Scheduling transmit_ready (%p).\n", sock);
 #endif
       sock->write_task = GNUNET_SCHEDULER_add_write_net (sock->sched,
-                                                         GNUNET_NO,
-                                                         GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                         GNUNET_SCHEDULER_NO_TASK,
                                                          GNUNET_TIME_absolute_get_remaining
                                                          (sock->nth.
                                                           transmit_timeout),
@@ -1488,9 +1458,6 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
 #endif
       sock->ccs |= COCO_TRANSMIT_READY;
       sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (sock->sched,
-                                                             GNUNET_NO,
-                                                             GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                             GNUNET_SCHEDULER_NO_TASK,
                                                              timeout,
                                                              &transmit_timeout,
                                                              sock);
index 3f5869489e18624be72e1d6b2ea5239294615f12..dcee545f79e811b20ff2fc1f0272a8d48e25e9c9 100644 (file)
@@ -415,11 +415,6 @@ struct FileHashContext
    */
   uint64_t offset;
 
-  /**
-   * Run on shutdown?
-   */
-  int run_on_shutdown;
-
   /**
    * File descriptor.
    */
@@ -476,8 +471,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       return;
     }
   GNUNET_SCHEDULER_add_after (tc->sched,
-                              fhc->run_on_shutdown,
-                              GNUNET_SCHEDULER_PRIORITY_KEEP,
                               GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc);
 }
 
@@ -487,7 +480,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  *
  * @param sched scheduler to use
  * @param priority scheduling priority to use
- * @param run_on_shutdown should we complete even on shutdown?
  * @param filename name of file to hash
  * @param blocksize number of bytes to process in one task
  * @param callback function to call upon completion
@@ -496,7 +488,6 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 void
 GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
                          enum GNUNET_SCHEDULER_Priority priority,
-                         int run_on_shutdown,
                          const char *filename,
                          size_t blocksize,
                          GNUNET_CRYPTO_HashCompletedCallback callback,
@@ -518,7 +509,6 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
       file_hash_finish (fhc, NULL);
       return;
     }
-  fhc->run_on_shutdown = run_on_shutdown;
   fhc->fh = GNUNET_DISK_file_open (filename,
                                    GNUNET_DISK_OPEN_READ,
                                    GNUNET_DISK_PERM_NONE);
@@ -527,10 +517,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
       file_hash_finish (fhc, NULL);
       return;
     }
-  GNUNET_SCHEDULER_add_after (sched,
-                              run_on_shutdown,
-                              priority,
-                              GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc);
+  GNUNET_SCHEDULER_add_with_priority (sched, priority, &file_hash_task, fhc);
 }
 
 
index 9f93a1ee2ed3be663c414a32c446309c827dc86d..3b3cb9e652c8de07c3adc1e4cd21f7be2df84599 100644 (file)
@@ -856,11 +856,9 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator
       GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES);
       return GNUNET_NO;
     }
-  GNUNET_SCHEDULER_add_after (iter->sched,
-                              GNUNET_YES,
-                              iter->priority,
-                              GNUNET_SCHEDULER_NO_TASK,
-                              &directory_iterator_task, iter);
+  GNUNET_SCHEDULER_add_with_priority (iter->sched,
+                                     iter->priority,
+                                     &directory_iterator_task, iter);
   return GNUNET_YES;
 }
 
index f8dd2e1669250616b97d876023451317e0b8aa76..4dcabface2b20d4e8ec947b2b3dad4ba009cd42c 100644 (file)
@@ -516,7 +516,7 @@ main (int argc, char *const *argv)
   ret = (GNUNET_OK ==
          GNUNET_SERVICE_run (argc,
                              argv,
-                             "resolver", &run, NULL, NULL, NULL)) ? 0 : 1;
+                             "resolver", &run, NULL)) ? 0 : 1;
 
   while (head != NULL)
     {
index 69d143bc1c7c1caaad06f0b4819d9c4cfb38606a..812cdc84eda0eb4a0f79243793f61a82a74d237b 100644 (file)
@@ -442,9 +442,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
        ((domain == AF_INET6) || (domain == AF_UNSPEC))))
     {
       rh->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                               GNUNET_NO,
-                                               GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                               GNUNET_SCHEDULER_NO_TASK,
                                                GNUNET_TIME_UNIT_ZERO,
                                                &numeric_resolution, rh);
       return rh;
@@ -455,9 +452,6 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
     if (0 == strcasecmp (loopback[i++], hostname))
       {
         rh->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                                 GNUNET_NO,
-                                                 GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                                 GNUNET_SCHEDULER_NO_TASK,
                                                  GNUNET_TIME_UNIT_ZERO,
                                                  &loopback_resolution, rh);
         return rh;
@@ -623,9 +617,6 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched,
   if (GNUNET_NO == do_resolve)
     {
       rh->task = GNUNET_SCHEDULER_add_delayed (sched,
-                                               GNUNET_NO,
-                                               GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                               GNUNET_SCHEDULER_NO_TASK,
                                                GNUNET_TIME_UNIT_ZERO,
                                                &numeric_reverse, rh);
       return rh;
index 2bb356eb6017491f8bd65fee1fc13ed9b0c05d7d..16f65b457bfa1096f32471534582e500ba441578 100644 (file)
@@ -95,11 +95,6 @@ struct Task
    */
   enum GNUNET_SCHEDULER_Priority priority;
 
-  /**
-   * Should this task be run on shutdown?
-   */
-  int run_on_shutdown;
-
 };
 
 
@@ -134,12 +129,6 @@ struct GNUNET_SCHEDULER_Handle
    */
   GNUNET_SCHEDULER_TaskIdentifier lowest_pending_id;
 
-  /**
-   * GNUNET_NO if we are running normally,
-   * GNUNET_YES if we are in shutdown mode.
-   */
-  int shutdown;
-
   /**
    * Number of tasks on the ready list.
    */
@@ -260,6 +249,8 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched,
         GNUNET_NETWORK_fdset_add (rs, pos->read_set);
       if (pos->write_set != NULL)
         GNUNET_NETWORK_fdset_add (ws, pos->write_set);
+      if (pos->reason != 0)
+       *timeout = GNUNET_TIME_UNIT_ZERO;
       pos = pos->next;
     }
 }
@@ -309,12 +300,7 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched,
           const struct GNUNET_NETWORK_FDSet *rs,
           const struct GNUNET_NETWORK_FDSet *ws)
 {
-  if ((GNUNET_NO == task->run_on_shutdown) && (GNUNET_YES == sched->shutdown))
-    return GNUNET_NO;
-  if ((GNUNET_YES == task->run_on_shutdown) &&
-      (GNUNET_YES == sched->shutdown))
-    task->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
-  if (now.value >= task->timeout.value)
+  if (now.value >= task->timeout.value) 
     task->reason |= GNUNET_SCHEDULER_REASON_TIMEOUT;
   if ((0 == (task->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
       (rs != NULL) && (set_overlaps (rs, task->read_set)))
@@ -394,6 +380,32 @@ check_ready (struct GNUNET_SCHEDULER_Handle *handle,
 }
 
 
+/**
+ * Request the shutdown of a scheduler.  Marks all currently
+ * pending tasks as ready because of shutdown.  This will
+ * cause all tasks to run (as soon as possible, respecting
+ * priorities and prerequisite tasks).  Note that tasks
+ * scheduled AFTER this call may still be delayed arbitrarily.
+ *
+ * @param sched the scheduler
+ */
+void
+GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
+{
+  struct Task *pos;
+
+  pos = sched->pending;
+  while (pos != NULL)
+    {
+      pos->reason |= GNUNET_SCHEDULER_REASON_SHUTDOWN;
+      /* we don't move the task into the ready queue yet; check_ready
+        will do that later, possibly adding additional
+        readyness-factors */
+      pos = pos->next;
+    }
+}
+
+
 /**
  * Destroy a task (release associated resources)
  *
@@ -415,7 +427,7 @@ destroy_task (struct Task *t)
  * empty.  Keep running tasks until we are either no longer running
  * "URGENT" tasks or until we have at least one "pending" task (which
  * may become ready, hence we should select on it).  Naturally, if
- * there are no more ready tasks, we also return.
+ * there are no more ready tasks, we also return.  
  *
  * @param sched the scheduler
  */
@@ -459,7 +471,7 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched)
   while ((sched->pending == NULL) || (p == GNUNET_SCHEDULER_PRIORITY_URGENT));
 }
 
-
+#ifndef MINGW
 /**
  * Pipe used to communicate shutdown via signal.
  */
@@ -478,19 +490,25 @@ sighandler_shutdown ()
                           (sigpipe, GNUNET_DISK_PIPE_END_WRITE), &c,
                           sizeof (c));
 }
+#endif
 
 
 /**
- * Initialize a scheduler using this thread.  This function will
- * return when either a shutdown was initiated (via signal) and all
- * tasks marked to "run_on_shutdown" have been completed or when all
- * tasks in general have been completed.
+ * Initialize and run scheduler.  This function will return when all
+ * tasks have completed.  On systems with signals, receiving a SIGTERM
+ * (and other similar signals) will cause "GNUNET_SCHEDULER_shutdown"
+ * to be run after the active task is complete.  As a result, SIGTERM
+ * causes all active tasks to be scheduled with reason
+ * "GNUNET_SCHEDULER_REASON_SHUTDOWN".  (However, tasks added
+ * afterwards will execute normally!). Note that any particular signal
+ * will only shut down one scheduler; applications should always only
+ * create a single scheduler.
  *
  * @param task task to run immediately
- * @param cls closure of task
+ * @param task_cls closure of task
  */
 void
-GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
+GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
 {
   struct GNUNET_SCHEDULER_Handle sched;
   struct GNUNET_NETWORK_FDSet *rs;
@@ -501,12 +519,12 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
   struct GNUNET_SIGNAL_Context *shc_term;
   struct GNUNET_SIGNAL_Context *shc_quit;
   struct GNUNET_SIGNAL_Context *shc_hup;
-  struct Task *tpos;
   unsigned long long last_tr;
   unsigned int busy_wait_warning;
 #ifndef MINGW
   const struct GNUNET_DISK_FileHandle *pr;
 #endif
+  char c;
 
   rs = GNUNET_NETWORK_fdset_create ();
   ws = GNUNET_NETWORK_fdset_create ();
@@ -516,38 +534,40 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
   GNUNET_assert (sigpipe != NULL);
   pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
   GNUNET_assert (pr != NULL);
-  shc_int = GNUNET_SIGNAL_handler_install (SIGINT, &sighandler_shutdown);
+  shc_int  = GNUNET_SIGNAL_handler_install (SIGINT, &sighandler_shutdown);
   shc_term = GNUNET_SIGNAL_handler_install (SIGTERM, &sighandler_shutdown);
   shc_quit = GNUNET_SIGNAL_handler_install (SIGQUIT, &sighandler_shutdown);
-  shc_hup = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown);
+  shc_hup  = GNUNET_SIGNAL_handler_install (SIGHUP, &sighandler_shutdown);
 #endif
   memset (&sched, 0, sizeof (sched));
   sched.current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT;
   GNUNET_SCHEDULER_add_continuation (&sched,
-                                     GNUNET_YES,
                                      task,
-                                     cls, GNUNET_SCHEDULER_REASON_STARTUP);
+                                     task_cls, 
+                                    GNUNET_SCHEDULER_REASON_STARTUP);
   last_tr = 0;
   busy_wait_warning = 0;
-  while ((GNUNET_NO == sched.shutdown) &&
-         ((sched.pending != NULL) || (sched.ready_count > 0)))
+  while ( (sched.pending != NULL) || (sched.ready_count > 0) )
     {
       GNUNET_NETWORK_fdset_zero (rs);
       GNUNET_NETWORK_fdset_zero (ws);
-      timeout = GNUNET_TIME_relative_get_forever ();
+      timeout = GNUNET_TIME_UNIT_FOREVER_REL;
       update_sets (&sched, rs, ws, &timeout);
-#ifndef MINGW
       GNUNET_NETWORK_fdset_handle_set (rs, pr);
-#endif
       if (sched.ready_count > 0)
         {
           /* no blocking, more work already ready! */
-          timeout = GNUNET_TIME_relative_get_zero ();
+          timeout = GNUNET_TIME_UNIT_ZERO;
         }
       ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout);
 #ifndef MINGW
       if (GNUNET_NETWORK_fdset_handle_isset (rs, pr))
-        break;
+       {
+         /* consume the signal */
+         GNUNET_DISK_file_read (pr, &c, sizeof(c));
+         /* mark all active tasks as ready due to shutdown */
+         GNUNET_SCHEDULER_shutdown (&sched);
+       }
 #endif
       if (last_tr == sched.tasks_run)
         {
@@ -574,7 +594,6 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
       check_ready (&sched, rs, ws);
       run_ready (&sched);
     }
-  sched.shutdown = GNUNET_YES;
 #ifndef MINGW
   GNUNET_SIGNAL_handler_uninstall (shc_int);
   GNUNET_SIGNAL_handler_uninstall (shc_term);
@@ -583,36 +602,11 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *cls)
   GNUNET_DISK_pipe_close (sigpipe);
   sigpipe = NULL;
 #endif
-  do
-    {
-      run_ready (&sched);
-      check_ready (&sched, NULL, NULL);
-    }
-  while (sched.ready_count > 0);
-  while (NULL != (tpos = sched.pending))
-    {
-      sched.pending = tpos->next;
-      GNUNET_free (tpos);
-    }
   GNUNET_NETWORK_fdset_destroy (rs);
   GNUNET_NETWORK_fdset_destroy (ws);
 }
 
 
-/**
- * Request the shutdown of a scheduler.  This function can be used to
- * stop a scheduling thread when created with the
- * "GNUNET_SCHEDULER_init_thread" function or from within the signal
- * handler for signals causing shutdowns.
- *
- * @param sched the scheduler
- */
-void
-GNUNET_SCHEDULER_shutdown (struct GNUNET_SCHEDULER_Handle *sched)
-{
-  sched->shutdown = GNUNET_YES;
-}
-
 
 /**
  * Get information about the current load of this scheduler.  Use this
@@ -715,102 +709,113 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Handle *sched,
  * and the reason code can be specified.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown should this task be run if we are shutting down?
- * @param main main function of the task
- * @param cls closure for 'main'
+ * @param task main function of the task
+ * @param task_cls closure for 'main'
  * @param reason reason for task invocation
  */
 void
 GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched,
-                                   int run_on_shutdown,
-                                   GNUNET_SCHEDULER_Task main,
-                                   void *cls,
+                                   GNUNET_SCHEDULER_Task task,
+                                   void *task_cls,
                                    enum GNUNET_SCHEDULER_Reason reason)
 {
-  struct Task *task;
-
-  task = GNUNET_malloc (sizeof (struct Task));
-  task->callback = main;
-  task->callback_cls = cls;
-  task->id = ++sched->last_id;
-  task->reason = reason;
-  task->priority = sched->current_priority;
-  task->run_on_shutdown = run_on_shutdown;
+  struct Task *t;
+
+  t = GNUNET_malloc (sizeof (struct Task));
+  t->callback = task;
+  t->callback_cls = task_cls;
+  t->id = ++sched->last_id;
+  t->reason = reason;
+  t->priority = sched->current_priority;
 #if DEBUG_TASKS
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Adding continuation task: %llu / %p\n",
-              task->id, task->callback_cls);
+              t->id, t->callback_cls);
 #endif
-  queue_ready_task (sched, task);
+  queue_ready_task (sched, t);
 }
 
 
+
 /**
- * Schedule a new task to be run after the specified
- * prerequisite task has completed.
+ * Schedule a new task to be run after the specified prerequisite task
+ * has completed. It will be run with the priority of the calling
+ * task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown?
- * @param prio how important is this task?
  * @param prerequisite_task run this task after the task with the given
  *        task identifier completes (and any of our other
  *        conditions, such as delay, read or write-readyness
  *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param main main function of the task
- * @param cls closure for 'main'
+ *        on completion of other tasks (this will cause the task to run as
+ *        soon as possible).
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
 GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched,
-                            int run_on_shutdown,
-                            enum GNUNET_SCHEDULER_Priority prio,
                             GNUNET_SCHEDULER_TaskIdentifier prerequisite_task,
-                            GNUNET_SCHEDULER_Task main, void *cls)
+                            GNUNET_SCHEDULER_Task task,
+                           void *task_cls)
 {
-  return GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
+  return GNUNET_SCHEDULER_add_select (sched, 
+                                     GNUNET_SCHEDULER_PRIORITY_KEEP,
                                       prerequisite_task,
                                       GNUNET_TIME_UNIT_ZERO,
-                                      NULL, NULL, main, cls);
+                                      NULL, NULL, task, task_cls);
 }
 
 
+/**
+ * Schedule a new task to be run with a specified priority.
+ *
+ * @param sched scheduler to use
+ * @param prio how important is the new task?
+ * @param task main function of the task
+ * @param task_cls closure of task
+ * @return unique task identifier for the job
+ *         only valid until "task" is started!
+ */
+GNUNET_SCHEDULER_TaskIdentifier
+GNUNET_SCHEDULER_add_with_priority (struct GNUNET_SCHEDULER_Handle *sched,
+                                   enum GNUNET_SCHEDULER_Priority prio,
+                                   GNUNET_SCHEDULER_Task task,
+                                   void *task_cls)
+{
+  return GNUNET_SCHEDULER_add_select (sched, 
+                                     prio,
+                                      GNUNET_SCHEDULER_NO_TASK,
+                                      GNUNET_TIME_UNIT_ZERO,
+                                      NULL, NULL, task, task_cls);
+}
+
+
+
 /**
  * Schedule a new task to be run with a specified delay.  The task
- * will be scheduled for execution once the delay has expired and the
- * prerequisite task has completed.
+ * will be scheduled for execution once the delay has expired. It
+ * will be run with the priority of the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? You can use this
- *        argument to run a function only during shutdown
- *        by setting delay to -1.  Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
- * @param main main function of the task
- * @param cls closure of task
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
-GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
-                              int run_on_shutdown,
-                              enum GNUNET_SCHEDULER_Priority prio,
-                              GNUNET_SCHEDULER_TaskIdentifier
-                              prerequisite_task,
+GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched,
                               struct GNUNET_TIME_Relative delay,
-                              GNUNET_SCHEDULER_Task main, void *cls)
+                              GNUNET_SCHEDULER_Task task,
+                             void *task_cls)
 {
-  return GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
-                                      prerequisite_task, delay,
-                                      NULL, NULL, main, cls);
+  return GNUNET_SCHEDULER_add_select (sched,
+                                     GNUNET_SCHEDULER_PRIORITY_KEEP,
+                                      GNUNET_SCHEDULER_NO_TASK, delay,
+                                      NULL, NULL, task, task_cls);
 }
 
 
@@ -819,34 +824,24 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched,
  * specified file descriptor is ready for reading.  The delay can be
  * used as a timeout on the socket being ready.  The task will be
  * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
+ * socket operation is ready.  It will be run with the priority of
+ * the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
  * @param rfd read file-descriptor
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
-GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched,
-                               int run_on_shutdown,
-                               enum GNUNET_SCHEDULER_Priority prio,
-                               GNUNET_SCHEDULER_TaskIdentifier
-                               prerequisite_task,
-                               struct GNUNET_TIME_Relative delay,
-                               struct GNUNET_NETWORK_Handle * rfd,
-                               GNUNET_SCHEDULER_Task main, void *cls)
+GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle *sched,
+                              struct GNUNET_TIME_Relative delay,
+                              struct GNUNET_NETWORK_Handle *rfd,
+                              GNUNET_SCHEDULER_Task task,
+                              void *task_cls)
 {
   struct GNUNET_NETWORK_FDSet *rs;
   GNUNET_SCHEDULER_TaskIdentifier ret;
@@ -854,9 +849,11 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched,
   GNUNET_assert (rfd != NULL);
   rs = GNUNET_NETWORK_fdset_create ();
   GNUNET_NETWORK_fdset_set (rs, rfd);
-  ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
-                                     prerequisite_task, delay,
-                                     rs, NULL, main, cls);
+  ret = GNUNET_SCHEDULER_add_select (sched, 
+                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
+                                     GNUNET_SCHEDULER_NO_TASK, 
+                                    delay,
+                                     rs, NULL, task, task_cls);
   GNUNET_NETWORK_fdset_destroy (rs);
   return ret;
 }
@@ -867,34 +864,24 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_SCHEDULER_Handle * sched,
  * specified file descriptor is ready for writing.  The delay can be
  * used as a timeout on the socket being ready.  The task will be
  * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
+ * socket operation is ready.  It will be run with the priority of
+ * the calling task.
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
  * @param wfd write file-descriptor
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
-GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched,
-                                int run_on_shutdown,
-                                enum GNUNET_SCHEDULER_Priority prio,
-                                GNUNET_SCHEDULER_TaskIdentifier
-                                prerequisite_task,
-                                struct GNUNET_TIME_Relative delay,
-                                struct GNUNET_NETWORK_Handle * wfd,
-                                GNUNET_SCHEDULER_Task main, void *cls)
+GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle *sched,
+                               struct GNUNET_TIME_Relative delay,
+                               struct GNUNET_NETWORK_Handle *wfd, 
+                               GNUNET_SCHEDULER_Task task, 
+                               void *task_cls)
 {
   struct GNUNET_NETWORK_FDSet *ws;
   GNUNET_SCHEDULER_TaskIdentifier ret;
@@ -902,14 +889,95 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched,
   GNUNET_assert (wfd != NULL);
   ws = GNUNET_NETWORK_fdset_create ();
   GNUNET_NETWORK_fdset_set (ws, wfd);
-  ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
-                                     prerequisite_task, delay,
-                                     NULL, ws, main, cls);
+  ret = GNUNET_SCHEDULER_add_select (sched, 
+                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
+                                     GNUNET_SCHEDULER_NO_TASK, delay,
+                                     NULL, ws, task, task_cls);
+  GNUNET_NETWORK_fdset_destroy (ws);
+  return ret;
+}
+
+
+/**
+ * Schedule a new task to be run with a specified delay or when the
+ * specified file descriptor is ready for reading.  The delay can be
+ * used as a timeout on the socket being ready.  The task will be
+ * scheduled for execution once either the delay has expired or the
+ * socket operation is ready. It will be run with the priority of
+ * the calling task.
+ *
+ * @param sched scheduler to use
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
+ * @param rfd read file-descriptor
+ * @param task main function of the task
+ * @param task_cls closure of task
+ * @return unique task identifier for the job
+ *         only valid until "task" is started!
+ */
+GNUNET_SCHEDULER_TaskIdentifier
+GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle *sched,
+                               struct GNUNET_TIME_Relative delay,
+                               const struct GNUNET_DISK_FileHandle *rfd, 
+                               GNUNET_SCHEDULER_Task task,
+                               void *task_cls)
+{
+  struct GNUNET_NETWORK_FDSet *rs;
+  GNUNET_SCHEDULER_TaskIdentifier ret;
+
+  GNUNET_assert (rfd != NULL);
+  rs = GNUNET_NETWORK_fdset_create ();
+  GNUNET_NETWORK_fdset_handle_set (rs, rfd);
+  ret = GNUNET_SCHEDULER_add_select (sched,
+                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
+                                    GNUNET_SCHEDULER_NO_TASK, delay,
+                                     rs, NULL, task, task_cls);
+  GNUNET_NETWORK_fdset_destroy (rs);
+  return ret;
+}
+
+
+/**
+ * Schedule a new task to be run with a specified delay or when the
+ * specified file descriptor is ready for writing.  The delay can be
+ * used as a timeout on the socket being ready.  The task will be
+ * scheduled for execution once either the delay has expired or the
+ * socket operation is ready. It will be run with the priority of
+ * the calling task.
+ *
+ * @param sched scheduler to use
+ * @param delay when should this operation time out? Use 
+ *        GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown"
+ * @param wfd write file-descriptor
+ * @param task main function of the task
+ * @param task_cls closure of task
+ * @return unique task identifier for the job
+ *         only valid until "task" is started!
+ */
+GNUNET_SCHEDULER_TaskIdentifier
+GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle *sched,
+                                struct GNUNET_TIME_Relative delay,
+                                const struct GNUNET_DISK_FileHandle *wfd,
+                                GNUNET_SCHEDULER_Task task, 
+                                void *task_cls)
+{
+  struct GNUNET_NETWORK_FDSet *ws;
+  GNUNET_SCHEDULER_TaskIdentifier ret;
+
+  GNUNET_assert (wfd != NULL);
+  ws = GNUNET_NETWORK_fdset_create ();
+  GNUNET_NETWORK_fdset_handle_set (ws, wfd);
+  ret = GNUNET_SCHEDULER_add_select (sched, 
+                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
+                                     GNUNET_SCHEDULER_NO_TASK, 
+                                    delay,
+                                     NULL, ws, task, task_cls);
   GNUNET_NETWORK_fdset_destroy (ws);
   return ret;
 }
 
 
+
 /**
  * Schedule a new task to be run with a specified delay or when any of
  * the specified file descriptor sets is ready.  The delay can be used
@@ -928,160 +996,61 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_SCHEDULER_Handle * sched,
  * </code>
  *
  * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown?  Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
  * @param prio how important is this task?
  * @param prerequisite_task run this task after the task with the given
  *        task identifier completes (and any of our other
  *        conditions, such as delay, read or write-readyness
  *        are satisfied).  Use GNUNET_SCHEDULER_NO_TASK to not have any dependency
  *        on completion of other tasks.
- * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever"
+ * @param delay how long should we wait? Use GNUNET_TIME_UNIT_FOREVER_REL for "forever",
+ *        which means that the task will only be run after we receive SIGTERM
  * @param rs set of file descriptors we want to read (can be NULL)
  * @param ws set of file descriptors we want to write (can be NULL)
- * @param main main function of the task
- * @param cls closure of task
+ * @param task main function of the task
+ * @param task_cls closure of task
  * @return unique task identifier for the job
- *         only valid until "main" is started!
+ *         only valid until "task" is started!
  */
 GNUNET_SCHEDULER_TaskIdentifier
-GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle * sched,
-                             int run_on_shutdown,
+GNUNET_SCHEDULER_add_select (struct GNUNET_SCHEDULER_Handle *sched,
                              enum GNUNET_SCHEDULER_Priority prio,
                              GNUNET_SCHEDULER_TaskIdentifier
                              prerequisite_task,
                              struct GNUNET_TIME_Relative delay,
                              const struct GNUNET_NETWORK_FDSet * rs,
-                             const struct GNUNET_NETWORK_FDSet * ws,
-                             GNUNET_SCHEDULER_Task main, void *cls)
+                            const struct GNUNET_NETWORK_FDSet * ws,
+                             GNUNET_SCHEDULER_Task task, 
+                            void *task_cls)
 {
-  struct Task *task;
+  struct Task *t;
 
-  task = GNUNET_malloc (sizeof (struct Task));
-  task->callback = main;
-  task->callback_cls = cls;
+  t = GNUNET_malloc (sizeof (struct Task));
+  t->callback = task;
+  t->callback_cls = task_cls;
   if (rs != NULL)
     {
-      task->read_set = GNUNET_NETWORK_fdset_create ();
-      GNUNET_NETWORK_fdset_copy (task->read_set, rs);
+      t->read_set = GNUNET_NETWORK_fdset_create ();
+      GNUNET_NETWORK_fdset_copy (t->read_set, rs);
     }
   if (ws != NULL)
     {
-      task->write_set = GNUNET_NETWORK_fdset_create ();
-      GNUNET_NETWORK_fdset_copy (task->write_set, ws);
+      t->write_set = GNUNET_NETWORK_fdset_create ();
+      GNUNET_NETWORK_fdset_copy (t->write_set, ws);
     }
-  task->id = ++sched->last_id;
-  task->prereq_id = prerequisite_task;
-  task->timeout = GNUNET_TIME_relative_to_absolute (delay);
-  task->priority =
+  t->id = ++sched->last_id;
+  t->prereq_id = prerequisite_task;
+  t->timeout = GNUNET_TIME_relative_to_absolute (delay);
+  t->priority =
     check_priority ((prio ==
                      GNUNET_SCHEDULER_PRIORITY_KEEP) ? sched->current_priority
                     : prio);
-  task->run_on_shutdown = run_on_shutdown;
-  task->next = sched->pending;
-  sched->pending = task;
+  t->next = sched->pending;
+  sched->pending = t;
 #if DEBUG_TASKS
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Adding task: %llu / %p\n", task->id, task->callback_cls);
+              "Adding task: %llu / %p\n", t->id, t->callback_cls);
 #endif
-  return task->id;
+  return t->id;
 }
 
-/**
- * Schedule a new task to be run with a specified delay or when the
- * specified file descriptor is ready for reading.  The delay can be
- * used as a timeout on the socket being ready.  The task will be
- * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
- *
- * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
- * @param rfd read file-descriptor
- * @param main main function of the task
- * @param cls closure of task
- * @return unique task identifier for the job
- *         only valid until "main" is started!
- */
-GNUNET_SCHEDULER_TaskIdentifier
-GNUNET_SCHEDULER_add_read_file (struct GNUNET_SCHEDULER_Handle * sched,
-                                int run_on_shutdown,
-                                enum GNUNET_SCHEDULER_Priority prio,
-                                GNUNET_SCHEDULER_TaskIdentifier
-                                prerequisite_task,
-                                struct GNUNET_TIME_Relative delay,
-                                const struct GNUNET_DISK_FileHandle * rfd,
-                                GNUNET_SCHEDULER_Task main, void *cls)
-{
-  struct GNUNET_NETWORK_FDSet *rs;
-  GNUNET_SCHEDULER_TaskIdentifier ret;
-
-  GNUNET_assert (rfd != NULL);
-  rs = GNUNET_NETWORK_fdset_create ();
-  GNUNET_NETWORK_fdset_handle_set (rs, rfd);
-  ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
-                                     prerequisite_task, delay,
-                                     rs, NULL, main, cls);
-  GNUNET_NETWORK_fdset_destroy (rs);
-  return ret;
-}
-
-
-/**
- * Schedule a new task to be run with a specified delay or when the
- * specified file descriptor is ready for writing.  The delay can be
- * used as a timeout on the socket being ready.  The task will be
- * scheduled for execution once either the delay has expired or the
- * socket operation is ready.
- *
- * @param sched scheduler to use
- * @param run_on_shutdown run on shutdown? Set this
- *        argument to GNUNET_NO to skip this task if
- *        the user requested process termination.
- * @param prio how important is this task?
- * @param prerequisite_task run this task after the task with the given
- *        task identifier completes (and any of our other
- *        conditions, such as delay, read or write-readyness
- *        are satisfied).  Use  GNUNET_SCHEDULER_NO_TASK to not have any dependency
- *        on completion of other tasks.
- * @param delay how long should we wait? Use  GNUNET_TIME_UNIT_FOREVER_REL for "forever"
- * @param wfd write file-descriptor
- * @param main main function of the task
- * @param cls closure of task
- * @return unique task identifier for the job
- *         only valid until "main" is started!
- */
-GNUNET_SCHEDULER_TaskIdentifier
-GNUNET_SCHEDULER_add_write_file (struct GNUNET_SCHEDULER_Handle * sched,
-                                 int run_on_shutdown,
-                                 enum GNUNET_SCHEDULER_Priority prio,
-                                 GNUNET_SCHEDULER_TaskIdentifier
-                                 prerequisite_task,
-                                 struct GNUNET_TIME_Relative delay,
-                                 const struct GNUNET_DISK_FileHandle * wfd,
-                                 GNUNET_SCHEDULER_Task main, void *cls)
-{
-  struct GNUNET_NETWORK_FDSet *ws;
-  GNUNET_SCHEDULER_TaskIdentifier ret;
-
-  GNUNET_assert (wfd != NULL);
-  ws = GNUNET_NETWORK_fdset_create ();
-  GNUNET_NETWORK_fdset_handle_set (ws, wfd);
-  ret = GNUNET_SCHEDULER_add_select (sched, run_on_shutdown, prio,
-                                     prerequisite_task, delay,
-                                     NULL, ws, main, cls);
-  GNUNET_NETWORK_fdset_destroy (ws);
-  return ret;
-}
-
-
 /* end of scheduler.c */
index 42fa8c46c5cf7b9b4dd91b6ade944c1bcf16c1ef..ff9c8c192bfddf71b9e8e8acb618e517c7ef23b6 100644 (file)
@@ -349,7 +349,6 @@ process_listen_socket (void *cls,
   GNUNET_NETWORK_fdset_set (r, server->listen_socket);
   GNUNET_NETWORK_fdset_handle_set (r, shutpipe);
   GNUNET_SCHEDULER_add_select (server->sched,
-                               GNUNET_YES,
                                GNUNET_SCHEDULER_PRIORITY_HIGH,
                                GNUNET_SCHEDULER_NO_TASK,
                                GNUNET_TIME_UNIT_FOREVER_REL,
@@ -475,7 +474,7 @@ GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched,
       GNUNET_NETWORK_fdset_handle_set (r,
                                        GNUNET_DISK_pipe_handle (ret->shutpipe,
                                                                 GNUNET_DISK_PIPE_END_READ));
-      GNUNET_SCHEDULER_add_select (sched, GNUNET_YES,
+      GNUNET_SCHEDULER_add_select (sched, 
                                    GNUNET_SCHEDULER_PRIORITY_HIGH,
                                    GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_UNIT_FOREVER_REL, r, NULL,
@@ -1167,7 +1166,6 @@ GNUNET_SERVER_receive_done (struct GNUNET_SERVER_Client *client, int success)
   if (GNUNET_YES != client->shutdown_now)
     {
       GNUNET_SCHEDULER_add_continuation (client->server->sched,
-                                         GNUNET_NO,
                                          &restart_processing,
                                          client,
                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);
index 0a33809bee40dad08fa17e88ad245823cfc4da99..173c0f566769a9ac166b6922179c990d39130bcf 100644 (file)
@@ -1067,6 +1067,22 @@ write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid)
 }
 
 
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+shutdown_task (void *cls,
+              const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_SERVER_Handle *server = cls;
+
+  GNUNET_SERVER_destroy (server);
+}
+
+
 /**
  * Initial task for the service.
  */
@@ -1092,6 +1108,10 @@ service_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       sctx->ret = GNUNET_SYSERR;
       return;
     }
+  GNUNET_SCHEDULER_add_delayed (tc->sched,
+                               GNUNET_TIME_UNIT_FOREVER_REL,
+                               &shutdown_task,
+                               sctx->server);
   sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers));
   memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers));
   i = 0;
@@ -1249,6 +1269,7 @@ pid_file_delete (struct GNUNET_SERVICE_Context *sctx)
   GNUNET_free (pif);
 }
 
+
 /**
  * Run a standard GNUnet service startup sequence (initialize loggers
  * and configuration, parse options).
@@ -1258,8 +1279,6 @@ pid_file_delete (struct GNUNET_SERVICE_Context *sctx)
  * @param serviceName our service name
  * @param task main task of the service
  * @param task_cls closure for task
- * @param term termination task of the service
- * @param term_cls closure for term
  * @return GNUNET_SYSERR on error, GNUNET_OK
  *         if we shutdown nicely
  */
@@ -1268,7 +1287,7 @@ GNUNET_SERVICE_run (int argc,
                     char *const *argv,
                     const char *serviceName,
                     GNUNET_SERVICE_Main task,
-                    void *task_cls, GNUNET_SERVICE_Term term, void *term_cls)
+                    void *task_cls)
 {
   char *cfg_fn;
   char *loglev;
@@ -1347,12 +1366,8 @@ GNUNET_SERVICE_run (int argc,
     }
 
   /* shutdown */
-  if (term != NULL)
-    term (term_cls, sctx.cfg);
   if ((do_daemonize == 1) && (sctx.server != NULL))
     pid_file_delete (&sctx);
-  if (sctx.server != NULL)
-    GNUNET_SERVER_destroy (sctx.server);
   GNUNET_free_non_null (sctx.my_handlers);
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_free_non_null (sctx.addr);
@@ -1413,8 +1428,6 @@ GNUNET_SERVICE_start (const char *serviceName,
   while ((sctx->my_handlers[i].callback != NULL))
     sctx->my_handlers[i++].callback_cls = sctx;
   GNUNET_SERVER_add_handlers (sctx->server, sctx->my_handlers);
-
-
   return sctx;
 }
 
index 0f4c46b3b15e70ebd14e57482571d61f45233758..07b5e843dd7792fc3b5fefd1dbf1de3c176ece8e 100644 (file)
@@ -175,9 +175,6 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test prepares to accept\n");
 #endif
   GNUNET_SCHEDULER_add_read_net (tc->sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                 GNUNET_SCHEDULER_NO_TASK,
                                  GNUNET_TIME_UNIT_FOREVER_REL,
                                  ls, &run_accept, cls);
 }
index 1b85dfac6d859e4db50784d661f4532461b061af..d6ac309f7edbc89fbc8832b6fe03c04f00b39ea9 100644 (file)
@@ -169,9 +169,6 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                                           &make_hello, NULL));
   GNUNET_CONNECTION_destroy (csock);
   GNUNET_SCHEDULER_add_read_net (tc->sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                 GNUNET_SCHEDULER_NO_TASK,
                                  GNUNET_TIME_UNIT_FOREVER_REL,
                                  ls, &run_accept, cls);
 }
index 5856e27ed501e92f14b4ef34d1427a7be4610a9b..b90191384d587bea5c0632ba7a79346b71ec7a8c 100644 (file)
@@ -124,15 +124,9 @@ task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                                  "localhost", PORT, 1024);
   GNUNET_assert (csock != NULL);
   GNUNET_SCHEDULER_add_read_net (tc->sched,
-                                 GNUNET_NO,
-                                 GNUNET_SCHEDULER_PRIORITY_HIGH,
-                                 GNUNET_SCHEDULER_NO_TASK,
                                  GNUNET_TIME_UNIT_FOREVER_REL,
                                  ls, &run_accept_cancel, cls);
   GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_SECONDS,
                                 &receive_cancel_task, cls);
 }
index 97ef4ec885baf12a69c0f3a39a1b67026bfe415d..b650355c09ce67f2b99ab19d6615928fd8a9f242 100644 (file)
@@ -124,7 +124,7 @@ file_hasher (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GNUNET_CRYPTO_hash_file (tc->sched,
                            GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                           GNUNET_NO, FILENAME, 1024, &finished_task, cls);
+                           FILENAME, 1024, &finished_task, cls);
 }
 
 
index 98dce6f97db2293fc64c739844c9122e78e419e9..3021dce19fc8ecb388a1f62353ebdea0da360fa1 100644 (file)
 
 #define VERBOSE GNUNET_NO
 
-static void
-task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-  int *ok = cls;
-  GNUNET_assert (2 == *ok);
-  (*ok) = 3;
-}
-
 static void
 task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -48,6 +40,19 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   (*ok) = 4;
 }
 
+
+static void
+task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  int *ok = cls;
+  GNUNET_assert (2 == *ok);
+  (*ok) = 3;
+  /* t3 will go before t4: higher priority */
+  GNUNET_SCHEDULER_add_with_priority (tc->sched,                                 
+                                     GNUNET_SCHEDULER_PRIORITY_UI,
+                                     &task3, cls);
+}
+
 static void
 task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -96,14 +101,9 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0]));
   GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1));
   (*ok) = 8;
-  GNUNET_SCHEDULER_add_after (tc->sched,
-                              GNUNET_NO,
-                              GNUNET_SCHEDULER_PRIORITY_UI,
-                              0, &taskNeverRun, NULL);
-  GNUNET_SCHEDULER_add_after (tc->sched,
-                              GNUNET_YES,
-                              GNUNET_SCHEDULER_PRIORITY_IDLE,
-                              0, &taskLast, cls);
+  GNUNET_SCHEDULER_add_with_priority (tc->sched,
+                                     GNUNET_SCHEDULER_PRIORITY_IDLE,
+                                     &taskLast, cls);
   GNUNET_SCHEDULER_shutdown (tc->sched);
 }
 
@@ -119,15 +119,9 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ);
   fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE);
   GNUNET_SCHEDULER_add_read_file (tc->sched,
-                                  GNUNET_NO,
-                                  GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                  GNUNET_SCHEDULER_NO_TASK,
                                   GNUNET_TIME_UNIT_FOREVER_REL,
                                   fds[0], &taskRd, cls);
   GNUNET_SCHEDULER_add_write_file (tc->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                   GNUNET_SCHEDULER_NO_TASK,
                                    GNUNET_TIME_UNIT_FOREVER_REL,
                                    fds[1], &taskWrt, cls);
 }
@@ -144,24 +138,13 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   (*ok) = 2;
   /* t2 will go first -- prereq for all */
   t2 = GNUNET_SCHEDULER_add_after (tc->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
                                    GNUNET_SCHEDULER_NO_TASK, &task2, cls);
-  /* t3 will go before t4: higher priority */
+  /* t4 will go after t2 ('add after') and after t3 (priority) */
   t4 = GNUNET_SCHEDULER_add_after (tc->sched,
-                                   GNUNET_NO,
-                                   GNUNET_SCHEDULER_PRIORITY_IDLE,
                                    t2, &task4, cls);
-  GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                t2,
-                                GNUNET_TIME_relative_get_zero (),
-                                &task3, cls);
-  /* t4 will go first: lower prio, but prereq! */
+  /* t5 will go last (after p4) */
   GNUNET_SCHEDULER_add_after (tc->sched,
-                              GNUNET_NO,
-                              GNUNET_SCHEDULER_PRIORITY_UI, t4, &task5, cls);
+                              t4, &task5, cls);
 }
 
 
@@ -181,21 +164,48 @@ check ()
 }
 
 
+static void
+taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  int *ok = cls;
+  GNUNET_assert (1 == *ok);
+  *ok = 8;
+  GNUNET_SCHEDULER_add_delayed (tc->sched,
+                               GNUNET_TIME_UNIT_FOREVER_REL,
+                               &taskLast, cls);
+  GNUNET_SCHEDULER_shutdown (tc->sched);
+}
+
+
+/**
+ * Main method, starts scheduler with task1,
+ * checks that "ok" is correct at the end.
+ */
+static int
+checkShutdown ()
+{
+  int ok;
+
+  ok = 1;
+  GNUNET_SCHEDULER_run (&taskShutdown, &ok);
+  return ok;
+}
+
+
 static void
 taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   int *ok = cls;
   GNUNET_assert (1 == *ok);
   *ok = 8;
-  GNUNET_SCHEDULER_add_after (tc->sched,
-                              GNUNET_NO,
-                              GNUNET_SCHEDULER_PRIORITY_UI,
-                              0, &taskNeverRun, NULL);
-  GNUNET_SCHEDULER_add_after (tc->sched,
-                              GNUNET_YES,
-                              GNUNET_SCHEDULER_PRIORITY_UI,
-                              0, &taskLast, cls);
+  GNUNET_SCHEDULER_add_delayed (tc->sched,
+                               GNUNET_TIME_UNIT_FOREVER_REL,
+                               &taskLast, cls);
+#ifndef MINGW
   GNUNET_break (0 == PLIBC_KILL (getpid (), SIGTERM));
+#else
+  GNUNET_SCHEDULER_shutdown (tc->sched);
+#endif
 }
 
 
@@ -214,8 +224,6 @@ checkSignal ()
 }
 
 
-
-
 static void
 taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -225,9 +233,7 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   *ok = 0;
   GNUNET_SCHEDULER_cancel (tc->sched,
                            GNUNET_SCHEDULER_add_after (tc->sched,
-                                                       GNUNET_NO,
-                                                       GNUNET_SCHEDULER_PRIORITY_UI,
-                                                       0,
+                                                       GNUNET_SCHEDULER_NO_TASK,
                                                        &taskNeverRun, NULL));
 }
 
@@ -256,6 +262,7 @@ main (int argc, char *argv[])
   GNUNET_log_setup ("test_scheduler", "WARNING", NULL);
   ret += check ();
   ret += checkSignal ();
+  ret += checkShutdown ();
   ret += checkCancel ();
   GNUNET_DISK_pipe_close (p);
 
index f5477fd4c4922a5317f8fb7419ef6f54df522649..d1d61c3e4b1b69b754b57521a7c486046de78088 100644 (file)
@@ -66,9 +66,6 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       return;
     }
   GNUNET_SCHEDULER_add_delayed (tc->sched,
-                                GNUNET_NO,
-                                GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_relative_multiply
                                 (GNUNET_TIME_UNIT_MILLISECONDS, i),
                                 &test_task, NULL);
index ae5609de0a5fce6be3d8fbfeed8c44b7e7115437..95206c0f137e68cea52e04943e2cfda977053ba4 100644 (file)
@@ -100,9 +100,6 @@ my_receive (void *cls,
       stctx->cb = receiver;
       stctx->cb_cls = receiver_cls;
       ret = GNUNET_SCHEDULER_add_delayed (sched,
-                                          GNUNET_NO,
-                                          GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                          GNUNET_SCHEDULER_NO_TASK,
                                           timeout, &signal_timeout, stctx);
       break;
     default:
index c5ce5e73648abb1d5598e2700d5a3380565c5c48..30fc34b08462defaa65b4face36d9c02cb0dd5f5 100644 (file)
@@ -95,9 +95,6 @@ recv_cb (void *cls,
     case 2:
       ok++;
       GNUNET_SCHEDULER_add_delayed (sched,
-                                    GNUNET_YES,
-                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                    GNUNET_SCHEDULER_NO_TASK,
                                     GNUNET_TIME_relative_multiply
                                     (GNUNET_TIME_UNIT_MILLISECONDS, 50),
                                     &send_done, argclient);
@@ -105,9 +102,6 @@ recv_cb (void *cls,
     case 4:
       ok++;
       GNUNET_SCHEDULER_add_delayed (sched,
-                                    GNUNET_YES,
-                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                    GNUNET_SCHEDULER_NO_TASK,
                                     GNUNET_TIME_relative_multiply
                                     (GNUNET_TIME_UNIT_MILLISECONDS, 50),
                                     &server_disconnect, argclient);
index 508c505b1fba79f174d26d10837d02add2379678..860ed3837ad2ad25f7c11be3ad51f0a6aed96677 100644 (file)
@@ -87,9 +87,6 @@ recv_cb (void *cls,
     case 2:
       ok++;
       GNUNET_SCHEDULER_add_delayed (sched,
-                                    GNUNET_YES,
-                                    GNUNET_SCHEDULER_PRIORITY_KEEP,
-                                    GNUNET_SCHEDULER_NO_TASK,
                                     GNUNET_TIME_relative_multiply
                                     (GNUNET_TIME_UNIT_MILLISECONDS, 50),
                                     &send_done, argclient);
index 93cafb4d2883c2d168e369f468d8bfedea1a56c1..fa35da6e9cd4a27eecb760cb6869f6cb421e837d 100644 (file)
@@ -30,6 +30,7 @@
 #include "gnunet_scheduler_lib.h"
 #include "gnunet_time_lib.h"
 
+
 #define VERBOSE GNUNET_NO
 
 #define PORT 12435
@@ -40,6 +41,9 @@ static struct GNUNET_SCHEDULER_Handle *sched;
 
 static struct GNUNET_SERVICE_Context *sctx;
 
+static int ok = 1;
+
+
 static void
 end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -47,8 +51,11 @@ end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down service\n");
   GNUNET_CLIENT_service_shutdown (client);
-  if (sctx != NULL)
+  if (sctx != NULL)    
     GNUNET_SERVICE_stop (sctx);
+  else
+    GNUNET_SCHEDULER_shutdown (sched);
+  ok = 0;
 }
 
 
@@ -63,7 +70,6 @@ build_msg (void *cls, size_t size, void *buf)
   msg->type = htons (MY_TYPE);
   msg->size = htons (sizeof (struct GNUNET_MessageHeader));
   GNUNET_SCHEDULER_add_continuation (sched,
-                                     GNUNET_YES,
                                      &end_it,
                                      client,
                                      GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -103,6 +109,9 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = {
   {NULL, NULL, 0, 0}
 };
 
+
+
+
 static void
 runner (void *cls,
         struct GNUNET_SCHEDULER_Handle *sched,
@@ -117,12 +126,6 @@ runner (void *cls,
                               (void *) cfg);
 }
 
-static void
-term (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
-  int *ok = cls;
-  *ok = 0;
-}
 
 /**
  * Main method, starts scheduler with task1,
@@ -131,7 +134,7 @@ term (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 static int
 check ()
 {
-  int ok = 1;
+  ok = 1;
   char *const argv[] = {
     "test_service",
     "-c",
@@ -149,12 +152,12 @@ check ()
                  GNUNET_SERVICE_run (5,
                                      argv,
                                      "test_service",
-                                     &runner, &ok, &term, &ok));
+                                     &runner, &ok));
   GNUNET_assert (0 == ok);
   return ok;
 }
 
-static void
+static void 
 ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
@@ -193,7 +196,6 @@ runner6 (void *cls,
 static int
 check6 ()
 {
-  int ok = 1;
   char *const argv[] = {
     "test_service6",
     "-c",
@@ -211,7 +213,7 @@ check6 ()
                  GNUNET_SERVICE_run (5,
                                      argv,
                                      "test_service6",
-                                     &runner6, &ok, &term, &ok));
+                                     &runner6, &ok));
   GNUNET_assert (0 == ok);
   return ok;
 }
@@ -224,7 +226,7 @@ check6 ()
 static int
 check6d ()
 {
-  int ok = 1;
+  ok = 1;
   char *const argv[] = {
     "test_service6",
     "-c",
@@ -243,7 +245,7 @@ check6d ()
                  GNUNET_SERVICE_run (6,
                                      argv,
                                      "test_service6",
-                                     &runner6, &ok, &term, &ok));
+                                     &runner6, &ok));
   GNUNET_break (0 == ok);
   return ok;
 }