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/nat/nat.c | |
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/nat/nat.c')
-rw-r--r-- | src/nat/nat.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c index 85d069e07..0225508a6 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -230,27 +230,27 @@ struct GNUNET_NAT_Handle | |||
230 | /** | 230 | /** |
231 | * ID of select gnunet-helper-nat-server stdout read task | 231 | * ID of select gnunet-helper-nat-server stdout read task |
232 | */ | 232 | */ |
233 | GNUNET_SCHEDULER_TaskIdentifier server_read_task; | 233 | struct GNUNET_SCHEDULER_Task * server_read_task; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * ID of interface IP-scan task | 236 | * ID of interface IP-scan task |
237 | */ | 237 | */ |
238 | GNUNET_SCHEDULER_TaskIdentifier ifc_task; | 238 | struct GNUNET_SCHEDULER_Task * ifc_task; |
239 | 239 | ||
240 | /** | 240 | /** |
241 | * ID of hostname DNS lookup task | 241 | * ID of hostname DNS lookup task |
242 | */ | 242 | */ |
243 | GNUNET_SCHEDULER_TaskIdentifier hostname_task; | 243 | struct GNUNET_SCHEDULER_Task * hostname_task; |
244 | 244 | ||
245 | /** | 245 | /** |
246 | * ID of DynDNS lookup task | 246 | * ID of DynDNS lookup task |
247 | */ | 247 | */ |
248 | GNUNET_SCHEDULER_TaskIdentifier dns_task; | 248 | struct GNUNET_SCHEDULER_Task * dns_task; |
249 | 249 | ||
250 | /** | 250 | /** |
251 | * ID of task to add addresses from bind. | 251 | * ID of task to add addresses from bind. |
252 | */ | 252 | */ |
253 | GNUNET_SCHEDULER_TaskIdentifier bind_task; | 253 | struct GNUNET_SCHEDULER_Task * bind_task; |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * How often do we scan for changes in our IP address from our local | 256 | * How often do we scan for changes in our IP address from our local |
@@ -758,7 +758,7 @@ process_interfaces (void *cls, const char *name, int isDefault, | |||
758 | return GNUNET_OK; | 758 | return GNUNET_OK; |
759 | } | 759 | } |
760 | if ((h->internal_address == NULL) && (h->server_proc == NULL) && | 760 | if ((h->internal_address == NULL) && (h->server_proc == NULL) && |
761 | (h->server_read_task == GNUNET_SCHEDULER_NO_TASK) && | 761 | (h->server_read_task == NULL) && |
762 | (GNUNET_YES == isDefault) && ((addr->sa_family == AF_INET) || | 762 | (GNUNET_YES == isDefault) && ((addr->sa_family == AF_INET) || |
763 | (addr->sa_family == AF_INET6))) | 763 | (addr->sa_family == AF_INET6))) |
764 | { | 764 | { |
@@ -784,7 +784,7 @@ restart_nat_server (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
784 | { | 784 | { |
785 | struct GNUNET_NAT_Handle *h = cls; | 785 | struct GNUNET_NAT_Handle *h = cls; |
786 | 786 | ||
787 | h->server_read_task = GNUNET_SCHEDULER_NO_TASK; | 787 | h->server_read_task = NULL; |
788 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 788 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
789 | return; | 789 | return; |
790 | start_gnunet_nat_server (h); | 790 | start_gnunet_nat_server (h); |
@@ -811,7 +811,7 @@ nat_server_read (void *cls, | |||
811 | const char *port_start; | 811 | const char *port_start; |
812 | struct sockaddr_in sin_addr; | 812 | struct sockaddr_in sin_addr; |
813 | 813 | ||
814 | h->server_read_task = GNUNET_SCHEDULER_NO_TASK; | 814 | h->server_read_task = NULL; |
815 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 815 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
816 | return; | 816 | return; |
817 | memset (mybuf, 0, sizeof (mybuf)); | 817 | memset (mybuf, 0, sizeof (mybuf)); |
@@ -946,7 +946,7 @@ list_interfaces (void *cls, | |||
946 | { | 946 | { |
947 | struct GNUNET_NAT_Handle *h = cls; | 947 | struct GNUNET_NAT_Handle *h = cls; |
948 | 948 | ||
949 | h->ifc_task = GNUNET_SCHEDULER_NO_TASK; | 949 | h->ifc_task = NULL; |
950 | remove_from_address_list_by_source (h, LAL_INTERFACE_ADDRESS); | 950 | remove_from_address_list_by_source (h, LAL_INTERFACE_ADDRESS); |
951 | GNUNET_OS_network_interfaces_list (&process_interfaces, h); | 951 | GNUNET_OS_network_interfaces_list (&process_interfaces, h); |
952 | h->ifc_task = | 952 | h->ifc_task = |
@@ -967,7 +967,7 @@ resolve_hostname (void *cls, | |||
967 | { | 967 | { |
968 | struct GNUNET_NAT_Handle *h = cls; | 968 | struct GNUNET_NAT_Handle *h = cls; |
969 | 969 | ||
970 | h->hostname_task = GNUNET_SCHEDULER_NO_TASK; | 970 | h->hostname_task = NULL; |
971 | remove_from_address_list_by_source (h, LAL_HOSTNAME_DNS); | 971 | remove_from_address_list_by_source (h, LAL_HOSTNAME_DNS); |
972 | h->hostname_dns = | 972 | h->hostname_dns = |
973 | GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, HOSTNAME_RESOLVE_TIMEOUT, | 973 | GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, HOSTNAME_RESOLVE_TIMEOUT, |
@@ -989,7 +989,7 @@ resolve_dns (void *cls, | |||
989 | struct GNUNET_NAT_Handle *h = cls; | 989 | struct GNUNET_NAT_Handle *h = cls; |
990 | struct LocalAddressList *pos; | 990 | struct LocalAddressList *pos; |
991 | 991 | ||
992 | h->dns_task = GNUNET_SCHEDULER_NO_TASK; | 992 | h->dns_task = NULL; |
993 | for (pos = h->lal_head; NULL != pos; pos = pos->next) | 993 | for (pos = h->lal_head; NULL != pos; pos = pos->next) |
994 | if (pos->source == LAL_EXTERNAL_IP) | 994 | if (pos->source == LAL_EXTERNAL_IP) |
995 | pos->source = LAL_EXTERNAL_IP_OLD; | 995 | pos->source = LAL_EXTERNAL_IP_OLD; |
@@ -1124,7 +1124,7 @@ add_from_bind (void *cls, | |||
1124 | struct sockaddr *sa; | 1124 | struct sockaddr *sa; |
1125 | const struct sockaddr_in *v4; | 1125 | const struct sockaddr_in *v4; |
1126 | 1126 | ||
1127 | h->bind_task = GNUNET_SCHEDULER_NO_TASK; | 1127 | h->bind_task = NULL; |
1128 | for (i = 0; i < h->num_local_addrs; i++) | 1128 | for (i = 0; i < h->num_local_addrs; i++) |
1129 | { | 1129 | { |
1130 | sa = h->local_addrs[i]; | 1130 | sa = h->local_addrs[i]; |
@@ -1384,30 +1384,30 @@ GNUNET_NAT_unregister (struct GNUNET_NAT_Handle *h) | |||
1384 | GNUNET_RESOLVER_request_cancel (h->hostname_dns); | 1384 | GNUNET_RESOLVER_request_cancel (h->hostname_dns); |
1385 | h->hostname_dns = NULL; | 1385 | h->hostname_dns = NULL; |
1386 | } | 1386 | } |
1387 | if (GNUNET_SCHEDULER_NO_TASK != h->server_read_task) | 1387 | if (NULL != h->server_read_task) |
1388 | { | 1388 | { |
1389 | GNUNET_SCHEDULER_cancel (h->server_read_task); | 1389 | GNUNET_SCHEDULER_cancel (h->server_read_task); |
1390 | h->server_read_task = GNUNET_SCHEDULER_NO_TASK; | 1390 | h->server_read_task = NULL; |
1391 | } | 1391 | } |
1392 | if (GNUNET_SCHEDULER_NO_TASK != h->bind_task) | 1392 | if (NULL != h->bind_task) |
1393 | { | 1393 | { |
1394 | GNUNET_SCHEDULER_cancel (h->bind_task); | 1394 | GNUNET_SCHEDULER_cancel (h->bind_task); |
1395 | h->bind_task = GNUNET_SCHEDULER_NO_TASK; | 1395 | h->bind_task = NULL; |
1396 | } | 1396 | } |
1397 | if (GNUNET_SCHEDULER_NO_TASK != h->ifc_task) | 1397 | if (NULL != h->ifc_task) |
1398 | { | 1398 | { |
1399 | GNUNET_SCHEDULER_cancel (h->ifc_task); | 1399 | GNUNET_SCHEDULER_cancel (h->ifc_task); |
1400 | h->ifc_task = GNUNET_SCHEDULER_NO_TASK; | 1400 | h->ifc_task = NULL; |
1401 | } | 1401 | } |
1402 | if (GNUNET_SCHEDULER_NO_TASK != h->hostname_task) | 1402 | if (NULL != h->hostname_task) |
1403 | { | 1403 | { |
1404 | GNUNET_SCHEDULER_cancel (h->hostname_task); | 1404 | GNUNET_SCHEDULER_cancel (h->hostname_task); |
1405 | h->hostname_task = GNUNET_SCHEDULER_NO_TASK; | 1405 | h->hostname_task = NULL; |
1406 | } | 1406 | } |
1407 | if (GNUNET_SCHEDULER_NO_TASK != h->dns_task) | 1407 | if (NULL != h->dns_task) |
1408 | { | 1408 | { |
1409 | GNUNET_SCHEDULER_cancel (h->dns_task); | 1409 | GNUNET_SCHEDULER_cancel (h->dns_task); |
1410 | h->dns_task = GNUNET_SCHEDULER_NO_TASK; | 1410 | h->dns_task = NULL; |
1411 | } | 1411 | } |
1412 | if (NULL != h->server_proc) | 1412 | if (NULL != h->server_proc) |
1413 | { | 1413 | { |