aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-24 01:10:47 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-24 01:10:47 +0000
commitf1f603c7d0b3f03dca46a4f313472288eb080eb1 (patch)
tree3a29966b02dfb83e0a8a8d5c42b3116380209fb0 /src/datastore
parent53cd5b8eda2fa8db86b0907a62a39598981d008a (diff)
downloadgnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.tar.gz
gnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.zip
making GNUNET_SCHEDULER_cancel() perform in O(1) instead of O(n) to help or even fully address #3247
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c18
-rw-r--r--src/datastore/gnunet-service-datastore.c8
2 files changed, 13 insertions, 13 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 6a994fbb0..497e654b2 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -142,7 +142,7 @@ struct GNUNET_DATASTORE_QueueEntry
142 /** 142 /**
143 * Task for timeout signalling. 143 * Task for timeout signalling.
144 */ 144 */
145 GNUNET_SCHEDULER_TaskIdentifier task; 145 struct GNUNET_SCHEDULER_Task * task;
146 146
147 /** 147 /**
148 * Timeout for the current operation. 148 * Timeout for the current operation.
@@ -216,7 +216,7 @@ struct GNUNET_DATASTORE_Handle
216 /** 216 /**
217 * Task for trying to reconnect. 217 * Task for trying to reconnect.
218 */ 218 */
219 GNUNET_SCHEDULER_TaskIdentifier reconnect_task; 219 struct GNUNET_SCHEDULER_Task * reconnect_task;
220 220
221 /** 221 /**
222 * How quickly should we retry? Used for exponential back-off on 222 * How quickly should we retry? Used for exponential back-off on
@@ -345,10 +345,10 @@ GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, int drop)
345 GNUNET_CLIENT_disconnect (h->client); 345 GNUNET_CLIENT_disconnect (h->client);
346 h->client = NULL; 346 h->client = NULL;
347 } 347 }
348 if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 348 if (h->reconnect_task != NULL)
349 { 349 {
350 GNUNET_SCHEDULER_cancel (h->reconnect_task); 350 GNUNET_SCHEDULER_cancel (h->reconnect_task);
351 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 351 h->reconnect_task = NULL;
352 } 352 }
353 while (NULL != (qe = h->queue_head)) 353 while (NULL != (qe = h->queue_head))
354 { 354 {
@@ -393,7 +393,7 @@ timeout_queue_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
393 GNUNET_STATISTICS_update (h->stats, 393 GNUNET_STATISTICS_update (h->stats,
394 gettext_noop ("# queue entry timeouts"), 1, 394 gettext_noop ("# queue entry timeouts"), 1,
395 GNUNET_NO); 395 GNUNET_NO);
396 qe->task = GNUNET_SCHEDULER_NO_TASK; 396 qe->task = NULL;
397 GNUNET_assert (GNUNET_NO == qe->was_transmitted); 397 GNUNET_assert (GNUNET_NO == qe->was_transmitted);
398 LOG (GNUNET_ERROR_TYPE_DEBUG, 398 LOG (GNUNET_ERROR_TYPE_DEBUG,
399 "Timeout of request in datastore queue\n"); 399 "Timeout of request in datastore queue\n");
@@ -521,7 +521,7 @@ try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
521 struct GNUNET_DATASTORE_Handle *h = cls; 521 struct GNUNET_DATASTORE_Handle *h = cls;
522 522
523 h->retry_time = GNUNET_TIME_STD_BACKOFF (h->retry_time); 523 h->retry_time = GNUNET_TIME_STD_BACKOFF (h->retry_time);
524 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 524 h->reconnect_task = NULL;
525 h->client = GNUNET_CLIENT_connect ("datastore", h->cfg); 525 h->client = GNUNET_CLIENT_connect ("datastore", h->cfg);
526 if (h->client == NULL) 526 if (h->client == NULL)
527 { 527 {
@@ -628,7 +628,7 @@ transmit_request (void *cls, size_t size, void *buf)
628 memcpy (buf, &qe[1], msize); 628 memcpy (buf, &qe[1], msize);
629 qe->was_transmitted = GNUNET_YES; 629 qe->was_transmitted = GNUNET_YES;
630 GNUNET_SCHEDULER_cancel (qe->task); 630 GNUNET_SCHEDULER_cancel (qe->task);
631 qe->task = GNUNET_SCHEDULER_NO_TASK; 631 qe->task = NULL;
632 GNUNET_assert (GNUNET_NO == h->in_receive); 632 GNUNET_assert (GNUNET_NO == h->in_receive);
633 h->in_receive = GNUNET_YES; 633 h->in_receive = GNUNET_YES;
634 GNUNET_CLIENT_receive (h->client, &receive_cb, h, 634 GNUNET_CLIENT_receive (h->client, &receive_cb, h,
@@ -720,10 +720,10 @@ free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe)
720 struct GNUNET_DATASTORE_Handle *h = qe->h; 720 struct GNUNET_DATASTORE_Handle *h = qe->h;
721 721
722 GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, qe); 722 GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, qe);
723 if (qe->task != GNUNET_SCHEDULER_NO_TASK) 723 if (qe->task != NULL)
724 { 724 {
725 GNUNET_SCHEDULER_cancel (qe->task); 725 GNUNET_SCHEDULER_cancel (qe->task);
726 qe->task = GNUNET_SCHEDULER_NO_TASK; 726 qe->task = NULL;
727 } 727 }
728 h->queue_size--; 728 h->queue_size--;
729 qe->was_transmitted = GNUNET_SYSERR; /* use-after-free warning */ 729 qe->was_transmitted = GNUNET_SYSERR; /* use-after-free warning */
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 0aa2273b5..ac0b5c0db 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -179,7 +179,7 @@ static unsigned long long payload;
179 * Identity of the task that is used to delete 179 * Identity of the task that is used to delete
180 * expired content. 180 * expired content.
181 */ 181 */
182static GNUNET_SCHEDULER_TaskIdentifier expired_kill_task; 182static struct GNUNET_SCHEDULER_Task * expired_kill_task;
183 183
184/** 184/**
185 * Minimum time that content should have to not be discarded instantly 185 * Minimum time that content should have to not be discarded instantly
@@ -381,7 +381,7 @@ expired_processor (void *cls,
381static void 381static void
382delete_expired (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 382delete_expired (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
383{ 383{
384 expired_kill_task = GNUNET_SCHEDULER_NO_TASK; 384 expired_kill_task = NULL;
385 plugin->api->get_expiration (plugin->api->cls, &expired_processor, NULL); 385 plugin->api->get_expiration (plugin->api->cls, &expired_processor, NULL);
386} 386}
387 387
@@ -1423,10 +1423,10 @@ cleaning_task (void *cls,
1423 GNUNET_free (tcc->msg); 1423 GNUNET_free (tcc->msg);
1424 GNUNET_free (tcc); 1424 GNUNET_free (tcc);
1425 } 1425 }
1426 if (expired_kill_task != GNUNET_SCHEDULER_NO_TASK) 1426 if (expired_kill_task != NULL)
1427 { 1427 {
1428 GNUNET_SCHEDULER_cancel (expired_kill_task); 1428 GNUNET_SCHEDULER_cancel (expired_kill_task);
1429 expired_kill_task = GNUNET_SCHEDULER_NO_TASK; 1429 expired_kill_task = NULL;
1430 } 1430 }
1431 if (GNUNET_YES == do_drop) 1431 if (GNUNET_YES == do_drop)
1432 plugin->api->drop (plugin->api->cls); 1432 plugin->api->drop (plugin->api->cls);