aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_cadet_client.c
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/fs/gnunet-service-fs_cadet_client.c
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/fs/gnunet-service-fs_cadet_client.c')
-rw-r--r--src/fs/gnunet-service-fs_cadet_client.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/fs/gnunet-service-fs_cadet_client.c b/src/fs/gnunet-service-fs_cadet_client.c
index f0905e6c3..88014f204 100644
--- a/src/fs/gnunet-service-fs_cadet_client.c
+++ b/src/fs/gnunet-service-fs_cadet_client.c
@@ -140,14 +140,14 @@ struct CadetHandle
140 * a few seconds to give the application a chance to give 140 * a few seconds to give the application a chance to give
141 * us another query). 141 * us another query).
142 */ 142 */
143 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 143 struct GNUNET_SCHEDULER_Task * timeout_task;
144 144
145 /** 145 /**
146 * Task to reset cadets that had errors (asynchronously, 146 * Task to reset cadets that had errors (asynchronously,
147 * as we may not be able to do it immediately during a 147 * as we may not be able to do it immediately during a
148 * callback from the cadet API). 148 * callback from the cadet API).
149 */ 149 */
150 GNUNET_SCHEDULER_TaskIdentifier reset_task; 150 struct GNUNET_SCHEDULER_Task * reset_task;
151 151
152}; 152};
153 153
@@ -258,7 +258,7 @@ cadet_timeout (void *cls,
258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
259 "Timeout on cadet channel to %s\n", 259 "Timeout on cadet channel to %s\n",
260 GNUNET_i2s (&mh->target)); 260 GNUNET_i2s (&mh->target));
261 mh->timeout_task = GNUNET_SCHEDULER_NO_TASK; 261 mh->timeout_task = NULL;
262 tun = mh->channel; 262 tun = mh->channel;
263 mh->channel = NULL; 263 mh->channel = NULL;
264 if(NULL != tun) 264 if(NULL != tun)
@@ -278,7 +278,7 @@ reset_cadet_task (void *cls,
278{ 278{
279 struct CadetHandle *mh = cls; 279 struct CadetHandle *mh = cls;
280 280
281 mh->reset_task = GNUNET_SCHEDULER_NO_TASK; 281 mh->reset_task = NULL;
282 reset_cadet (mh); 282 reset_cadet (mh);
283} 283}
284 284
@@ -292,7 +292,7 @@ reset_cadet_task (void *cls,
292static void 292static void
293reset_cadet_async (struct CadetHandle *mh) 293reset_cadet_async (struct CadetHandle *mh)
294{ 294{
295 if (GNUNET_SCHEDULER_NO_TASK != mh->reset_task) 295 if (NULL != mh->reset_task)
296 GNUNET_SCHEDULER_cancel (mh->reset_task); 296 GNUNET_SCHEDULER_cancel (mh->reset_task);
297 mh->reset_task = GNUNET_SCHEDULER_add_now (&reset_cadet_task, 297 mh->reset_task = GNUNET_SCHEDULER_add_now (&reset_cadet_task,
298 mh); 298 mh);
@@ -527,10 +527,10 @@ get_cadet (const struct GNUNET_PeerIdentity *target)
527 target); 527 target);
528 if (NULL != mh) 528 if (NULL != mh)
529 { 529 {
530 if (GNUNET_SCHEDULER_NO_TASK != mh->timeout_task) 530 if (NULL != mh->timeout_task)
531 { 531 {
532 GNUNET_SCHEDULER_cancel (mh->timeout_task); 532 GNUNET_SCHEDULER_cancel (mh->timeout_task);
533 mh->timeout_task = GNUNET_SCHEDULER_NO_TASK; 533 mh->timeout_task = NULL;
534 } 534 }
535 return mh; 535 return mh;
536 } 536 }
@@ -698,9 +698,9 @@ cleaner_cb (void *cls,
698 mh); 698 mh);
699 if (NULL != mh->wh) 699 if (NULL != mh->wh)
700 GNUNET_CADET_notify_transmit_ready_cancel (mh->wh); 700 GNUNET_CADET_notify_transmit_ready_cancel (mh->wh);
701 if (GNUNET_SCHEDULER_NO_TASK != mh->timeout_task) 701 if (NULL != mh->timeout_task)
702 GNUNET_SCHEDULER_cancel (mh->timeout_task); 702 GNUNET_SCHEDULER_cancel (mh->timeout_task);
703 if (GNUNET_SCHEDULER_NO_TASK != mh->reset_task) 703 if (NULL != mh->reset_task)
704 GNUNET_SCHEDULER_cancel (mh->reset_task); 704 GNUNET_SCHEDULER_cancel (mh->reset_task);
705 GNUNET_assert (0 == 705 GNUNET_assert (0 ==
706 GNUNET_CONTAINER_multihashmap_size (mh->waiting_map)); 706 GNUNET_CONTAINER_multihashmap_size (mh->waiting_map));