gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9392 - in gnunet: . src/arm src/core src/datastore src/fs


From: gnunet
Subject: [GNUnet-SVN] r9392 - in gnunet: . src/arm src/core src/datastore src/fs src/hostlist src/include src/nat src/peerinfo src/statistics src/template src/testing src/topology src/transport src/util
Date: Wed, 4 Nov 2009 07:10:32 -0700

Author: grothoff
Date: 2009-11-04 07:10:32 -0700 (Wed, 04 Nov 2009)
New Revision: 9392

Modified:
   gnunet/BUGS
   gnunet/src/arm/gnunet-arm.c
   gnunet/src/arm/gnunet-service-arm.c
   gnunet/src/core/core_api.c
   gnunet/src/core/gnunet-service-core.c
   gnunet/src/core/test_core_api.c
   gnunet/src/core/test_core_api_start_only.c
   gnunet/src/datastore/gnunet-service-datastore.c
   gnunet/src/datastore/perf_datastore_api.c
   gnunet/src/datastore/perf_plugin_datastore.c
   gnunet/src/datastore/plugin_datastore_sqlite.c
   gnunet/src/datastore/test_datastore_api.c
   gnunet/src/datastore/test_datastore_api_management.c
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/fs_list_indexed.c
   gnunet/src/fs/fs_publish.c
   gnunet/src/fs/fs_search.c
   gnunet/src/fs/fs_tree.c
   gnunet/src/fs/fs_unindex.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/test_fs_download.c
   gnunet/src/fs/test_fs_list_indexed.c
   gnunet/src/fs/test_fs_publish.c
   gnunet/src/fs/test_fs_search.c
   gnunet/src/fs/test_fs_unindex.c
   gnunet/src/hostlist/gnunet-daemon-hostlist.c
   gnunet/src/hostlist/hostlist-client.c
   gnunet/src/hostlist/hostlist-server.c
   gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
   gnunet/src/include/gnunet_crypto_lib.h
   gnunet/src/include/gnunet_scheduler_lib.h
   gnunet/src/include/gnunet_service_lib.h
   gnunet/src/nat/nat.c
   gnunet/src/nat/test_nat.c
   gnunet/src/peerinfo/gnunet-service-peerinfo.c
   gnunet/src/peerinfo/test_peerinfo_api.c
   gnunet/src/statistics/gnunet-service-statistics.c
   gnunet/src/template/gnunet-service-template.c
   gnunet/src/testing/testing.c
   gnunet/src/topology/gnunet-daemon-topology.c
   gnunet/src/topology/test_gnunet_service_topology.c
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/test_plugin_transport.c
   gnunet/src/transport/transport_api.c
   gnunet/src/util/client.c
   gnunet/src/util/connection.c
   gnunet/src/util/crypto_hash.c
   gnunet/src/util/disk.c
   gnunet/src/util/gnunet-service-resolver.c
   gnunet/src/util/resolver_api.c
   gnunet/src/util/scheduler.c
   gnunet/src/util/server.c
   gnunet/src/util/service.c
   gnunet/src/util/test_connection.c
   gnunet/src/util/test_connection_addressing.c
   gnunet/src/util/test_connection_receive_cancel.c
   gnunet/src/util/test_crypto_hash.c
   gnunet/src/util/test_scheduler.c
   gnunet/src/util/test_scheduler_delay.c
   gnunet/src/util/test_server.c
   gnunet/src/util/test_server_disconnect.c
   gnunet/src/util/test_server_with_client.c
   gnunet/src/util/test_service.c
Log:
bugfixes and redesigning scheduler API

Modified: gnunet/BUGS
===================================================================
--- gnunet/BUGS 2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/BUGS 2009-11-04 14:10:32 UTC (rev 9392)
@@ -2,7 +2,11 @@
 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)
   - Windows: use events instead of pipes to signal select()s [Nils]

