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/identity | |
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/identity')
-rw-r--r-- | src/identity/identity_api.c | 10 | ||||
-rw-r--r-- | src/identity/test_identity.c | 6 | ||||
-rw-r--r-- | src/identity/test_identity_defaults.c | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index 3028ff3fd..d4ee6c01b 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -155,7 +155,7 @@ struct GNUNET_IDENTITY_Handle | |||
155 | /** | 155 | /** |
156 | * Task doing exponential back-off trying to reconnect. | 156 | * Task doing exponential back-off trying to reconnect. |
157 | */ | 157 | */ |
158 | GNUNET_SCHEDULER_TaskIdentifier reconnect_task; | 158 | struct GNUNET_SCHEDULER_Task * reconnect_task; |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * Time for next connect retry. | 161 | * Time for next connect retry. |
@@ -210,7 +210,7 @@ reconnect (void *cls, | |||
210 | static void | 210 | static void |
211 | reschedule_connect (struct GNUNET_IDENTITY_Handle *h) | 211 | reschedule_connect (struct GNUNET_IDENTITY_Handle *h) |
212 | { | 212 | { |
213 | GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); | 213 | GNUNET_assert (h->reconnect_task == NULL); |
214 | 214 | ||
215 | if (NULL != h->th) | 215 | if (NULL != h->th) |
216 | { | 216 | { |
@@ -542,7 +542,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
542 | struct GNUNET_IDENTITY_Operation *op; | 542 | struct GNUNET_IDENTITY_Operation *op; |
543 | struct GNUNET_MessageHeader msg; | 543 | struct GNUNET_MessageHeader msg; |
544 | 544 | ||
545 | h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 545 | h->reconnect_task = NULL; |
546 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 546 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
547 | "Connecting to identity service.\n"); | 547 | "Connecting to identity service.\n"); |
548 | GNUNET_assert (NULL == h->client); | 548 | GNUNET_assert (NULL == h->client); |
@@ -966,10 +966,10 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) | |||
966 | struct GNUNET_IDENTITY_Operation *op; | 966 | struct GNUNET_IDENTITY_Operation *op; |
967 | 967 | ||
968 | GNUNET_assert (NULL != h); | 968 | GNUNET_assert (NULL != h); |
969 | if (h->reconnect_task != GNUNET_SCHEDULER_NO_TASK) | 969 | if (h->reconnect_task != NULL) |
970 | { | 970 | { |
971 | GNUNET_SCHEDULER_cancel (h->reconnect_task); | 971 | GNUNET_SCHEDULER_cancel (h->reconnect_task); |
972 | h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 972 | h->reconnect_task = NULL; |
973 | } | 973 | } |
974 | if (NULL != h->th) | 974 | if (NULL != h->th) |
975 | { | 975 | { |
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c index 6797afe3c..0dca38411 100644 --- a/src/identity/test_identity.c +++ b/src/identity/test_identity.c | |||
@@ -50,7 +50,7 @@ static struct GNUNET_IDENTITY_Operation *op; | |||
50 | /** | 50 | /** |
51 | * Handle for task for timeout termination. | 51 | * Handle for task for timeout termination. |
52 | */ | 52 | */ |
53 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 53 | static struct GNUNET_SCHEDULER_Task * endbadly_task; |
54 | 54 | ||
55 | 55 | ||
56 | /** | 56 | /** |
@@ -107,10 +107,10 @@ end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
107 | static void | 107 | static void |
108 | end () | 108 | end () |
109 | { | 109 | { |
110 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 110 | if (endbadly_task != NULL) |
111 | { | 111 | { |
112 | GNUNET_SCHEDULER_cancel (endbadly_task); | 112 | GNUNET_SCHEDULER_cancel (endbadly_task); |
113 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 113 | endbadly_task = NULL; |
114 | } | 114 | } |
115 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 115 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, |
116 | &end_normally, NULL); | 116 | &end_normally, NULL); |
diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c index 980f4abd2..0d9c2ee27 100644 --- a/src/identity/test_identity_defaults.c +++ b/src/identity/test_identity_defaults.c | |||
@@ -50,7 +50,7 @@ static struct GNUNET_IDENTITY_Operation *op; | |||
50 | /** | 50 | /** |
51 | * Handle for task for timeout termination. | 51 | * Handle for task for timeout termination. |
52 | */ | 52 | */ |
53 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 53 | static struct GNUNET_SCHEDULER_Task * endbadly_task; |
54 | 54 | ||
55 | 55 | ||
56 | /** | 56 | /** |
@@ -107,10 +107,10 @@ end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
107 | static void | 107 | static void |
108 | end () | 108 | end () |
109 | { | 109 | { |
110 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 110 | if (endbadly_task != NULL) |
111 | { | 111 | { |
112 | GNUNET_SCHEDULER_cancel (endbadly_task); | 112 | GNUNET_SCHEDULER_cancel (endbadly_task); |
113 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 113 | endbadly_task = NULL; |
114 | } | 114 | } |
115 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | 115 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, |
116 | &end_normally, NULL); | 116 | &end_normally, NULL); |