diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
commit | f1f603c7d0b3f03dca46a4f313472288eb080eb1 (patch) | |
tree | 3a29966b02dfb83e0a8a8d5c42b3116380209fb0 /src/testbed/gnunet-service-testbed_links.c | |
parent | 53cd5b8eda2fa8db86b0907a62a39598981d008a (diff) | |
download | gnunet-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/testbed/gnunet-service-testbed_links.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_links.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/testbed/gnunet-service-testbed_links.c b/src/testbed/gnunet-service-testbed_links.c index cb908f12b..4c2e6c58a 100644 --- a/src/testbed/gnunet-service-testbed_links.c +++ b/src/testbed/gnunet-service-testbed_links.c | |||
@@ -92,7 +92,7 @@ struct LCFContext | |||
92 | /** | 92 | /** |
93 | * The timeout task | 93 | * The timeout task |
94 | */ | 94 | */ |
95 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 95 | struct GNUNET_SCHEDULER_Task * timeout_task; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * The id of the operation which created this context | 98 | * The id of the operation which created this context |
@@ -206,7 +206,7 @@ struct Neighbour | |||
206 | /** | 206 | /** |
207 | * Task id for the task to call notifications from the notification list | 207 | * Task id for the task to call notifications from the notification list |
208 | */ | 208 | */ |
209 | GNUNET_SCHEDULER_TaskIdentifier notify_task; | 209 | struct GNUNET_SCHEDULER_Task * notify_task; |
210 | 210 | ||
211 | /** | 211 | /** |
212 | * How many references are present currently to this neighbour's connection | 212 | * How many references are present currently to this neighbour's connection |
@@ -265,7 +265,7 @@ struct NeighbourConnectCtxt | |||
265 | /** | 265 | /** |
266 | * Task to be run upon timeout | 266 | * Task to be run upon timeout |
267 | */ | 267 | */ |
268 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 268 | struct GNUNET_SCHEDULER_Task * timeout_task; |
269 | 269 | ||
270 | /** | 270 | /** |
271 | * The notification handle associated with the neighbour's connection request | 271 | * The notification handle associated with the neighbour's connection request |
@@ -317,7 +317,7 @@ static struct LCFContextQueue *lcfq_tail; | |||
317 | /** | 317 | /** |
318 | * The lcf_task handle | 318 | * The lcf_task handle |
319 | */ | 319 | */ |
320 | static GNUNET_SCHEDULER_TaskIdentifier lcf_proc_task_id; | 320 | static struct GNUNET_SCHEDULER_Task * lcf_proc_task_id; |
321 | 321 | ||
322 | /** | 322 | /** |
323 | * The size of the route list | 323 | * The size of the route list |
@@ -602,7 +602,7 @@ lcf_proc_cc (void *cls, const char *emsg) | |||
602 | { | 602 | { |
603 | struct LCFContext *lcf = cls; | 603 | struct LCFContext *lcf = cls; |
604 | 604 | ||
605 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 605 | GNUNET_assert (NULL == lcf_proc_task_id); |
606 | switch (lcf->state) | 606 | switch (lcf->state) |
607 | { | 607 | { |
608 | case INIT: | 608 | case INIT: |
@@ -652,14 +652,14 @@ lcf_forwarded_operation_timeout (void *cls, | |||
652 | { | 652 | { |
653 | struct LCFContext *lcf = cls; | 653 | struct LCFContext *lcf = cls; |
654 | 654 | ||
655 | lcf->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 655 | lcf->timeout_task = NULL; |
656 | // GST_forwarded_operation_timeout (lcf->fopc, tc); | 656 | // GST_forwarded_operation_timeout (lcf->fopc, tc); |
657 | LOG (GNUNET_ERROR_TYPE_WARNING, | 657 | LOG (GNUNET_ERROR_TYPE_WARNING, |
658 | "A forwarded controller link operation has timed out\n"); | 658 | "A forwarded controller link operation has timed out\n"); |
659 | send_controller_link_response (lcf->client, lcf->operation_id, NULL, | 659 | send_controller_link_response (lcf->client, lcf->operation_id, NULL, |
660 | "A forwarded controller link operation has " | 660 | "A forwarded controller link operation has " |
661 | "timed out\n"); | 661 | "timed out\n"); |
662 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 662 | GNUNET_assert (NULL == lcf_proc_task_id); |
663 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 663 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
664 | } | 664 | } |
665 | 665 | ||
@@ -676,7 +676,7 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
676 | struct LCFContext *lcf = cls; | 676 | struct LCFContext *lcf = cls; |
677 | struct LCFContextQueue *lcfq; | 677 | struct LCFContextQueue *lcfq; |
678 | 678 | ||
679 | lcf_proc_task_id = GNUNET_SCHEDULER_NO_TASK; | 679 | lcf_proc_task_id = NULL; |
680 | switch (lcf->state) | 680 | switch (lcf->state) |
681 | { | 681 | { |
682 | case INIT: | 682 | case INIT: |
@@ -753,7 +753,7 @@ slave_event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
753 | GNUNET_TESTBED_operation_done (lcf->op); | 753 | GNUNET_TESTBED_operation_done (lcf->op); |
754 | lcf->op = NULL; | 754 | lcf->op = NULL; |
755 | GNUNET_assert (FINISHED == lcf->state); | 755 | GNUNET_assert (FINISHED == lcf->state); |
756 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != lcf->timeout_task); | 756 | GNUNET_assert (NULL != lcf->timeout_task); |
757 | GNUNET_SCHEDULER_cancel (lcf->timeout_task); | 757 | GNUNET_SCHEDULER_cancel (lcf->timeout_task); |
758 | if (NULL == event->details.operation_finished.emsg) | 758 | if (NULL == event->details.operation_finished.emsg) |
759 | send_controller_link_response (lcf->client, lcf->operation_id, | 759 | send_controller_link_response (lcf->client, lcf->operation_id, |
@@ -764,7 +764,7 @@ slave_event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
764 | send_controller_link_response (lcf->client, lcf->operation_id, | 764 | send_controller_link_response (lcf->client, lcf->operation_id, |
765 | NULL, | 765 | NULL, |
766 | event->details.operation_finished.emsg); | 766 | event->details.operation_finished.emsg); |
767 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 767 | GNUNET_assert (NULL == lcf_proc_task_id); |
768 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 768 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
769 | return; | 769 | return; |
770 | } | 770 | } |
@@ -862,8 +862,8 @@ neighbour_connect_notify_task (void *cls, | |||
862 | struct NeighbourConnectNotification *h; | 862 | struct NeighbourConnectNotification *h; |
863 | 863 | ||
864 | GNUNET_assert (NULL != (h = n->nl_head)); | 864 | GNUNET_assert (NULL != (h = n->nl_head)); |
865 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != n->notify_task); | 865 | GNUNET_assert (NULL != n->notify_task); |
866 | n->notify_task = GNUNET_SCHEDULER_NO_TASK; | 866 | n->notify_task = NULL; |
867 | GNUNET_assert (NULL != n->controller); | 867 | GNUNET_assert (NULL != n->controller); |
868 | GNUNET_CONTAINER_DLL_remove (n->nl_head, n->nl_tail, h); | 868 | GNUNET_CONTAINER_DLL_remove (n->nl_head, n->nl_tail, h); |
869 | trigger_notifications (n); | 869 | trigger_notifications (n); |
@@ -888,7 +888,7 @@ trigger_notifications (struct Neighbour *n) | |||
888 | return; | 888 | return; |
889 | if (NULL == n->controller) | 889 | if (NULL == n->controller) |
890 | return; | 890 | return; |
891 | if (GNUNET_SCHEDULER_NO_TASK != n->notify_task) | 891 | if (NULL != n->notify_task) |
892 | return; | 892 | return; |
893 | if (1 == n->inactive) | 893 | if (1 == n->inactive) |
894 | { | 894 | { |
@@ -936,7 +936,7 @@ oprelease_neighbour_conn (void *cls) | |||
936 | struct Neighbour *n = cls; | 936 | struct Neighbour *n = cls; |
937 | 937 | ||
938 | GNUNET_assert (0 == n->reference_cnt); | 938 | GNUNET_assert (0 == n->reference_cnt); |
939 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == n->notify_task); | 939 | GNUNET_assert (NULL == n->notify_task); |
940 | GNUNET_assert (NULL == n->nl_head); | 940 | GNUNET_assert (NULL == n->nl_head); |
941 | if (NULL != n->controller) | 941 | if (NULL != n->controller) |
942 | { | 942 | { |
@@ -1006,12 +1006,12 @@ GST_neighbour_get_connection_cancel (struct NeighbourConnectNotification *h) | |||
1006 | GNUNET_free (h); | 1006 | GNUNET_free (h); |
1007 | if (GNUNET_NO == cleanup_task) | 1007 | if (GNUNET_NO == cleanup_task) |
1008 | return; | 1008 | return; |
1009 | if (GNUNET_SCHEDULER_NO_TASK == n->notify_task) | 1009 | if (NULL == n->notify_task) |
1010 | return; | 1010 | return; |
1011 | GNUNET_assert (0 < n->reference_cnt); | 1011 | GNUNET_assert (0 < n->reference_cnt); |
1012 | n->reference_cnt--; | 1012 | n->reference_cnt--; |
1013 | GNUNET_SCHEDULER_cancel (n->notify_task); | 1013 | GNUNET_SCHEDULER_cancel (n->notify_task); |
1014 | n->notify_task = GNUNET_SCHEDULER_NO_TASK; | 1014 | n->notify_task = NULL; |
1015 | if (NULL == n->nl_head) | 1015 | if (NULL == n->nl_head) |
1016 | { | 1016 | { |
1017 | if ( (0 == n->reference_cnt) && (0 == n->inactive) ) | 1017 | if ( (0 == n->reference_cnt) && (0 == n->inactive) ) |
@@ -1056,7 +1056,7 @@ cleanup_ncc (struct NeighbourConnectCtxt *ncc) | |||
1056 | { | 1056 | { |
1057 | if (NULL != ncc->nh) | 1057 | if (NULL != ncc->nh) |
1058 | GST_neighbour_get_connection_cancel (ncc->nh); | 1058 | GST_neighbour_get_connection_cancel (ncc->nh); |
1059 | if (GNUNET_SCHEDULER_NO_TASK != ncc->timeout_task) | 1059 | if (NULL != ncc->timeout_task) |
1060 | GNUNET_SCHEDULER_cancel (ncc->timeout_task); | 1060 | GNUNET_SCHEDULER_cancel (ncc->timeout_task); |
1061 | GNUNET_SERVER_client_drop (ncc->client); | 1061 | GNUNET_SERVER_client_drop (ncc->client); |
1062 | GNUNET_CONTAINER_DLL_remove (ncc_head, ncc_tail, ncc); | 1062 | GNUNET_CONTAINER_DLL_remove (ncc_head, ncc_tail, ncc); |
@@ -1126,7 +1126,7 @@ timeout_neighbour_connect (void *cls, | |||
1126 | { | 1126 | { |
1127 | struct NeighbourConnectCtxt *ncc = cls; | 1127 | struct NeighbourConnectCtxt *ncc = cls; |
1128 | 1128 | ||
1129 | ncc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1129 | ncc->timeout_task = NULL; |
1130 | send_controller_link_response (ncc->client, ncc->op_id, NULL, | 1130 | send_controller_link_response (ncc->client, ncc->op_id, NULL, |
1131 | "Could not connect to delegated controller"); | 1131 | "Could not connect to delegated controller"); |
1132 | cleanup_ncc (ncc); | 1132 | cleanup_ncc (ncc); |
@@ -1145,7 +1145,7 @@ neighbour_connect_cb (void *cls, struct GNUNET_TESTBED_Controller *c) | |||
1145 | struct NeighbourConnectCtxt *ncc = cls; | 1145 | struct NeighbourConnectCtxt *ncc = cls; |
1146 | 1146 | ||
1147 | GNUNET_SCHEDULER_cancel (ncc->timeout_task); | 1147 | GNUNET_SCHEDULER_cancel (ncc->timeout_task); |
1148 | ncc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1148 | ncc->timeout_task = NULL; |
1149 | ncc->nh = NULL; | 1149 | ncc->nh = NULL; |
1150 | GST_neighbour_release_connection (ncc->n); | 1150 | GST_neighbour_release_connection (ncc->n); |
1151 | send_controller_link_response (ncc->client, ncc->op_id, NULL, NULL); | 1151 | send_controller_link_response (ncc->client, ncc->op_id, NULL, NULL); |
@@ -1314,7 +1314,7 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1314 | lcfq->lcf->client = client; | 1314 | lcfq->lcf->client = client; |
1315 | if (NULL == lcfq_head) | 1315 | if (NULL == lcfq_head) |
1316 | { | 1316 | { |
1317 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 1317 | GNUNET_assert (NULL == lcf_proc_task_id); |
1318 | GNUNET_CONTAINER_DLL_insert_tail (lcfq_head, lcfq_tail, lcfq); | 1318 | GNUNET_CONTAINER_DLL_insert_tail (lcfq_head, lcfq_tail, lcfq); |
1319 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcfq->lcf); | 1319 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcfq->lcf); |
1320 | } | 1320 | } |
@@ -1354,20 +1354,20 @@ GST_free_lcfq () | |||
1354 | 1354 | ||
1355 | if (NULL != lcfq_head) | 1355 | if (NULL != lcfq_head) |
1356 | { | 1356 | { |
1357 | if (GNUNET_SCHEDULER_NO_TASK != lcf_proc_task_id) | 1357 | if (NULL != lcf_proc_task_id) |
1358 | { | 1358 | { |
1359 | GNUNET_SCHEDULER_cancel (lcf_proc_task_id); | 1359 | GNUNET_SCHEDULER_cancel (lcf_proc_task_id); |
1360 | lcf_proc_task_id = GNUNET_SCHEDULER_NO_TASK; | 1360 | lcf_proc_task_id = NULL; |
1361 | } | 1361 | } |
1362 | } | 1362 | } |
1363 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 1363 | GNUNET_assert (NULL == lcf_proc_task_id); |
1364 | for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head) | 1364 | for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head) |
1365 | { | 1365 | { |
1366 | lcf = lcfq->lcf; | 1366 | lcf = lcfq->lcf; |
1367 | GNUNET_SERVER_client_drop (lcf->client); | 1367 | GNUNET_SERVER_client_drop (lcf->client); |
1368 | if (NULL != lcf->op) | 1368 | if (NULL != lcf->op) |
1369 | GNUNET_TESTBED_operation_done (lcf->op); | 1369 | GNUNET_TESTBED_operation_done (lcf->op); |
1370 | if (GNUNET_SCHEDULER_NO_TASK != lcf->timeout_task) | 1370 | if (NULL != lcf->timeout_task) |
1371 | GNUNET_SCHEDULER_cancel (lcf->timeout_task); | 1371 | GNUNET_SCHEDULER_cancel (lcf->timeout_task); |
1372 | GNUNET_free (lcf); | 1372 | GNUNET_free (lcf); |
1373 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); | 1373 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); |