Modified: gnunet/src/arm/gnunet-arm.c
===================================================================
--- gnunet/src/arm/gnunet-arm.c 2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/arm/gnunet-arm.c 2009-11-04 14:10:32 UTC (rev 9392)
@@ -123,7 +123,6 @@
       break;
     }
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -147,7 +146,6 @@
   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 @@
       return;
     }
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &cps_loop,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);

Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/arm/gnunet-service-arm.c 2009-11-04 14:10:32 UTC (rev 9392)
@@ -516,9 +516,6 @@
       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 @@
     }
   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 @@
   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 @@
 {
   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 */

Modified: gnunet/src/core/core_api.c
===================================================================
--- gnunet/src/core/core_api.c  2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/core/core_api.c  2009-11-04 14:10:32 UTC (rev 9392)
@@ -320,9 +320,6 @@
     }
   /* 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 @@
             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 @@
   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 @@
   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;

Modified: gnunet/src/core/gnunet-service-core.c
===================================================================
--- gnunet/src/core/gnunet-service-core.c       2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/core/gnunet-service-core.c       2009-11-04 14:10:32 UTC (rev 
9392)
@@ -1703,9 +1703,6 @@
       /* 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 @@
   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 @@
                 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 @@
     }
   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 @@
                                         &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,18 +3200,7 @@
 }
 
 
-/**
- * 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 @@
   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 */

Modified: gnunet/src/core/test_core_api.c
===================================================================
--- gnunet/src/core/test_core_api.c     2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/core/test_core_api.c     2009-11-04 14:10:32 UTC (rev 9392)
@@ -172,9 +172,6 @@
   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 @@
   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 @@
                                         "-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);

Modified: gnunet/src/core/test_core_api_start_only.c
===================================================================
--- gnunet/src/core/test_core_api_start_only.c  2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/core/test_core_api_start_only.c  2009-11-04 14:10:32 UTC (rev 
9392)
@@ -166,7 +166,6 @@
                                         "-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);

Modified: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c     2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/datastore/gnunet-service-datastore.c     2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -260,9 +260,6 @@
     {
       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 @@
       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 @@
                  _("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 @@
   ret = (GNUNET_OK ==
          GNUNET_SERVICE_run (argc,
                              argv,
-                             "datastore", &run, NULL, NULL, NULL)) ? 0 : 1;
+                             "datastore", &run, NULL)) ? 0 : 1;
   return ret;
 }
 

Modified: gnunet/src/datastore/perf_datastore_api.c
===================================================================
--- gnunet/src/datastore/perf_datastore_api.c   2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/datastore/perf_datastore_api.c   2009-11-04 14:10:32 UTC (rev 
9392)
@@ -140,7 +140,6 @@
        crc->phase = RP_CUT;
     }
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -167,7 +166,6 @@
 #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 @@
        {
          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 @@
       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 @@
   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 @@
                                  "-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);

Modified: gnunet/src/datastore/perf_plugin_datastore.c
===================================================================
--- gnunet/src/datastore/perf_plugin_datastore.c        2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/datastore/perf_plugin_datastore.c        2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -168,8 +168,6 @@
            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 @@
       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 @@
       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 @@
   crc->cfg = c;
   crc->phase = RP_PUT;
   GNUNET_SCHEDULER_add_after (s,
-                             GNUNET_YES,
-                             GNUNET_SCHEDULER_PRIORITY_KEEP,
                              GNUNET_SCHEDULER_NO_TASK,
                              &test, crc);
 }

Modified: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c      2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c      2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -663,7 +663,6 @@
   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);

