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/set | |
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/set')
-rw-r--r-- | src/set/gnunet-service-set.c | 12 | ||||
-rw-r--r-- | src/set/gnunet-service-set.h | 2 | ||||
-rw-r--r-- | src/set/set_api.c | 8 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 2291bd2f2..dc5a787f6 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -475,10 +475,10 @@ incoming_destroy (struct Operation *incoming) | |||
475 | GNUNET_CONTAINER_DLL_remove (incoming_head, | 475 | GNUNET_CONTAINER_DLL_remove (incoming_head, |
476 | incoming_tail, | 476 | incoming_tail, |
477 | incoming); | 477 | incoming); |
478 | if (GNUNET_SCHEDULER_NO_TASK != incoming->timeout_task) | 478 | if (NULL != incoming->timeout_task) |
479 | { | 479 | { |
480 | GNUNET_SCHEDULER_cancel (incoming->timeout_task); | 480 | GNUNET_SCHEDULER_cancel (incoming->timeout_task); |
481 | incoming->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 481 | incoming->timeout_task = NULL; |
482 | } | 482 | } |
483 | /* make sure that the tunnel end handler will not destroy us again */ | 483 | /* make sure that the tunnel end handler will not destroy us again */ |
484 | incoming->vt = NULL; | 484 | incoming->vt = NULL; |
@@ -543,9 +543,9 @@ incoming_suggest (struct Operation *incoming, | |||
543 | incoming->suggest_id = suggest_id++; | 543 | incoming->suggest_id = suggest_id++; |
544 | if (0 == suggest_id) | 544 | if (0 == suggest_id) |
545 | suggest_id++; | 545 | suggest_id++; |
546 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != incoming->timeout_task); | 546 | GNUNET_assert (NULL != incoming->timeout_task); |
547 | GNUNET_SCHEDULER_cancel (incoming->timeout_task); | 547 | GNUNET_SCHEDULER_cancel (incoming->timeout_task); |
548 | incoming->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 548 | incoming->timeout_task = NULL; |
549 | mqm = GNUNET_MQ_msg_nested_mh (cmsg, | 549 | mqm = GNUNET_MQ_msg_nested_mh (cmsg, |
550 | GNUNET_MESSAGE_TYPE_SET_REQUEST, | 550 | GNUNET_MESSAGE_TYPE_SET_REQUEST, |
551 | incoming->spec->context_msg); | 551 | incoming->spec->context_msg); |
@@ -624,7 +624,7 @@ handle_incoming_msg (struct Operation *op, | |||
624 | &msg->app_id); | 624 | &msg->app_id); |
625 | if (NULL == listener) | 625 | if (NULL == listener) |
626 | { | 626 | { |
627 | GNUNET_break (GNUNET_SCHEDULER_NO_TASK != op->timeout_task); | 627 | GNUNET_break (NULL != op->timeout_task); |
628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
629 | "No matching listener for incoming request (op %u, app %s), waiting with timeout\n", | 629 | "No matching listener for incoming request (op %u, app %s), waiting with timeout\n", |
630 | ntohl (msg->operation), | 630 | ntohl (msg->operation), |
@@ -1279,7 +1279,7 @@ incoming_timeout_cb (void *cls, | |||
1279 | { | 1279 | { |
1280 | struct Operation *incoming = cls; | 1280 | struct Operation *incoming = cls; |
1281 | 1281 | ||
1282 | incoming->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1282 | incoming->timeout_task = NULL; |
1283 | GNUNET_assert (GNUNET_YES == incoming->is_incoming); | 1283 | GNUNET_assert (GNUNET_YES == incoming->is_incoming); |
1284 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1284 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1285 | return; | 1285 | return; |
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h index b2904dc06..d1b957e73 100644 --- a/src/set/gnunet-service-set.h +++ b/src/set/gnunet-service-set.h | |||
@@ -366,7 +366,7 @@ struct Operation | |||
366 | * Timeout task, if the incoming peer has not been accepted | 366 | * Timeout task, if the incoming peer has not been accepted |
367 | * after the timeout, it will be disconnected. | 367 | * after the timeout, it will be disconnected. |
368 | */ | 368 | */ |
369 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 369 | struct GNUNET_SCHEDULER_Task * timeout_task; |
370 | 370 | ||
371 | /** | 371 | /** |
372 | * Unique request id for the request from a remote peer, sent to the | 372 | * Unique request id for the request from a remote peer, sent to the |
diff --git a/src/set/set_api.c b/src/set/set_api.c index 453a235b2..0327daab1 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -204,7 +204,7 @@ struct GNUNET_SET_ListenHandle | |||
204 | /** | 204 | /** |
205 | * Task for reconnecting when the listener fails. | 205 | * Task for reconnecting when the listener fails. |
206 | */ | 206 | */ |
207 | GNUNET_SCHEDULER_TaskIdentifier reconnect_task; | 207 | struct GNUNET_SCHEDULER_Task * reconnect_task; |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * Operation we listen for. | 210 | * Operation we listen for. |
@@ -786,7 +786,7 @@ listen_connect (void *cls, | |||
786 | "Listener not reconnecting due to shutdown\n"); | 786 | "Listener not reconnecting due to shutdown\n"); |
787 | return; | 787 | return; |
788 | } | 788 | } |
789 | lh->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 789 | lh->reconnect_task = NULL; |
790 | GNUNET_assert (NULL == lh->client); | 790 | GNUNET_assert (NULL == lh->client); |
791 | lh->client = GNUNET_CLIENT_connect ("set", lh->cfg); | 791 | lh->client = GNUNET_CLIENT_connect ("set", lh->cfg); |
792 | if (NULL == lh->client) | 792 | if (NULL == lh->client) |
@@ -860,10 +860,10 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) | |||
860 | GNUNET_CLIENT_disconnect (lh->client); | 860 | GNUNET_CLIENT_disconnect (lh->client); |
861 | lh->client = NULL; | 861 | lh->client = NULL; |
862 | } | 862 | } |
863 | if (GNUNET_SCHEDULER_NO_TASK != lh->reconnect_task) | 863 | if (NULL != lh->reconnect_task) |
864 | { | 864 | { |
865 | GNUNET_SCHEDULER_cancel (lh->reconnect_task); | 865 | GNUNET_SCHEDULER_cancel (lh->reconnect_task); |
866 | lh->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 866 | lh->reconnect_task = NULL; |
867 | } | 867 | } |
868 | GNUNET_free (lh); | 868 | GNUNET_free (lh); |
869 | } | 869 | } |