From 95f9076a2139f5fb042b944a0658b6cda2fa35db Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 30 Apr 2016 08:17:37 +0000 Subject: implementing new scheduler shutdown semantics --- src/namestore/gnunet-namestore-fcfsd.c | 3 +-- src/namestore/gnunet-namestore.c | 3 +-- src/namestore/gnunet-service-namestore.c | 4 ++-- src/namestore/plugin_rest_namestore.c | 26 +++++++++++++++++++++----- 4 files changed, 25 insertions(+), 11 deletions(-) (limited to 'src/namestore') diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index 82d73f6de..c2f506f6d 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c @@ -988,8 +988,7 @@ run (void *cls, char *const *args, const char *cfgfile, } id_op = GNUNET_IDENTITY_get (identity, "fcfsd", &identity_cb, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &do_shutdown, NULL); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); } diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 0965d8cbe..90214e9d6 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c @@ -1006,8 +1006,7 @@ testservice_id_task (void *cls, int result) ret = -1; return; } - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, - &do_shutdown, (void *) cfg); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg); if (NULL == ego_name) { diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 0bfd002f5..4be55cf9b 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -1689,8 +1689,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, GNUNET_SERVER_disconnect_notify (server, &client_disconnect_notification, NULL); - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, - NULL); + GNUNET_SCHEDULER_add_shutdown (&cleanup_task, + NULL); } diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index cfebd63a7..4612528c6 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c @@ -242,6 +242,7 @@ struct RequestHandle /** * Cleanup lookup handle + * * @param handle Handle to clean up */ static void @@ -250,6 +251,7 @@ cleanup_handle (struct RequestHandle *handle) struct RecordEntry *record_entry; struct RecordEntry *record_tmp; int i; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); if (NULL != handle->resp_object) @@ -295,6 +297,7 @@ cleanup_handle (struct RequestHandle *handle) GNUNET_free (handle); } + /** * Create json representation of a GNSRECORD * @@ -350,9 +353,9 @@ gnsrecord_to_json (const struct GNUNET_GNSRECORD_Data *rd) /** - * Task run on shutdown. Cleans up everything. + * Task run on error. Generates error response and cleans up. * - * @param cls unused + * @param cls the request to generate an error response for */ static void do_error (void *cls) @@ -365,6 +368,21 @@ do_error (void *cls) } +/** + * Task run on timeout. + * + * @param cls the request to time out + */ +static void +do_timeout (void *cls) +{ + struct RequestHandle *handle = cls; + + handle->timeout_task = NULL; + do_error (handle); +} + + static void cleanup_handle_delayed (void *cls) { @@ -1138,10 +1156,8 @@ rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, &testservice_id_task, handle); handle->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->timeout, - &do_error, + &do_timeout, handle); - - } /** -- cgit v1.2.3