Modified: gnunet/src/datastore/test_datastore_api.c
===================================================================
--- gnunet/src/datastore/test_datastore_api.c   2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/datastore/test_datastore_api.c   2009-11-04 14:10:32 UTC (rev 
9392)
@@ -145,7 +145,6 @@
   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 @@
   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 @@
          crc->i = ITERATIONS;
        }
       GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                        GNUNET_NO,
                                         &run_continuation,
                                         crc,
                                         GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -226,7 +223,6 @@
     {
       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 @@
       crc->phase = RP_RESERVE;   
     }
   GNUNET_SCHEDULER_add_continuation (crc->sched,
-                                    GNUNET_NO,
                                     &run_continuation,
                                     crc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -284,7 +279,6 @@
       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 @@
       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 @@
   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 @@
                                  "-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);

Modified: gnunet/src/datastore/test_datastore_api_management.c
===================================================================
--- gnunet/src/datastore/test_datastore_api_management.c        2009-11-04 
08:51:00 UTC (rev 9391)
+++ gnunet/src/datastore/test_datastore_api_management.c        2009-11-04 
14:10:32 UTC (rev 9392)
@@ -133,7 +133,6 @@
   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 @@
       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 @@
   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 @@
   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 @@
                                  "-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);

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/fs_download.c 2009-11-04 14:10:32 UTC (rev 9392)
@@ -718,9 +718,6 @@
     }
   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);

Modified: gnunet/src/fs/fs_list_indexed.c
===================================================================
--- gnunet/src/fs/fs_list_indexed.c     2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/fs_list_indexed.c     2009-11-04 14:10:32 UTC (rev 9392)
@@ -91,7 +91,6 @@
                  "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 @@
     {
       /* 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 @@
                  "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 @@
                     &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 @@
                  _("Failed to not connect to `%s' service.\n"),
                  "fs");
       GNUNET_SCHEDULER_add_continuation (h->sched,
-                                        GNUNET_NO,
                                         cont,
                                         cont_cls,
                                         GNUNET_SCHEDULER_REASON_TIMEOUT);

Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c  2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/fs_publish.c  2009-11-04 14:10:32 UTC (rev 9392)
@@ -185,13 +185,10 @@
   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 @@
     {
       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 @@
   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 @@
     }
   /* 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 @@
   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 @@
       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 @@
   // 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 @@
       return;
     }
   GNUNET_SCHEDULER_add_continuation (pkc->h->sched,
-                                    GNUNET_NO,
                                     &publish_ksk_cont,
                                     pkc,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -1383,7 +1363,6 @@
   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);

Modified: gnunet/src/fs/fs_search.c
===================================================================
--- gnunet/src/fs/fs_search.c   2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/fs_search.c   2009-11-04 14:10:32 UTC (rev 9392)
@@ -720,9 +720,6 @@
     }
   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);

Modified: gnunet/src/fs/fs_tree.c
===================================================================
--- gnunet/src/fs/fs_tree.c     2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/fs_tree.c     2009-11-04 14:10:32 UTC (rev 9392)
@@ -287,7 +287,6 @@
                      &te->emsg))
        {
          GNUNET_SCHEDULER_add_continuation (te->h->sched,
-                                            GNUNET_NO,
                                             te->cont,
                                             te->cls,
                                             GNUNET_SCHEDULER_REASON_TIMEOUT);
@@ -309,7 +308,6 @@
       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);

Modified: gnunet/src/fs/fs_unindex.c
===================================================================
--- gnunet/src/fs/fs_unindex.c  2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/fs_unindex.c  2009-11-04 14:10:32 UTC (rev 9392)
@@ -420,7 +420,6 @@
               &pi);
   GNUNET_CRYPTO_hash_file (h->sched,
                           GNUNET_SCHEDULER_PRIORITY_IDLE,
-                          GNUNET_NO,
                           filename,
                           HASHING_BLOCKSIZE,
                           &process_hash,

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/gnunet-service-fs.c   2009-11-04 14:10:32 UTC (rev 9392)
@@ -1075,7 +1075,6 @@
   /* 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 @@
   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 @@
   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 @@
   
   /* (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 @@
     {
       /* 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 @@
     {
       /* 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 @@
     {
       /* 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 @@
     {
       /* 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 @@
                                             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 @@
 
   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 @@
       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 @@
             (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 @@
                                 pgc);
   else
     GNUNET_SCHEDULER_add_continuation (sched,
-                                      GNUNET_NO,
                                       &forward_get_request,
                                       pgc,
                                       GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -3338,9 +3307,6 @@
   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 @@
   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 @@
   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 */

Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c    2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/test_fs_download.c    2009-11-04 14:10:32 UTC (rev 9392)
@@ -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 @@
       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 @@
               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 @@
               "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 @@
     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);

