From 70e6847205a9f9b9b660be2a173d5bc309eaa58d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 24 Jul 2009 22:04:41 +0000 Subject: [PATCH] quota management and better name for NO_TASK' ' --- src/arm/gnunet-service-arm.c | 4 +- src/core/core_api.c | 24 +- src/core/gnunet-service-core.c | 34 +-- src/core/test_core_api.c | 4 +- src/datastore/gnunet-service-datastore.c | 285 +++++++++++++++++++++-- src/datastore/perf_datastore_api.c | 2 +- src/datastore/perf_plugin_datastore.c | 8 +- src/datastore/plugin_datastore_sqlite.c | 2 +- src/hostlist/gnunet-daemon-hostlist.c | 2 +- src/hostlist/hostlist-client.c | 4 +- src/hostlist/hostlist-server.c | 6 +- src/include/gnunet_network_lib.h | 2 +- src/include/gnunet_scheduler_lib.h | 12 +- src/include/gnunet_server_lib.h | 2 +- src/peerinfo/gnunet-service-peerinfo.c | 12 +- src/topology/gnunet-daemon-topology.c | 6 +- src/transport/gnunet-service-transport.c | 22 +- src/transport/plugin_transport_tcp.c | 2 +- src/transport/test_plugin_transport.c | 8 +- src/transport/transport_api.c | 72 +++--- src/util/client.c | 8 +- src/util/crypto_hash.c | 4 +- src/util/disk.c | 2 +- src/util/network.c | 62 ++--- src/util/scheduler.c | 14 +- src/util/server.c | 14 +- src/util/test_network.c | 2 +- src/util/test_network_addressing.c | 2 +- src/util/test_network_receive_cancel.c | 4 +- src/util/test_scheduler.c | 6 +- src/util/test_scheduler_delay.c | 2 +- src/util/test_server.c | 4 +- src/util/test_server_disconnect.c | 4 +- src/util/test_server_with_client.c | 2 +- 34 files changed, 446 insertions(+), 197 deletions(-) diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index 1953bffeb..a84445271 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -561,7 +561,7 @@ maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_delayed (tc->sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, MAINT_FREQUENCY, &maint, cfg); /* check for services that died (WAITPID) */ @@ -723,7 +723,7 @@ run (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, MAINT_FREQUENCY, &maint, NULL); } diff --git a/src/core/core_api.c b/src/core/core_api.c index a995eb27f..67b21ca26 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -277,7 +277,7 @@ timeout_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmission request timed out.\n"); h = th->ch; - th->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL)); GNUNET_CORE_notify_transmit_ready_cancel (th); } @@ -310,7 +310,7 @@ request_start (void *cls, size_t size, void *buf) th->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (th->timeout), &timeout_request, th); @@ -344,7 +344,7 @@ trigger_next_request (struct GNUNET_CORE_Handle *h) return; /* no requests pending */ GNUNET_assert (NULL == h->th); GNUNET_SCHEDULER_cancel (h->sched, th->timeout_task); - th->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->timeout_task = GNUNET_SCHEDULER_NO_TASK; h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, th->msize, GNUNET_TIME_absolute_get_remaining @@ -660,7 +660,7 @@ static void reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_CORE_Handle *h = cls; - h->reconnect_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; reconnect (h); } @@ -702,7 +702,7 @@ transmit_start (void *cls, size_t size, void *buf) h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, delay, &reconnect_task, h); return 0; } @@ -837,7 +837,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) { if (handle->th != NULL) GNUNET_NETWORK_notify_transmit_ready_cancel (handle->th); - if (handle->reconnect_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); GNUNET_CLIENT_disconnect (handle->client); GNUNET_free (handle); @@ -858,7 +858,7 @@ produce_configure_message (void *cls, size_t size, void *buf) /* communicate handle timeout/error! */ if (th->info != NULL) th->info (th->info_cls, NULL, 0, 0, GNUNET_TIME_UNIT_ZERO, 0, 0.0); - if (th->timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_CORE_notify_transmit_ready_cancel (th); if (ch->submitted == th) ch->submitted = NULL; @@ -934,7 +934,7 @@ GNUNET_CORE_peer_configure (struct GNUNET_CORE_Handle *handle, th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, timeout, &timeout_request, th); th->msize = sizeof (struct RequestConfigureMessage); @@ -974,7 +974,7 @@ produce_send (void *cls, size_t size, void *buf) GNUNET_i2s(&th->peer)); #endif GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); - if (th->timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_CORE_notify_transmit_ready_cancel (th); trigger_next_request (h); return 0; @@ -984,7 +984,7 @@ produce_send (void *cls, size_t size, void *buf) "Preparing for P2P transmission to `%4s'.\n", GNUNET_i2s(&th->peer)); #endif - GNUNET_assert (th->timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_assert (th->timeout_task != GNUNET_SCHEDULER_NO_TASK); sm = (struct SendMessage *) buf; sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND); sm->priority = htonl (th->priority); @@ -1050,7 +1050,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, maxdelay, &timeout_request, th); th->priority = priority; @@ -1088,7 +1088,7 @@ GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle else h->next->prev = h->prev; } - if (h->timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (h->timeout_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (handle->sched, h->timeout_task); GNUNET_free (h); } diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index c4de03350..0a96d8288 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -1595,7 +1595,7 @@ retry_plaintext_processing (void *cls, { struct Neighbour *n = cls; - n->retry_plaintext_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + n->retry_plaintext_task = GNUNET_SCHEDULER_NO_TASK; process_plaintext_neighbour_queue (n); } @@ -1628,10 +1628,10 @@ process_plaintext_neighbour_queue (struct Neighbour *n) struct GNUNET_TIME_Absolute deadline; struct GNUNET_TIME_Relative retry_time; - if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); - n->retry_plaintext_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + n->retry_plaintext_task = GNUNET_SCHEDULER_NO_TASK; } switch (n->status) { @@ -1645,7 +1645,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) return; case PEER_STATE_KEY_SENT: GNUNET_assert (n->retry_set_key_task != - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_SCHEDULER_NO_TASK); #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not yet connected to `%4s', deferring processing of plaintext messages.\n", @@ -1654,7 +1654,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) return; case PEER_STATE_KEY_RECEIVED: GNUNET_assert (n->retry_set_key_task != - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_SCHEDULER_NO_TASK); #if DEBUG_CORE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not yet connected to `%4s', deferring processing of plaintext messages.\n", @@ -1705,7 +1705,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n) GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, retry_time, &retry_plaintext_processing, n); return; @@ -2021,7 +2021,7 @@ set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct Neighbour *n = cls; GNUNET_assert (n->status != PEER_STATE_KEY_CONFIRMED); - n->retry_set_key_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; n->set_key_retry_frequency = GNUNET_TIME_relative_multiply (n->set_key_retry_frequency, 2); send_key (n); @@ -2148,7 +2148,7 @@ send_key (struct Neighbour *n) = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, n->set_key_retry_frequency, &set_key_retry_task, n); } @@ -2484,10 +2484,10 @@ handle_pong (struct Neighbour *n, const struct PingMessage *m) return; case PEER_STATE_KEY_RECEIVED: n->status = PEER_STATE_KEY_CONFIRMED; - if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); - n->retry_set_key_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; } process_encrypted_neighbour_queue (n); break; @@ -2883,12 +2883,12 @@ static void schedule_quota_update (struct Neighbour *n) { GNUNET_assert (n->quota_update_task == - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_SCHEDULER_NO_TASK); n->quota_update_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, QUOTA_UPDATE_FREQUENCY, &neighbour_quota_update, n); @@ -2912,7 +2912,7 @@ neighbour_quota_update (void *cls, double share; unsigned long long distributable; - n->quota_update_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + n->quota_update_task = GNUNET_SCHEDULER_NO_TASK; /* calculate relative preference among all neighbours; divides by a bit more to avoid division by zero AND to account for possibility of new neighbours joining any time @@ -3022,11 +3022,11 @@ free_neighbour (struct Neighbour *n) } if (NULL != n->th) GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th); - if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); - if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); - if (n->quota_update_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (n->quota_update_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (sched, n->quota_update_task); GNUNET_free_non_null (n->public_key); GNUNET_free_non_null (n->pending_ping); @@ -3192,7 +3192,7 @@ run (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); /* process client requests */ diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index df354a856..f2095025f 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -173,7 +173,7 @@ process_mtype (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_ZERO, &terminate_task, NULL); return GNUNET_OK; } @@ -202,7 +202,7 @@ transmit_ready (void *cls, size_t size, void *buf) GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_MINUTES, &terminate_task_error, NULL); return sizeof (struct GNUNET_MessageHeader); diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 89c5d6af8..cedad3649 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -22,13 +22,6 @@ * @file datastore/gnunet-service-datastore.c * @brief Management for the datastore for files stored on a GNUnet node * @author Christian Grothoff - * - * TODO: - * quota management code: - * - track storage use - * - refuse above-quota - * - content expiration job - * - near-quota low-priority content discard job */ #include "platform.h" @@ -42,6 +35,13 @@ */ #define MAX_PENDING 1024 +/** + * How long are we at most keeping "expired" content + * past the expiration date in the database? + */ +#define MAX_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) + + /** * Our datastore plugin. @@ -133,11 +133,35 @@ static int reservation_gen; */ static unsigned long long quota; +/** + * How much space are we using for the cache? + * (space available for insertions that will be + * instantly reclaimed by discarding less + * important content --- or possibly whatever + * we just inserted into the "cache"). + */ +static unsigned long long cache_size; + /** * How much space have we currently reserved? */ static unsigned long long reserved; +/** + * Identity of the task that is used to delete + * expired content. + */ +static GNUNET_SCHEDULER_TaskIdentifier expired_kill_task; + +/** + * Our configuration. + */ +struct GNUNET_CONFIGURATION_Handle *cfg; + +/** + * Our scheduler. + */ +struct GNUNET_SCHEDULER_Handle *sched; /** * Function called once the transmit operation has @@ -149,6 +173,7 @@ static unsigned long long reserved; typedef void (*TransmitContinuation)(void *cls, int status); + struct TransmitCallbackContext { /** @@ -180,6 +205,176 @@ struct TransmitCallbackContext }; +/** + * Task that is used to remove expired entries from + * the datastore. This task will schedule itself + * again automatically to always delete all expired + * content quickly. + * + * @param cls not used + * @param tc task context + */ +static void +delete_expired (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc); + + +/** + * Iterate over the expired items stored in the datastore. + * Delete all expired items; once we have processed all + * expired items, re-schedule the "delete_expired" task. + * + * @param cls not used + * @param next_cls closure to pass to the "next" function. + * @param key key for the content + * @param size number of bytes in data + * @param data content stored + * @param type type of the content + * @param priority priority of the content + * @param anonymity anonymity-level for the content + * @param expiration expiration time for the content + * @param uid unique identifier for the datum; + * maybe 0 if no unique identifier is available + * + * @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue + * (continue on call to "next", of course), + * GNUNET_NO to delete the item and continue (if supported) + */ +static int +expired_processor (void *cls, + void *next_cls, + const GNUNET_HashCode * key, + uint32_t size, + const void *data, + uint32_t type, + uint32_t priority, + uint32_t anonymity, + struct GNUNET_TIME_Absolute + expiration, + uint64_t uid) +{ + struct GNUNET_TIME_Absolute now; + + expired_kill_task = GNUNET_SCHEDULER_NO_TASK; + if (key == NULL) + { + expired_kill_task + = GNUNET_SCHEDULER_add_delayed (sched, + GNUNET_NO, + GNUNET_SCHEDULER_PRIORITY_IDLE, + GNUNET_SCHEDULER_NO_TASK, + MAX_EXPIRE_DELAY, + &delete_expired, + NULL); + return GNUNET_SYSERR; + } + now = GNUNET_TIME_absolute_get (); + if (expiration.value > now.value) + { + /* finished processing */ + plugin->api->next_request (next_cls, GNUNET_YES); + return GNUNET_SYSERR; + } + plugin->api->next_request (next_cls, GNUNET_NO); + return GNUNET_NO; /* delete */ +} + + +/** + * Task that is used to remove expired entries from + * the datastore. This task will schedule itself + * again automatically to always delete all expired + * content quickly. + * + * @param cls not used + * @param tc task context + */ +static void +delete_expired (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + plugin->api->iter_ascending_expiration (plugin->api->cls, + 0, + &expired_processor, + NULL); +} + + +/** + * An iterator over a set of items stored in the datastore. + * + * @param cls closure + * @param next_cls closure to pass to the "next" function. + * @param key key for the content + * @param size number of bytes in data + * @param data content stored + * @param type type of the content + * @param priority priority of the content + * @param anonymity anonymity-level for the content + * @param expiration expiration time for the content + * @param uid unique identifier for the datum; + * maybe 0 if no unique identifier is available + * + * @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue + * (continue on call to "next", of course), + * GNUNET_NO to delete the item and continue (if supported) + */ +static int +manage (void *cls, + void *next_cls, + const GNUNET_HashCode * key, + uint32_t size, + const void *data, + uint32_t type, + uint32_t priority, + uint32_t anonymity, + struct GNUNET_TIME_Absolute + expiration, + uint64_t uid) +{ + unsigned long long *need = cls; + + if (NULL == key) + { + GNUNET_free (need); + return GNUNET_SYSERR; + } + if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need) + *need = 0; + else + *need -= size + GNUNET_DATASTORE_ENTRY_OVERHEAD; + plugin->api->next_request (next_cls, + (0 == *need) ? GNUNET_YES : GNUNET_NO); + return GNUNET_NO; +} + + +/** + * Manage available disk space by running tasks + * that will discard content if necessary. This + * function will be run whenever a request for + * "need" bytes of storage could only be satisfied + * by eating into the "cache" (and we want our cache + * space back). + * + * @param need number of bytes of content that were + * placed into the "cache" (and hence the + * number of bytes that should be removed). + */ +static void +manage_space (unsigned long long need) +{ + unsigned long long *n; + + n = GNUNET_malloc (sizeof(unsigned long long)); + *n = need; + plugin->api->iter_low_priority (plugin->api->cls, + 0, + &manage, + n); +} + + /** * Function called to notify a client about the socket * begin ready to queue more data. "buf" will be @@ -446,13 +641,32 @@ handle_reserve (void *cls, if (used + req > quota) { if (quota < used) - used = quota; /* cheat a bit */ + used = quota; /* cheat a bit for error message (to avoid negative numbers) */ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Insufficient space (%llu bytes are available) to satisfy `%s' request for %llu bytes\n"), quota - used, "RESERVE", req); - transmit_status (client, 0, gettext_noop ("Insufficient space to satisfy request")); + if (cache_size < req) + { + /* TODO: document this in the FAQ; essentially, if this + message happens, the insertion request could be blocked + by less-important content from migration because it is + larger than 1/8th of the overall available space, and + we only reserve 1/8th for "fresh" insertions */ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _("The requested amount (%llu bytes) is larger than the cache size (%llu bytes)\n"), + req, + cache_size); + transmit_status (client, 0, + gettext_noop ("Insufficient space to satisfy request and " + "requested amount is larger than cache size")); + } + else + { + transmit_status (client, 0, + gettext_noop ("Insufficient space to satisfy request")); + } return; } reserved += req; @@ -623,6 +837,8 @@ handle_put (void *cls, (GNUNET_SYSERR == ret) ? GNUNET_SYSERR : GNUNET_OK, msg); GNUNET_free_non_null (msg); + if (quota - reserved - cache_size < plugin->api->get_size (plugin->api->cls)) + manage_space (size + GNUNET_DATASTORE_ENTRY_OVERHEAD); } @@ -894,8 +1110,7 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = { * Load the datastore plugin. */ static struct DatastorePlugin * -load_plugin (struct GNUNET_CONFIGURATION_Handle *cfg, - struct GNUNET_SCHEDULER_Handle *sched) +load_plugin () { struct DatastorePlugin *ret; char *libname; @@ -978,7 +1193,30 @@ cleanup_reservations (void *cls, struct GNUNET_SERVER_Client * client) { - /* FIXME */ + struct ReservationList *pos; + struct ReservationList *prev; + struct ReservationList *next; + + prev = NULL; + pos = reservations; + while (NULL != pos) + { + next = pos->next; + if (pos->client == client) + { + if (prev == NULL) + reservations = next; + else + prev->next = next; + reserved -= pos->amount + pos->entries * GNUNET_DATASTORE_ENTRY_OVERHEAD; + GNUNET_free (pos); + } + else + { + prev = pos; + } + pos = next; + } } @@ -986,19 +1224,21 @@ cleanup_reservations (void *cls, * Process datastore requests. * * @param cls closure - * @param sched scheduler to use + * @param s 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_SCHEDULER_Handle *s, struct GNUNET_SERVER_Handle *server, - struct GNUNET_CONFIGURATION_Handle *cfg) + struct GNUNET_CONFIGURATION_Handle *c) { char *fn; unsigned int bf_size; + sched = s; + cfg = c; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "DATASTORE", "QUOTA", "a)) @@ -1009,6 +1249,7 @@ run (void *cls, "DATASTORE"); return; } + cache_size = quota / 8; /* Or should we make this an option? */ bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */ fn = NULL; if ( (GNUNET_OK != @@ -1033,7 +1274,7 @@ run (void *cls, _("Failed to initialize bloomfilter.\n")); return; } - plugin = load_plugin (cfg, sched); + plugin = load_plugin (); if (NULL == plugin) { GNUNET_CONTAINER_bloomfilter_free (filter); @@ -1041,12 +1282,20 @@ run (void *cls, } 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_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); + } diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 948097e9c..d488cef4c 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -223,7 +223,7 @@ delete_value (void *cls, GNUNET_SCHEDULER_add_after (crc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &do_delete, crc); return; diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index 6b5ae9a28..dae8e7432 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -170,7 +170,7 @@ iterateDummy (void *cls, GNUNET_SCHEDULER_add_after (crc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &test, crc); return GNUNET_OK; } @@ -255,7 +255,7 @@ test (void *cls, GNUNET_SCHEDULER_add_after (crc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &test, crc); break; case RP_LP_GET: @@ -303,7 +303,7 @@ test (void *cls, GNUNET_SCHEDULER_add_delayed (crc->sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_ZERO, &cleaning_task, crc); break; @@ -365,7 +365,7 @@ run (void *cls, GNUNET_SCHEDULER_add_after (s, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &test, crc); } diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index ce92d3882..9a807463a 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -632,7 +632,7 @@ sqlite_next_request (void *next_cls, if (GNUNET_YES == end_it) nc->end_it = GNUNET_YES; GNUNET_SCHEDULER_add_continuation (nc->plugin->env->sched, - GNUNET_NO, + GNUNET_NO, &sqlite_next_request_cont, nc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index ceb3415d5..281459b75 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -178,7 +178,7 @@ run (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); } diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 5008b41fc..785e189ab 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -399,7 +399,7 @@ run_multi () = GNUNET_SCHEDULER_add_select (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_MINUTES, max, &rs, @@ -543,7 +543,7 @@ schedule_hostlist_task () current_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, delay, &check_task, NULL); diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index dabc40d03..6139283ed 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -94,7 +94,7 @@ finish_response (struct HostSet *results) GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, RESPONSE_UPDATE_FREQUENCY, &update_response, NULL); @@ -242,7 +242,7 @@ prepare_daemon () = GNUNET_SCHEDULER_add_select (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, tv, max, &rs, @@ -301,7 +301,7 @@ void GNUNET_HOSTLIST_server_stop () { GNUNET_SCHEDULER_cancel (sched, hostlist_task); - hostlist_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + hostlist_task = GNUNET_SCHEDULER_NO_TASK; MHD_stop_daemon (daemon_handle); daemon_handle = NULL; } diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h index 8731eacec..26a39d575 100644 --- a/src/include/gnunet_network_lib.h +++ b/src/include/gnunet_network_lib.h @@ -202,7 +202,7 @@ void GNUNET_NETWORK_socket_destroy (struct GNUNET_NETWORK_SocketHandle *sock); * @param timeout maximum amount of time to wait * @param receiver function to call with received data * @param receiver_cls closure for receiver - * @return scheduler task ID used for receiving, GNUNET_SCHEDULER_NO_PREREQUISITE_TASK on error + * @return scheduler task ID used for receiving, GNUNET_SCHEDULER_NO_TASK on error */ GNUNET_SCHEDULER_TaskIdentifier GNUNET_NETWORK_receive (struct GNUNET_NETWORK_SocketHandle *sock, diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index aa5830942..d4013e630 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h @@ -54,7 +54,7 @@ typedef unsigned long long GNUNET_SCHEDULER_TaskIdentifier; * Constant used to indicate that the scheduled * task has no others as prerequisites. */ -#define GNUNET_SCHEDULER_NO_PREREQUISITE_TASK ((GNUNET_SCHEDULER_TaskIdentifier) 0) +#define GNUNET_SCHEDULER_NO_TASK ((GNUNET_SCHEDULER_TaskIdentifier) 0) /** * Reasons why the schedule may have triggered @@ -272,7 +272,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -302,7 +302,7 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -335,7 +335,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle *sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -368,7 +368,7 @@ GNUNET_SCHEDULER_add_read (struct GNUNET_SCHEDULER_Handle *sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -411,7 +411,7 @@ GNUNET_SCHEDULER_add_write (struct GNUNET_SCHEDULER_Handle *sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 nfds highest-numbered file descriptor in any of the two sets plus one diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h index 44db9ce70..aa79d7833 100644 --- a/src/include/gnunet_server_lib.h +++ b/src/include/gnunet_server_lib.h @@ -254,7 +254,7 @@ struct GNUNET_SERVER_Client *GNUNET_SERVER_connect_socket (struct * @param receiver function to call with received data * @param receiver_cls closure for receiver * @return task identifier that can be used to cancel the receive, - * GNUNET_SCHEDULER_NO_PREREQUISITE_TASK should be returned + * GNUNET_SCHEDULER_NO_TASK should be returned * if the receiver function was already called */ typedef GNUNET_SCHEDULER_TaskIdentifier diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 752629cb5..6b709e84a 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -336,7 +336,7 @@ cron_scan_directory_data_hosts (void *cls, GNUNET_SCHEDULER_add_delayed (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, DATA_HOST_FREQ, &cron_scan_directory_data_hosts, NULL); } @@ -485,7 +485,7 @@ cron_flush_trust (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_delayed (tc->sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, TRUST_FLUSH_FREQ, &cron_flush_trust, NULL); } @@ -545,7 +545,7 @@ cron_clean_data_hosts (void *cls, GNUNET_SCHEDULER_add_delayed (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, DATA_HOST_CLEAN_FREQ, &cron_clean_data_hosts, NULL); } @@ -669,18 +669,18 @@ run (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + 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_PREREQUISITE_TASK, + 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_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, DATA_HOST_CLEAN_FREQ, &cron_clean_data_hosts, NULL); GNUNET_SERVER_add_handlers (server, handlers); diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 73fb84981..04d9d8801 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -463,7 +463,7 @@ schedule_peer_search () GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, delay, &find_more_peers, NULL); @@ -706,7 +706,7 @@ core_init (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_SECONDS /* give core time to tell us about existing connections */, &find_more_peers, NULL); @@ -1053,7 +1053,7 @@ run (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL); } diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 445fb4315..96d2001aa 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -1172,9 +1172,9 @@ update_addresses (struct TransportPlugin *plugin, int fresh) struct AddressList *next; int expired; - if (plugin->address_update_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (plugin->address_update_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (plugin->env.sched, plugin->address_update_task); - plugin->address_update_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK; now = GNUNET_TIME_absolute_get (); min_remaining = GNUNET_TIME_UNIT_FOREVER_REL; expired = GNUNET_NO; @@ -1209,7 +1209,7 @@ update_addresses (struct TransportPlugin *plugin, int fresh) = GNUNET_SCHEDULER_add_delayed (plugin->env.sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, min_remaining, &expire_address_task, plugin); @@ -1226,7 +1226,7 @@ static void expire_address_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct TransportPlugin *plugin = cls; - plugin->address_update_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + plugin->address_update_task = GNUNET_SCHEDULER_NO_TASK; update_addresses (plugin, GNUNET_NO); } @@ -1513,7 +1513,7 @@ cleanup_validation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (pos->timeout), &cleanup_validation, NULL); } @@ -1608,7 +1608,7 @@ plugin_env_notify_validation (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_ZERO, &cleanup_validation, NULL); } @@ -1757,7 +1757,7 @@ check_hello_validated (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (chvc->e->timeout), &cleanup_validation, NULL); @@ -1920,7 +1920,7 @@ disconnect_neighbour (struct NeighbourList *n, GNUNET_assert (mq->neighbour == n); GNUNET_free (mq); } - if (n->timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (n->timeout_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (sched, n->timeout_task); /* finally, free n itself */ @@ -1971,7 +1971,7 @@ neighbour_timeout_task (void *cls, "Neighbour `%4s' has timed out!\n", GNUNET_i2s(&n->id)); #endif - n->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + n->timeout_task = GNUNET_SCHEDULER_NO_TASK; disconnect_neighbour (n, GNUNET_NO); } @@ -2007,7 +2007,7 @@ setup_new_neighbour (const struct GNUNET_PeerIdentity *peer) n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &neighbour_timeout_task, n); transmit_to_peer (NULL, 0, @@ -2120,7 +2120,7 @@ plugin_env_receive (void *cls, n->timeout_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &neighbour_timeout_task, n); update_quota (n); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 3ed20d4fa..76d980621 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1886,7 +1886,7 @@ handle_tcp_data (void *cls, GNUNET_SCHEDULER_add_delayed (session->plugin->env->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, delay, &delayed_done, session); } diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index 9cc9f2853..ef6c8a76a 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -157,10 +157,10 @@ validation_notification (void *cls, /* Sailor: 'test_validation' should get here if the validation worked; so we cancel the "delayed" task that will cause failure */ - if (validation_timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (validation_timeout_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (sched, validation_timeout_task); - validation_timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + validation_timeout_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_assert (challenge == 42); @@ -176,7 +176,7 @@ static void validation_failed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - validation_timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + validation_timeout_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_break (0); /* output error */ /* the "validation_notification" was not called in a timely fashion; we should set an error @@ -221,7 +221,7 @@ test_validation () GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, TIMEOUT, &validation_failed, NULL); diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index dab244e45..eef0ede5e 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -405,13 +405,13 @@ transport_notify_ready (void *cls, size_t size, void *buf) do { th = h->connect_ready_head; - if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { /* remove existing time out task (only applies if this is not the first iteration of the loop) */ GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_assert (th->notify_size <= size); if (th->next != NULL) @@ -459,13 +459,13 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h) th = h->connect_ready_head; if (th == NULL) return; /* no request pending */ - if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { /* remove existing time out task, will be integrated with transmit_ready notification! */ GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } h->transmission_scheduled = GNUNET_YES; h->network_handle = GNUNET_CLIENT_notify_transmit_ready (h->client, @@ -529,10 +529,10 @@ remove_from_any_list (struct GNUNET_TRANSPORT_TransmitHandle *th) struct GNUNET_TRANSPORT_Handle *h; h = th->handle; - if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } if (th->prev == NULL) { @@ -573,7 +573,7 @@ transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_TRANSPORT_TransmitHandle *th = cls; - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; if (th->neighbour != NULL) th->neighbour->transmit_handle = NULL; #if DEBUG_TRANSPORT @@ -620,7 +620,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, = GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, timeout, &transmit_timeout, th); if (at_head) @@ -785,7 +785,7 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct HelloWaitList *pos; struct HelloWaitList *prev; - hwl->task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + hwl->task = GNUNET_SCHEDULER_NO_TASK; if (GNUNET_TIME_absolute_get_remaining (hwl->timeout).value > 0) { #if DEBUG_TRANSPORT @@ -797,7 +797,7 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) hwl->task = GNUNET_SCHEDULER_add_delayed (hwl->handle->sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (hwl->timeout), &hello_wait_timeout, hwl); return; @@ -857,7 +857,7 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, hwl->task = GNUNET_SCHEDULER_add_delayed (handle->sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, timeout, &hello_wait_timeout, hwl); return; @@ -979,7 +979,7 @@ request_connect (void *cls, size_t size, void *buf) struct TryConnectMessage *tcm; struct GNUNET_TRANSPORT_Handle *h; - GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK); h = th->handle; if (buf == NULL) { @@ -1008,7 +1008,7 @@ request_connect (void *cls, size_t size, void *buf) = GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (th->timeout), &transmit_timeout, th); @@ -1028,7 +1028,7 @@ request_connect (void *cls, size_t size, void *buf) static void try_connect (struct GNUNET_TRANSPORT_TransmitHandle *th) { - GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_TASK); schedule_control_transmit (th->handle, sizeof (struct TryConnectMessage), GNUNET_NO, @@ -1050,7 +1050,7 @@ try_connect_task (void *cls, { struct GNUNET_TRANSPORT_TransmitHandle *th = cls; - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; try_connect (th); } @@ -1103,18 +1103,18 @@ remove_neighbour (struct GNUNET_TRANSPORT_Handle *h, if (GNUNET_TIME_absolute_get_remaining (th->timeout).value <= CONNECT_RETRY_TIMEOUT.value) { /* signal error */ - GNUNET_assert (GNUNET_SCHEDULER_NO_PREREQUISITE_TASK == th->notify_delay_task); + GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == th->notify_delay_task); transmit_timeout (th, NULL); } else { /* try again in a bit */ - GNUNET_assert (GNUNET_SCHEDULER_NO_PREREQUISITE_TASK == th->notify_delay_task); + 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_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, CONNECT_RETRY_TIMEOUT, &try_connect_task, th); @@ -1144,7 +1144,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to transport service.\n"); #endif GNUNET_assert (h->client == NULL); - h->reconnect_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; h->client = GNUNET_CLIENT_connect (h->sched, "transport", h->cfg); GNUNET_assert (h->client != NULL); /* make sure we don't send "START" twice, @@ -1189,12 +1189,12 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) h->reconnect_delay.value); #endif GNUNET_assert (h->client == NULL); - GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + 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_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, h->reconnect_delay, &reconnect, h); h->reconnect_delay = GNUNET_TIME_UNIT_SECONDS; } @@ -1217,7 +1217,7 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_TRANSPORT_TransmitHandle *th = cls; - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; schedule_request (th); } @@ -1252,10 +1252,10 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th) h = th->handle; n = th->neighbour; - if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } /* check outgoing quota */ duration = GNUNET_TIME_absolute_get_duration (n->last_quota_update); @@ -1298,7 +1298,7 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th) = GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, duration, &transmit_ready, th); return; } @@ -1320,7 +1320,7 @@ schedule_request (struct GNUNET_TRANSPORT_TransmitHandle *th) = GNUNET_SCHEDULER_add_delayed (h->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (th->timeout), &transmit_timeout, th); return; @@ -1392,10 +1392,10 @@ add_neighbour (struct GNUNET_TRANSPORT_Handle *h, "Found pending request for `%4s' will trigger it now.\n", GNUNET_i2s (&pos->target)); #endif - if (pos->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (pos->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task); - pos->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } schedule_request (pos); } @@ -1495,10 +1495,10 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) while (NULL != (th = handle->connect_wait_head)) { handle->connect_wait_head = th->next; - if (th->notify_delay_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (handle->sched, th->notify_delay_task); - th->notify_delay_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; } th->notify (th->notify_cls, 0, NULL); GNUNET_free (th); @@ -1519,10 +1519,10 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) hwl->rec (hwl->rec_cls, GNUNET_TIME_UNIT_ZERO, NULL, NULL); GNUNET_free (hwl); } - if (handle->reconnect_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); - handle->reconnect_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; } GNUNET_free_non_null (handle->my_hello); handle->my_hello = NULL; @@ -1578,12 +1578,12 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) h->transmission_scheduled = GNUNET_NO; th = h->connect_ready_head; /* add timeout again, we cancelled the transmit_ready task! */ - GNUNET_assert (th->notify_delay_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + 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_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining(th->timeout), &transmit_timeout, th); @@ -1692,7 +1692,7 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg) GNUNET_SCHEDULER_cancel (h->sched, n->transmit_handle->notify_delay_task); n->transmit_handle->notify_delay_task = - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (GNUNET_YES == n->received_ack); schedule_request (n->transmit_handle); } @@ -1927,7 +1927,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle = GNUNET_SCHEDULER_add_delayed (handle->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, timeout, &transmit_timeout, th); return th; } diff --git a/src/util/client.c b/src/util/client.c index 487f3f8e8..7d380fa5c 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -230,7 +230,7 @@ receive_helper (void *cls, struct GNUNET_TIME_Relative remaining; GNUNET_assert (conn->msg_complete == GNUNET_NO); - conn->receiver_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + conn->receiver_task = GNUNET_SCHEDULER_NO_TASK; if ((available == 0) || (conn->sock == NULL) || (errCode != 0)) { @@ -284,7 +284,7 @@ receive_task (void *scls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader*) mbuf; GNUNET_assert (GNUNET_YES == sock->msg_complete); - sock->receiver_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sock->receiver_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_assert (sock->received_pos >= msize); memcpy (msg, cmsg, msize); memmove (sock->received_buf, @@ -320,7 +320,7 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, return; } GNUNET_assert (sock->receiver_task == - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_SCHEDULER_NO_TASK); sock->receiver_handler = handler; sock->receiver_handler_cls = cls; sock->receive_timeout = GNUNET_TIME_relative_to_absolute (timeout); @@ -328,7 +328,7 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, sock->receiver_task = GNUNET_SCHEDULER_add_after (sock->sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &receive_task, sock); else sock->receiver_task = GNUNET_NETWORK_receive (sock->sock, diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index 8df4cc8f4..fc4d24320 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c @@ -484,7 +484,7 @@ file_hash_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_after (tc->sched, fhc->run_on_shutdown, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc); } @@ -536,7 +536,7 @@ GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_SCHEDULER_add_after (sched, run_on_shutdown, priority, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &file_hash_task, fhc); } diff --git a/src/util/disk.c b/src/util/disk.c index c70f2cc2b..b0f92c7f2 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -735,7 +735,7 @@ GNUNET_DISK_directory_iterator_next (struct GNUNET_DISK_DirectoryIterator GNUNET_SCHEDULER_add_after (iter->sched, GNUNET_YES, iter->priority, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &directory_iterator_task, iter); return GNUNET_YES; } diff --git a/src/util/network.c b/src/util/network.c index cb8542329..9b61bd8c2 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -541,7 +541,7 @@ connect_continuation (void *cls, int error; /* nobody needs to wait for us anymore... */ - sock->connect_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sock->connect_task = GNUNET_SCHEDULER_NO_TASK; /* Note: write-ready does NOT mean connect succeeded, we need to use getsockopt to be sure */ len = sizeof (error); @@ -574,7 +574,7 @@ connect_continuation (void *cls, } sock->connect_task = GNUNET_SCHEDULER_add_write (tc->sched, GNUNET_NO, /* abort on shutdown */ GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_NETWORK_CONNECT_RETRY_TIMEOUT, sock->sock, &connect_continuation, @@ -630,7 +630,7 @@ GNUNET_NETWORK_socket_create_from_connect (struct GNUNET_SCHEDULER_Handle } ret->connect_task = GNUNET_SCHEDULER_add_write (sched, GNUNET_NO, /* abort on shutdown */ GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_NETWORK_CONNECT_RETRY_TIMEOUT, ret->sock, &connect_continuation, ret); @@ -727,7 +727,7 @@ destroy_continuation (void *cls, struct GNUNET_NETWORK_SocketHandle *sock = cls; GNUNET_NETWORK_TransmitReadyNotify notify; - if (sock->write_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->write_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_add_after (sock->sched, GNUNET_YES, @@ -743,7 +743,7 @@ destroy_continuation (void *cls, #endif SHUTDOWN (sock->sock, SHUT_RDWR); } - if (sock->read_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->read_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_add_after (sock->sched, GNUNET_YES, @@ -756,10 +756,10 @@ destroy_continuation (void *cls, { sock->nth.notify_ready = NULL; notify (sock->nth.notify_ready_cls, 0, NULL); - if (sock->nth.timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (sock->sched, sock->nth.timeout_task); - sock->nth.timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sock->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; } } if (sock->sock != -1) @@ -837,7 +837,7 @@ receive_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ssize_t ret; GNUNET_NETWORK_Receiver receiver; - sh->read_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sh->read_task = GNUNET_SCHEDULER_NO_TASK; now = GNUNET_TIME_absolute_get (); if ((now.value > sh->receive_timeout.value) || (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) || @@ -907,9 +907,9 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct GNUNET_NETWORK_SocketHandle *sh = cls; struct GNUNET_TIME_Absolute now; - sh->read_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sh->read_task = GNUNET_SCHEDULER_NO_TASK; if ((sh->sock == -1) && - (sh->connect_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)) + (sh->connect_task == GNUNET_SCHEDULER_NO_TASK)) { /* not connected and no longer trying */ #if DEBUG_NETWORK @@ -930,7 +930,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) signal_timeout (sh); return; } - if (sh->connect_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sh->connect_task != GNUNET_SCHEDULER_NO_TASK) { /* connect was retried */ sh->read_task = GNUNET_SCHEDULER_add_after (tc->sched, @@ -965,7 +965,7 @@ receive_again (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param timeout maximum amount of time to wait (use -1 for "forever") * @param receiver function to call with received data * @param receiver_cls closure for receiver - * @return scheduler task ID used for receiving, GNUNET_SCHEDULER_NO_PREREQUISITE_TASK on error + * @return scheduler task ID used for receiving, GNUNET_SCHEDULER_NO_TASK on error */ GNUNET_SCHEDULER_TaskIdentifier GNUNET_NETWORK_receive (struct GNUNET_NETWORK_SocketHandle *sock, @@ -975,7 +975,7 @@ GNUNET_NETWORK_receive (struct GNUNET_NETWORK_SocketHandle *sock, { struct GNUNET_SCHEDULER_TaskContext tc; - GNUNET_assert ((sock->read_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) && + GNUNET_assert ((sock->read_task == GNUNET_SCHEDULER_NO_TASK) && (sock->receiver == NULL)); sock->receiver = receiver; sock->receiver_cls = receiver_cls; @@ -1004,7 +1004,7 @@ GNUNET_NETWORK_receive_cancel (struct GNUNET_NETWORK_SocketHandle *sock, { GNUNET_assert (sock->read_task == task); GNUNET_assert (sock == GNUNET_SCHEDULER_cancel (sock->sched, task)); - sock->read_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sock->read_task = GNUNET_SCHEDULER_NO_TASK; sock->receiver = NULL; return sock->receiver_cls; } @@ -1025,7 +1025,7 @@ process_notify (struct GNUNET_NETWORK_SocketHandle *sock) size_t size; GNUNET_NETWORK_TransmitReadyNotify notify; - GNUNET_assert (sock->write_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_assert (sock->write_task == GNUNET_SCHEDULER_NO_TASK); if (NULL == (notify = sock->nth.notify_ready)) return GNUNET_NO; used = sock->write_buffer_off - sock->write_buffer_pos; @@ -1034,10 +1034,10 @@ process_notify (struct GNUNET_NETWORK_SocketHandle *sock) if (sock->nth.notify_size > avail) return GNUNET_NO; sock->nth.notify_ready = NULL; - if (sock->nth.timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (sock->sched, sock->nth.timeout_task); - sock->nth.timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sock->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; } if (sock->write_buffer_size - sock->write_buffer_off < size) { @@ -1084,10 +1084,10 @@ transmit_error (struct GNUNET_NETWORK_SocketHandle *sock) { if (sock->nth.notify_ready == NULL) return; /* nobody to tell about it */ - if (sock->nth.timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->nth.timeout_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (sock->sched, sock->nth.timeout_task); - sock->nth.timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + sock->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK; } transmit_timeout (sock, NULL); } @@ -1105,13 +1105,13 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ssize_t ret; size_t have; - GNUNET_assert (sock->write_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); - sock->write_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; - if (sock->connect_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + GNUNET_assert (sock->write_task != GNUNET_SCHEDULER_NO_TASK); + sock->write_task = GNUNET_SCHEDULER_NO_TASK; + if (sock->connect_task != GNUNET_SCHEDULER_NO_TASK) { /* still waiting for connect */ GNUNET_assert (sock->write_task == - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_SCHEDULER_NO_TASK); sock->write_task = GNUNET_SCHEDULER_add_delayed (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, @@ -1195,12 +1195,12 @@ RETRY: return; /* all data sent! */ /* not done writing, schedule more */ SCHEDULE_WRITE: - if (sock->write_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) sock->write_task = GNUNET_SCHEDULER_add_write (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (sock->nth.transmit_timeout), sock->sock, &transmit_ready, sock); } @@ -1233,7 +1233,7 @@ GNUNET_NETWORK_notify_transmit_ready (struct GNUNET_NETWORK_SocketHandle GNUNET_assert (sock->write_buffer_size >= size); if ((sock->sock == -1) && - (sock->connect_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK)) + (sock->connect_task == GNUNET_SCHEDULER_NO_TASK)) { #if DEBUG_NETWORK GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1254,17 +1254,17 @@ GNUNET_NETWORK_notify_transmit_ready (struct GNUNET_NETWORK_SocketHandle sock->nth.timeout_task = GNUNET_SCHEDULER_add_delayed (sock->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, timeout, &transmit_timeout, sock); - if (sock->write_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->write_task == GNUNET_SCHEDULER_NO_TASK) { - if (sock->connect_task == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (sock->connect_task == GNUNET_SCHEDULER_NO_TASK) sock->write_task = GNUNET_SCHEDULER_add_write (sock->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_absolute_get_remaining (sock->nth.transmit_timeout), sock->sock, &transmit_ready, sock); @@ -1290,7 +1290,7 @@ GNUNET_NETWORK_notify_transmit_ready_cancel (struct { GNUNET_assert (h->notify_ready != NULL); GNUNET_SCHEDULER_cancel (h->sh->sched, h->timeout_task); - h->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + h->timeout_task = GNUNET_SCHEDULER_NO_TASK; h->notify_ready = NULL; } diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 4872eee41..0b5307290 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -255,7 +255,7 @@ update_sets (struct GNUNET_SCHEDULER_Handle *sched, pos = sched->pending; while (pos != NULL) { - if ((pos->prereq_id != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) && + if ((pos->prereq_id != GNUNET_SCHEDULER_NO_TASK) && (GNUNET_YES == is_pending (sched, pos->prereq_id))) { pos = pos->next; @@ -329,7 +329,7 @@ is_ready (struct GNUNET_SCHEDULER_Handle *sched, task->reason |= GNUNET_SCHEDULER_REASON_WRITE_READY; if (task->reason == 0) return GNUNET_NO; /* not ready */ - if (task->prereq_id != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + if (task->prereq_id != GNUNET_SCHEDULER_NO_TASK) { if (GNUNET_YES == is_pending (sched, task->prereq_id)) return GNUNET_NO; /* prereq waiting */ @@ -671,7 +671,7 @@ GNUNET_SCHEDULER_add_continuation (struct GNUNET_SCHEDULER_Handle *sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -707,7 +707,7 @@ GNUNET_SCHEDULER_add_after (struct GNUNET_SCHEDULER_Handle *sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -745,7 +745,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_SCHEDULER_Handle * sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -788,7 +788,7 @@ GNUNET_SCHEDULER_add_read (struct GNUNET_SCHEDULER_Handle * sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 @@ -841,7 +841,7 @@ GNUNET_SCHEDULER_add_write (struct GNUNET_SCHEDULER_Handle * sched, * @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_PREREQUISITE_TASK to not have any dependency + * 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 nfds highest-numbered file descriptor in any of the two sets plus one diff --git a/src/util/server.c b/src/util/server.c index f604fbc50..8ffc9c027 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -223,7 +223,7 @@ struct GNUNET_SERVER_Client /** * Current task identifier for the receive call - * (or GNUNET_SCHEDULER_NO_PREREQUISITE_TASK for none). + * (or GNUNET_SCHEDULER_NO_TASK for none). */ GNUNET_SCHEDULER_TaskIdentifier my_receive; @@ -351,7 +351,7 @@ process_listen_socket (void *cls, GNUNET_SCHEDULER_add_select (server->sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_MAX (server->listen_socket, server->shutpipe[0]) + 1, &r, NULL, @@ -483,7 +483,7 @@ GNUNET_SERVER_create (struct GNUNET_SCHEDULER_Handle *sched, GNUNET_SCHEDULER_add_select (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_MAX (ret->listen_socket, ret->shutpipe[0]) + 1, &r, @@ -621,7 +621,7 @@ shutdown_incoming_processing (struct GNUNET_SERVER_Client *client) struct NotifyList *n; unsigned int rc; - GNUNET_assert (client->my_receive == GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_assert (client->my_receive == GNUNET_SCHEDULER_NO_TASK); rc = client->reference_count; if (client->server != NULL) { @@ -740,7 +740,7 @@ process_incoming (void *cls, const char *cbuf = buf; size_t maxcpy; - client->my_receive = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + client->my_receive = GNUNET_SCHEDULER_NO_TASK; if ((buf == NULL) || (available == 0) || (errCode != 0) || @@ -1107,9 +1107,9 @@ GNUNET_SERVER_client_disconnect (struct GNUNET_SERVER_Client *client) { if (client->server == NULL) return; /* already disconnected */ - GNUNET_assert (client->my_receive != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); + GNUNET_assert (client->my_receive != GNUNET_SCHEDULER_NO_TASK); client->receive_cancel (client->client_closure, client->my_receive); - client->my_receive = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + client->my_receive = GNUNET_SCHEDULER_NO_TASK; shutdown_incoming_processing (client); } diff --git a/src/util/test_network.c b/src/util/test_network.c index b55b346a7..02555c299 100644 --- a/src/util/test_network.c +++ b/src/util/test_network.c @@ -169,7 +169,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_read (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, cls); } diff --git a/src/util/test_network_addressing.c b/src/util/test_network_addressing.c index 4a571fff5..3c2a690d9 100644 --- a/src/util/test_network_addressing.c +++ b/src/util/test_network_addressing.c @@ -159,7 +159,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_read (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, ls, &run_accept, cls); } diff --git a/src/util/test_network_receive_cancel.c b/src/util/test_network_receive_cancel.c index e22e24d8c..7eb31153c 100644 --- a/src/util/test_network_receive_cancel.c +++ b/src/util/test_network_receive_cancel.c @@ -123,13 +123,13 @@ task_receive_cancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_read (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_HIGH, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + 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_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_SECONDS, &receive_cancel_task, cls); } diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index 855b3a08a..d5a93ed7d 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c @@ -118,13 +118,13 @@ task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_read (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, fds[0], &taskRd, cls); GNUNET_SCHEDULER_add_write (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_UNIT_FOREVER_REL, fds[1], &taskWrt, cls); } @@ -144,7 +144,7 @@ task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) t2 = GNUNET_SCHEDULER_add_after (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_IDLE, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, &task2, cls); /* t3 will go before t4: higher priority */ t4 = GNUNET_SCHEDULER_add_after (tc->sched, diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c index 76cbf94d8..f5477fd4c 100644 --- a/src/util/test_scheduler_delay.c +++ b/src/util/test_scheduler_delay.c @@ -68,7 +68,7 @@ test_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_SCHEDULER_add_delayed (tc->sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_DEFAULT, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, i), &test_task, NULL); diff --git a/src/util/test_server.c b/src/util/test_server.c index c26d64270..0f2ea3ce7 100644 --- a/src/util/test_server.c +++ b/src/util/test_server.c @@ -77,7 +77,7 @@ my_receive (void *cls, struct SignalTimeoutContext *stctx; GNUNET_SCHEDULER_TaskIdentifier ret; - ret = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + ret = GNUNET_SCHEDULER_NO_TASK; switch (*ok) { case 1: @@ -98,7 +98,7 @@ my_receive (void *cls, ret = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_NO, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, timeout, &signal_timeout, stctx); break; default: diff --git a/src/util/test_server_disconnect.c b/src/util/test_server_disconnect.c index 7eab48284..d737e92ec 100644 --- a/src/util/test_server_disconnect.c +++ b/src/util/test_server_disconnect.c @@ -94,7 +94,7 @@ recv_cb (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50), &send_done, argclient); @@ -104,7 +104,7 @@ recv_cb (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50), &server_disconnect, argclient); diff --git a/src/util/test_server_with_client.c b/src/util/test_server_with_client.c index 22cf2cded..e5eb50d8e 100644 --- a/src/util/test_server_with_client.c +++ b/src/util/test_server_with_client.c @@ -86,7 +86,7 @@ recv_cb (void *cls, GNUNET_SCHEDULER_add_delayed (sched, GNUNET_YES, GNUNET_SCHEDULER_PRIORITY_KEEP, - GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_SCHEDULER_NO_TASK, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50), &send_done, argclient); -- 2.25.1