aboutsummaryrefslogtreecommitdiff
path: root/src/nat/nat_test.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/nat/nat_test.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/nat/nat_test.c')
-rw-r--r--src/nat/nat_test.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c
index b96ee60ed..33fbb1070 100644
--- a/src/nat/nat_test.c
+++ b/src/nat/nat_test.c
@@ -60,7 +60,7 @@ struct NatActivity
60 /** 60 /**
61 * Task reading from the incoming connection. 61 * Task reading from the incoming connection.
62 */ 62 */
63 GNUNET_SCHEDULER_TaskIdentifier rtask; 63 struct GNUNET_SCHEDULER_Task * rtask;
64}; 64};
65 65
66 66
@@ -141,12 +141,12 @@ struct GNUNET_NAT_Test
141 /** 141 /**
142 * Identity of task for the listen socket (if any) 142 * Identity of task for the listen socket (if any)
143 */ 143 */
144 GNUNET_SCHEDULER_TaskIdentifier ltask; 144 struct GNUNET_SCHEDULER_Task * ltask;
145 145
146 /** 146 /**
147 * Task identifier for the timeout (if any) 147 * Task identifier for the timeout (if any)
148 */ 148 */
149 GNUNET_SCHEDULER_TaskIdentifier ttask; 149 struct GNUNET_SCHEDULER_Task * ttask;
150 150
151 /** 151 /**
152 * GNUNET_YES if we're testing TCP 152 * GNUNET_YES if we're testing TCP
@@ -250,7 +250,7 @@ do_read (void *cls,
250 struct GNUNET_NAT_Test *tst; 250 struct GNUNET_NAT_Test *tst;
251 uint16_t data; 251 uint16_t data;
252 252
253 na->rtask = GNUNET_SCHEDULER_NO_TASK; 253 na->rtask = NULL;
254 tst = na->h; 254 tst = na->h;
255 GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, na); 255 GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, na);
256 if ((NULL != tc->write_ready) && 256 if ((NULL != tc->write_ready) &&
@@ -287,7 +287,7 @@ do_accept (void *cls,
287 struct GNUNET_NETWORK_Handle *s; 287 struct GNUNET_NETWORK_Handle *s;
288 struct NatActivity *wl; 288 struct NatActivity *wl;
289 289
290 tst->ltask = GNUNET_SCHEDULER_NO_TASK; 290 tst->ltask = NULL;
291 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 291 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
292 return; 292 return;
293 tst->ltask = 293 tst->ltask =
@@ -386,7 +386,7 @@ do_timeout (void *cls,
386{ 386{
387 struct GNUNET_NAT_Test *nh = cls; 387 struct GNUNET_NAT_Test *nh = cls;
388 388
389 nh->ttask = GNUNET_SCHEDULER_NO_TASK; 389 nh->ttask = NULL;
390 nh->report (nh->report_cls, 390 nh->report (nh->report_cls,
391 (GNUNET_NAT_ERROR_SUCCESS == nh->status) 391 (GNUNET_NAT_ERROR_SUCCESS == nh->status)
392 ? GNUNET_NAT_ERROR_TIMEOUT 392 ? GNUNET_NAT_ERROR_TIMEOUT
@@ -495,10 +495,10 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
495 { 495 {
496 LOG (GNUNET_ERROR_TYPE_ERROR, 496 LOG (GNUNET_ERROR_TYPE_ERROR,
497 _("NAT test failed to start NAT library\n")); 497 _("NAT test failed to start NAT library\n"));
498 if (GNUNET_SCHEDULER_NO_TASK != nh->ltask) 498 if (NULL != nh->ltask)
499 { 499 {
500 GNUNET_SCHEDULER_cancel (nh->ltask); 500 GNUNET_SCHEDULER_cancel (nh->ltask);
501 nh->ltask = GNUNET_SCHEDULER_NO_TASK; 501 nh->ltask = NULL;
502 } 502 }
503 if (NULL != nh->lsock) 503 if (NULL != nh->lsock)
504 { 504 {
@@ -541,9 +541,9 @@ GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst)
541 GNUNET_NETWORK_socket_close (pos->sock); 541 GNUNET_NETWORK_socket_close (pos->sock);
542 GNUNET_free (pos); 542 GNUNET_free (pos);
543 } 543 }
544 if (GNUNET_SCHEDULER_NO_TASK != tst->ttask) 544 if (NULL != tst->ttask)
545 GNUNET_SCHEDULER_cancel (tst->ttask); 545 GNUNET_SCHEDULER_cancel (tst->ttask);
546 if (GNUNET_SCHEDULER_NO_TASK != tst->ltask) 546 if (NULL != tst->ltask)
547 GNUNET_SCHEDULER_cancel (tst->ltask); 547 GNUNET_SCHEDULER_cancel (tst->ltask);
548 if (NULL != tst->lsock) 548 if (NULL != tst->lsock)
549 GNUNET_NETWORK_socket_close (tst->lsock); 549 GNUNET_NETWORK_socket_close (tst->lsock);