Modified: gnunet/src/fs/test_fs_list_indexed.c
===================================================================
--- gnunet/src/fs/test_fs_list_indexed.c        2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/fs/test_fs_list_indexed.c        2009-11-04 14:10:32 UTC (rev 
9392)
@@ -97,7 +97,6 @@
 {
 
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &abort_publish_task,
                                     NULL,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -120,7 +119,6 @@
       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 @@
       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);

Modified: gnunet/src/fs/test_fs_publish.c
===================================================================
--- gnunet/src/fs/test_fs_publish.c     2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/test_fs_publish.c     2009-11-04 14:10:32 UTC (rev 9392)
@@ -106,7 +106,6 @@
       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 @@
       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 @@
        {
          GNUNET_assert (publish == event->value.publish.sc);
          GNUNET_SCHEDULER_add_continuation (sched,
-                                            GNUNET_NO,
                                             &abort_publish_task,
                                             NULL,
                                             
GNUNET_SCHEDULER_REASON_PREREQ_DONE);

Modified: gnunet/src/fs/test_fs_search.c
===================================================================
--- gnunet/src/fs/test_fs_search.c      2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/test_fs_search.c      2009-11-04 14:10:32 UTC (rev 9392)
@@ -124,7 +124,6 @@
       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 @@
               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 @@
               "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 @@
     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);

Modified: gnunet/src/fs/test_fs_unindex.c
===================================================================
--- gnunet/src/fs/test_fs_unindex.c     2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/fs/test_fs_unindex.c     2009-11-04 14:10:32 UTC (rev 9392)
@@ -121,7 +121,6 @@
       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 @@
               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 @@
               "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 @@
     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);

Modified: gnunet/src/hostlist/gnunet-daemon-hostlist.c
===================================================================
--- gnunet/src/hostlist/gnunet-daemon-hostlist.c        2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/hostlist/gnunet-daemon-hostlist.c        2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -177,9 +177,6 @@
                       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);
 }

Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c       2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/hostlist/hostlist-client.c       2009-11-04 14:10:32 UTC (rev 
9392)
@@ -404,7 +404,6 @@
   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 @@
                         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);

Modified: gnunet/src/hostlist/hostlist-server.c
===================================================================
--- gnunet/src/hostlist/hostlist-server.c       2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/hostlist/hostlist-server.c       2009-11-04 14:10:32 UTC (rev 
9392)
@@ -92,9 +92,6 @@
   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 @@
   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,

Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist.c   2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist.c   2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -95,7 +95,6 @@
                                         "-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);

Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h      2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/include/gnunet_crypto_lib.h      2009-11-04 14:10:32 UTC (rev 
9392)
@@ -370,7 +370,6 @@
  *
  * @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 @@
  */
 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,

