aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo
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/peerinfo
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/peerinfo')
-rw-r--r--src/peerinfo/peerinfo_api.c20
-rw-r--r--src/peerinfo/peerinfo_api_notify.c6
-rw-r--r--src/peerinfo/test_peerinfo_api_notify_friend_only.c8
3 files changed, 17 insertions, 17 deletions
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index 20042f8e3..e2539bd55 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -110,7 +110,7 @@ struct GNUNET_PEERINFO_IteratorContext
110 /** 110 /**
111 * Task responsible for timeout. 111 * Task responsible for timeout.
112 */ 112 */
113 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 113 struct GNUNET_SCHEDULER_Task * timeout_task;
114 114
115 /** 115 /**
116 * Timeout for the operation. 116 * Timeout for the operation.
@@ -179,7 +179,7 @@ struct GNUNET_PEERINFO_Handle
179 /** 179 /**
180 * ID for a reconnect task. 180 * ID for a reconnect task.
181 */ 181 */
182 GNUNET_SCHEDULER_TaskIdentifier r_task; 182 struct GNUNET_SCHEDULER_Task * r_task;
183 183
184 /** 184 /**
185 * Are we now receiving? 185 * Are we now receiving?
@@ -247,10 +247,10 @@ GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h)
247 GNUNET_CLIENT_disconnect (h->client); 247 GNUNET_CLIENT_disconnect (h->client);
248 h->client = NULL; 248 h->client = NULL;
249 } 249 }
250 if (GNUNET_SCHEDULER_NO_TASK != h->r_task) 250 if (NULL != h->r_task)
251 { 251 {
252 GNUNET_SCHEDULER_cancel (h->r_task); 252 GNUNET_SCHEDULER_cancel (h->r_task);
253 h->r_task = GNUNET_SCHEDULER_NO_TASK; 253 h->r_task = NULL;
254 } 254 }
255 GNUNET_free (h); 255 GNUNET_free (h);
256} 256}
@@ -287,7 +287,7 @@ reconnect_task (void *cls,
287{ 287{
288 struct GNUNET_PEERINFO_Handle *h = cls; 288 struct GNUNET_PEERINFO_Handle *h = cls;
289 289
290 h->r_task = GNUNET_SCHEDULER_NO_TASK; 290 h->r_task = NULL;
291 reconnect (h); 291 reconnect (h);
292} 292}
293 293
@@ -300,10 +300,10 @@ reconnect_task (void *cls,
300static void 300static void
301reconnect (struct GNUNET_PEERINFO_Handle *h) 301reconnect (struct GNUNET_PEERINFO_Handle *h)
302{ 302{
303 if (GNUNET_SCHEDULER_NO_TASK != h->r_task) 303 if (NULL != h->r_task)
304 { 304 {
305 GNUNET_SCHEDULER_cancel (h->r_task); 305 GNUNET_SCHEDULER_cancel (h->r_task);
306 h->r_task = GNUNET_SCHEDULER_NO_TASK; 306 h->r_task = NULL;
307 } 307 }
308 if (NULL != h->th) 308 if (NULL != h->th)
309 { 309 {
@@ -709,7 +709,7 @@ signal_timeout (void *cls,
709 GNUNET_PEERINFO_Processor cb; 709 GNUNET_PEERINFO_Processor cb;
710 void *cb_cls; 710 void *cb_cls;
711 711
712 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; 712 ic->timeout_task = NULL;
713 cb = ic->callback; 713 cb = ic->callback;
714 cb_cls = ic->callback_cls; 714 cb_cls = ic->callback_cls;
715 GNUNET_PEERINFO_iterate_cancel (ic); 715 GNUNET_PEERINFO_iterate_cancel (ic);
@@ -811,10 +811,10 @@ GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
811 struct GNUNET_PEERINFO_Handle *h; 811 struct GNUNET_PEERINFO_Handle *h;
812 812
813 h = ic->h; 813 h = ic->h;
814 if (GNUNET_SCHEDULER_NO_TASK != ic->timeout_task) 814 if (NULL != ic->timeout_task)
815 { 815 {
816 GNUNET_SCHEDULER_cancel (ic->timeout_task); 816 GNUNET_SCHEDULER_cancel (ic->timeout_task);
817 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; 817 ic->timeout_task = NULL;
818 } 818 }
819 ic->callback = NULL; 819 ic->callback = NULL;
820 if (GNUNET_YES == ic->request_transmitted) 820 if (GNUNET_YES == ic->request_transmitted)
diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c
index af41b08f9..aaa62588e 100644
--- a/src/peerinfo/peerinfo_api_notify.c
+++ b/src/peerinfo/peerinfo_api_notify.c
@@ -66,7 +66,7 @@ struct GNUNET_PEERINFO_NotifyContext
66 /** 66 /**
67 * Tasked used for delayed re-connection attempt. 67 * Tasked used for delayed re-connection attempt.
68 */ 68 */
69 GNUNET_SCHEDULER_TaskIdentifier task; 69 struct GNUNET_SCHEDULER_Task * task;
70 70
71 /** 71 /**
72 * Include friend only HELLOs in callbacks 72 * Include friend only HELLOs in callbacks
@@ -107,7 +107,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
107{ 107{
108 struct GNUNET_PEERINFO_NotifyContext *nc = cls; 108 struct GNUNET_PEERINFO_NotifyContext *nc = cls;
109 109
110 nc->task = GNUNET_SCHEDULER_NO_TASK; 110 nc->task = NULL;
111 nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg); 111 nc->client = GNUNET_CLIENT_connect ("peerinfo", nc->cfg);
112 if (NULL == nc->client) 112 if (NULL == nc->client)
113 { 113 {
@@ -295,7 +295,7 @@ GNUNET_PEERINFO_notify_cancel (struct GNUNET_PEERINFO_NotifyContext *nc)
295 } 295 }
296 if (NULL != nc->client) 296 if (NULL != nc->client)
297 GNUNET_CLIENT_disconnect (nc->client); 297 GNUNET_CLIENT_disconnect (nc->client);
298 if (GNUNET_SCHEDULER_NO_TASK != nc->task) 298 if (NULL != nc->task)
299 GNUNET_SCHEDULER_cancel (nc->task); 299 GNUNET_SCHEDULER_cancel (nc->task);
300 GNUNET_free (nc); 300 GNUNET_free (nc);
301} 301}
diff --git a/src/peerinfo/test_peerinfo_api_notify_friend_only.c b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
index c47fe6387..0b252621e 100644
--- a/src/peerinfo/test_peerinfo_api_notify_friend_only.c
+++ b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
@@ -58,12 +58,12 @@ static int res_cb_wo_fo;
58 58
59struct GNUNET_PeerIdentity pid; 59struct GNUNET_PeerIdentity pid;
60 60
61GNUNET_SCHEDULER_TaskIdentifier timeout_task; 61struct GNUNET_SCHEDULER_Task * timeout_task;
62 62
63static void 63static void
64end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 64end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
65{ 65{
66 timeout_task = GNUNET_SCHEDULER_NO_TASK; 66 timeout_task = NULL;
67 GNUNET_break(0); 67 GNUNET_break(0);
68 if (NULL != pnc_wo_fo) 68 if (NULL != pnc_wo_fo)
69 { 69 {
@@ -95,10 +95,10 @@ done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
95 GNUNET_PEERINFO_disconnect (h); 95 GNUNET_PEERINFO_disconnect (h);
96 h = NULL; 96 h = NULL;
97 97
98 if (GNUNET_SCHEDULER_NO_TASK != timeout_task) 98 if (NULL != timeout_task)
99 { 99 {
100 GNUNET_SCHEDULER_cancel (timeout_task); 100 GNUNET_SCHEDULER_cancel (timeout_task);
101 timeout_task = GNUNET_SCHEDULER_NO_TASK; 101 timeout_task = NULL;
102 } 102 }
103 103
104 if ((GNUNET_YES == res_cb_w_fo) && (GNUNET_NO == res_cb_wo_fo)) 104 if ((GNUNET_YES == res_cb_w_fo) && (GNUNET_NO == res_cb_wo_fo))