Modified: gnunet/src/include/gnunet_scheduler_lib.h
===================================================================
--- gnunet/src/include/gnunet_scheduler_lib.h   2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/include/gnunet_scheduler_lib.h   2009-11-04 14:10:32 UTC (rev 
9392)
@@ -197,21 +197,30 @@
 
 
 /**
- * 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_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 @@
  * 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 @@
  * 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 @@
  * 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 @@
  * 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 @@
  * </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 */
 {

Modified: gnunet/src/include/gnunet_service_lib.h
===================================================================
--- gnunet/src/include/gnunet_service_lib.h     2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/include/gnunet_service_lib.h     2009-11-04 14:10:32 UTC (rev 
9392)
@@ -55,18 +55,6 @@
 
 
 /**
- * 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 @@
  * @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 @@
                         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;

Modified: gnunet/src/nat/nat.c
===================================================================
--- gnunet/src/nat/nat.c        2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/nat/nat.c        2009-11-04 14:10:32 UTC (rev 9392)
@@ -285,9 +285,7 @@
       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 @@
   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);
 

Modified: gnunet/src/nat/test_nat.c
===================================================================
--- gnunet/src/nat/test_nat.c   2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/nat/test_nat.c   2009-11-04 14:10:32 UTC (rev 9392)
@@ -125,9 +125,7 @@
   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);
 }

Modified: gnunet/src/peerinfo/gnunet-service-peerinfo.c
===================================================================
--- gnunet/src/peerinfo/gnunet-service-peerinfo.c       2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/peerinfo/gnunet-service-peerinfo.c       2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -342,6 +342,8 @@
   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 @@
                 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 @@
       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 @@
 {
   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 @@
 };
 
 
+
 /**
  * Process statistics requests.
  *
@@ -686,23 +683,15 @@
                                                           &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 @@
   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;

Modified: gnunet/src/peerinfo/test_peerinfo_api.c
===================================================================
--- gnunet/src/peerinfo/test_peerinfo_api.c     2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/peerinfo/test_peerinfo_api.c     2009-11-04 14:10:32 UTC (rev 
9392)
@@ -149,7 +149,6 @@
                                  "-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);

Modified: gnunet/src/statistics/gnunet-service-statistics.c
===================================================================
--- gnunet/src/statistics/gnunet-service-statistics.c   2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/statistics/gnunet-service-statistics.c   2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -83,6 +83,11 @@
 };
 
 /**
+ * Our configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+/**
  * Linked list of our active statistics.
  */
 static struct StatsEntry *start;
@@ -96,10 +101,11 @@
  * 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 @@
   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;
@@ -435,21 +436,40 @@
 
 
 /**
+ * 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 @@
   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 */

Modified: gnunet/src/template/gnunet-service-template.c
===================================================================
--- gnunet/src/template/gnunet-service-template.c       2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/template/gnunet-service-template.c       2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -27,20 +27,7 @@
 #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
  * service.
@@ -50,7 +37,22 @@
   {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.
  *
  * @param cls closure
@@ -66,6 +68,10 @@
 {
   /* 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 @@
   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 */

Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c        2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/testing/testing.c        2009-11-04 14:10:32 UTC (rev 9392)
@@ -306,9 +306,6 @@
          /* 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 @@
       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 @@
          /* 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 @@
          /* 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 @@
          /* 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 @@
        }
       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 @@
 #endif
   ret->phase = SP_COPIED;
   GNUNET_SCHEDULER_add_continuation (sched,
-                                    GNUNET_NO,
                                     &start_fsm,
                                     ret,
                                     GNUNET_SCHEDULER_REASON_PREREQ_DONE);
@@ -781,9 +762,6 @@
       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 @@
   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 @@
   GNUNET_TRANSPORT_disconnect (ctx->d2th);
   ctx->d2th = NULL;
   GNUNET_SCHEDULER_add_continuation (ctx->d1->sched,
-                                    GNUNET_NO,
                                     &notify_connect_result,
                                     ctx,
                                     (buf == NULL) ? 

Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c        2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/topology/gnunet-daemon-topology.c        2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -523,9 +523,6 @@
              (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 @@
 #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 @@
                       handlers);
 
   GNUNET_SCHEDULER_add_delayed (sched,
-                                GNUNET_YES,
-                                GNUNET_SCHEDULER_PRIORITY_IDLE,
-                                GNUNET_SCHEDULER_NO_TASK,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &cleaning_task, NULL);
 }

Modified: gnunet/src/topology/test_gnunet_service_topology.c
===================================================================
--- gnunet/src/topology/test_gnunet_service_topology.c  2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/topology/test_gnunet_service_topology.c  2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -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?

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/transport/gnunet-service-transport.c     2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -710,9 +710,9 @@
       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 @@
     }
   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 @@
   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 @@
          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 @@
                  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 @@
       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 @@
   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 @@
   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 @@
       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 @@
          GNUNET_SERVICE_run (argc,
                              argv,
                              "transport",
-                             &run, NULL, NULL, NULL)) ? 0 : 1;
+                             &run, NULL)) ? 0 : 1;
 }
 
 /* end of gnunet-service-transport.c */

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/transport/plugin_transport_tcp.c 2009-11-04 14:10:32 UTC (rev 
9392)
@@ -1898,9 +1898,6 @@
     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);
 }
 

Modified: gnunet/src/transport/test_plugin_transport.c
===================================================================
--- gnunet/src/transport/test_plugin_transport.c        2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/transport/test_plugin_transport.c        2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -179,7 +179,6 @@
      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 @@
   /* 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);

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/transport/transport_api.c        2009-11-04 14:10:32 UTC (rev 
9392)
@@ -625,9 +625,6 @@
   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 @@
   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 @@
   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 @@
                  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 @@
       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 @@
   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 @@
          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 @@
   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 @@
 #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 @@
 #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 @@
              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 @@
 #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;
     }

Modified: gnunet/src/util/client.c
===================================================================
--- gnunet/src/util/client.c    2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/client.c    2009-11-04 14:10:32 UTC (rev 9392)
@@ -308,8 +308,6 @@
     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 @@
   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 @@
 
   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 @@
   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 @@
                     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 @@
                   "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 @@
       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;

Modified: gnunet/src/util/connection.c
===================================================================
--- gnunet/src/util/connection.c        2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/connection.c        2009-11-04 14:10:32 UTC (rev 9392)
@@ -476,8 +476,6 @@
                   "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 @@
   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 @@
 #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 @@
       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 @@
 #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 @@
 #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 @@
       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 @@
 #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 @@
                                       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_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 @@
   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 @@
   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 @@
       (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 @@
                   "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 @@
 #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);

Modified: gnunet/src/util/crypto_hash.c
===================================================================
--- gnunet/src/util/crypto_hash.c       2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/crypto_hash.c       2009-11-04 14:10:32 UTC (rev 9392)
@@ -416,11 +416,6 @@
   uint64_t offset;
 
   /**
-   * Run on shutdown?
-   */
-  int run_on_shutdown;
-
-  /**
    * File descriptor.
    */
   struct GNUNET_DISK_FileHandle *fh;
@@ -476,8 +471,6 @@
       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 @@
  *
  * @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 @@
 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 @@
       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 @@
       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);
 }
 
 

Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c      2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/disk.c      2009-11-04 14:10:32 UTC (rev 9392)
@@ -856,11 +856,9 @@
       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;
 }
 

Modified: gnunet/src/util/gnunet-service-resolver.c
===================================================================
--- gnunet/src/util/gnunet-service-resolver.c   2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/util/gnunet-service-resolver.c   2009-11-04 14:10:32 UTC (rev 
9392)
@@ -516,7 +516,7 @@
   ret = (GNUNET_OK ==
          GNUNET_SERVICE_run (argc,
                              argv,
-                             "resolver", &run, NULL, NULL, NULL)) ? 0 : 1;
+                             "resolver", &run, NULL)) ? 0 : 1;
 
   while (head != NULL)
     {

Modified: gnunet/src/util/resolver_api.c
===================================================================
--- gnunet/src/util/resolver_api.c      2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/resolver_api.c      2009-11-04 14:10:32 UTC (rev 9392)
@@ -442,9 +442,6 @@
        ((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 @@
     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 @@
   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;

Modified: gnunet/src/util/scheduler.c
===================================================================
--- gnunet/src/util/scheduler.c 2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/scheduler.c 2009-11-04 14:10:32 UTC (rev 9392)
@@ -95,11 +95,6 @@
    */
   enum GNUNET_SCHEDULER_Priority priority;
 
-  /**
-   * Should this task be run on shutdown?
-   */
-  int run_on_shutdown;
-
 };
 
 
@@ -135,12 +130,6 @@
   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.
    */
   unsigned int ready_count;
@@ -260,6 +249,8 @@
         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 @@
           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)))
@@ -395,6 +381,32 @@
 
 
 /**
+ * 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)
  *
  * @param t task to destroy
@@ -415,7 +427,7 @@
  * 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 @@
   while ((sched->pending == NULL) || (p == GNUNET_SCHEDULER_PRIORITY_URGENT));
 }
 
-
+#ifndef MINGW
 /**
  * Pipe used to communicate shutdown via signal.
  */
@@ -478,19 +490,25 @@
                           (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 @@
   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_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 @@
       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,37 +602,12 @@
   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
  * function to determine if an elective task should be added or simply
@@ -715,102 +709,113 @@
  * 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;
+  struct Task *t;
 
-  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;
+  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 @@
  * 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_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 @@
  * 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,15 +889,96 @@
   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
  * as a timeout on the socket(s) being ready.  The task will be
@@ -928,160 +996,61 @@
  * </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 */

Modified: gnunet/src/util/server.c
===================================================================
--- gnunet/src/util/server.c    2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/server.c    2009-11-04 14:10:32 UTC (rev 9392)
@@ -349,7 +349,6 @@
   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_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 @@
   if (GNUNET_YES != client->shutdown_now)
     {
       GNUNET_SCHEDULER_add_continuation (client->server->sched,
-                                         GNUNET_NO,
                                          &restart_processing,
                                          client,
                                          GNUNET_SCHEDULER_REASON_PREREQ_DONE);

Modified: gnunet/src/util/service.c
===================================================================
--- gnunet/src/util/service.c   2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/service.c   2009-11-04 14:10:32 UTC (rev 9392)
@@ -1068,6 +1068,22 @@
 
 
 /**
+ * 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.
  */
 static void
@@ -1092,6 +1108,10 @@
       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 @@
   GNUNET_free (pif);
 }
 
+
 /**
  * Run a standard GNUnet service startup sequence (initialize loggers
  * and configuration, parse options).
@@ -1258,8 +1279,6 @@
  * @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 @@
                     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 @@
     }
 
   /* 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 @@
   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;
 }
 

Modified: gnunet/src/util/test_connection.c
===================================================================
--- gnunet/src/util/test_connection.c   2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/test_connection.c   2009-11-04 14:10:32 UTC (rev 9392)
@@ -175,9 +175,6 @@
   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);
 }

Modified: gnunet/src/util/test_connection_addressing.c
===================================================================
--- gnunet/src/util/test_connection_addressing.c        2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/util/test_connection_addressing.c        2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -169,9 +169,6 @@
                                                           &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);
 }

Modified: gnunet/src/util/test_connection_receive_cancel.c
===================================================================
--- gnunet/src/util/test_connection_receive_cancel.c    2009-11-04 08:51:00 UTC 
(rev 9391)
+++ gnunet/src/util/test_connection_receive_cancel.c    2009-11-04 14:10:32 UTC 
(rev 9392)
@@ -124,15 +124,9 @@
                                                  "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);
 }

Modified: gnunet/src/util/test_crypto_hash.c
===================================================================
--- gnunet/src/util/test_crypto_hash.c  2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/test_crypto_hash.c  2009-11-04 14:10:32 UTC (rev 9392)
@@ -124,7 +124,7 @@
 {
   GNUNET_CRYPTO_hash_file (tc->sched,
                            GNUNET_SCHEDULER_PRIORITY_DEFAULT,
-                           GNUNET_NO, FILENAME, 1024, &finished_task, cls);
+                           FILENAME, 1024, &finished_task, cls);
 }
 
 

Modified: gnunet/src/util/test_scheduler.c
===================================================================
--- gnunet/src/util/test_scheduler.c    2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/test_scheduler.c    2009-11-04 14:10:32 UTC (rev 9392)
@@ -30,14 +30,6 @@
 #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)
 {
   int *ok = cls;
@@ -48,7 +40,20 @@
   (*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)
 {
   int *ok = cls;
@@ -96,14 +101,9 @@
   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 @@
   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 @@
   (*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);
 }
 
 
@@ -182,20 +165,47 @@
 
 
 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 @@
 }
 
 
-
-
 static void
 taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -225,9 +233,7 @@
   *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 @@
   GNUNET_log_setup ("test_scheduler", "WARNING", NULL);
   ret += check ();
   ret += checkSignal ();
+  ret += checkShutdown ();
   ret += checkCancel ();
   GNUNET_DISK_pipe_close (p);
 

Modified: gnunet/src/util/test_scheduler_delay.c
===================================================================
--- gnunet/src/util/test_scheduler_delay.c      2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/util/test_scheduler_delay.c      2009-11-04 14:10:32 UTC (rev 
9392)
@@ -66,9 +66,6 @@
       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);

Modified: gnunet/src/util/test_server.c
===================================================================
--- gnunet/src/util/test_server.c       2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/test_server.c       2009-11-04 14:10:32 UTC (rev 9392)
@@ -100,9 +100,6 @@
       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:

Modified: gnunet/src/util/test_server_disconnect.c
===================================================================
--- gnunet/src/util/test_server_disconnect.c    2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/util/test_server_disconnect.c    2009-11-04 14:10:32 UTC (rev 
9392)
@@ -95,9 +95,6 @@
     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 @@
     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);

Modified: gnunet/src/util/test_server_with_client.c
===================================================================
--- gnunet/src/util/test_server_with_client.c   2009-11-04 08:51:00 UTC (rev 
9391)
+++ gnunet/src/util/test_server_with_client.c   2009-11-04 14:10:32 UTC (rev 
9392)
@@ -87,9 +87,6 @@
     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);

Modified: gnunet/src/util/test_service.c
===================================================================
--- gnunet/src/util/test_service.c      2009-11-04 08:51:00 UTC (rev 9391)
+++ gnunet/src/util/test_service.c      2009-11-04 14:10:32 UTC (rev 9392)
@@ -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_SERVICE_Context *sctx;
 
+static int ok = 1;
+
+
 static void
 end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -47,8 +51,11 @@
 
   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 @@
   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 @@
   {NULL, NULL, 0, 0}
 };
 
+
+
+
 static void
 runner (void *cls,
         struct GNUNET_SCHEDULER_Handle *sched,
@@ -117,12 +126,6 @@
                               (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 @@
 static int
 check ()
 {
-  int ok = 1;
+  ok = 1;
   char *const argv[] = {
     "test_service",
     "-c",
@@ -149,12 +152,12 @@
                  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 @@
 static int
 check6 ()
 {
-  int ok = 1;
   char *const argv[] = {
     "test_service6",
     "-c",
@@ -211,7 +213,7 @@
                  GNUNET_SERVICE_run (5,
                                      argv,
                                      "test_service6",
-                                     &runner6, &ok, &term, &ok));
+                                     &runner6, &ok));
   GNUNET_assert (0 == ok);
   return ok;
 }
@@ -224,7 +226,7 @@
 static int
 check6d ()
 {
-  int ok = 1;
+  ok = 1;
   char *const argv[] = {
     "test_service6",
     "-c",
@@ -243,7 +245,7 @@
                  GNUNET_SERVICE_run (6,
                                      argv,
                                      "test_service6",
-                                     &runner6, &ok, &term, &ok));
+                                     &runner6, &ok));
   GNUNET_break (0 == ok);
   return ok;
 }





reply via email to

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