aboutsummaryrefslogtreecommitdiff
path: root/src/dns
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/dns
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/dns')
-rw-r--r--src/dns/dns_api.c8
-rw-r--r--src/dns/dnsstub.c12
2 files changed, 10 insertions, 10 deletions
diff --git a/src/dns/dns_api.c b/src/dns/dns_api.c
index 288b421c6..916a860f1 100644
--- a/src/dns/dns_api.c
+++ b/src/dns/dns_api.c
@@ -119,7 +119,7 @@ struct GNUNET_DNS_Handle
119 /** 119 /**
120 * Task to reconnect to the service. 120 * Task to reconnect to the service.
121 */ 121 */
122 GNUNET_SCHEDULER_TaskIdentifier reconnect_task; 122 struct GNUNET_SCHEDULER_Task * reconnect_task;
123 123
124 /** 124 /**
125 * Re-connect counter, to make sure we did not reconnect in the meantime. 125 * Re-connect counter, to make sure we did not reconnect in the meantime.
@@ -169,7 +169,7 @@ reconnect (void *cls,
169 struct ReplyQueueEntry *qe; 169 struct ReplyQueueEntry *qe;
170 struct GNUNET_DNS_Register *msg; 170 struct GNUNET_DNS_Register *msg;
171 171
172 dh->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 172 dh->reconnect_task = NULL;
173 dh->dns_connection = GNUNET_CLIENT_connect ("dns", dh->cfg); 173 dh->dns_connection = GNUNET_CLIENT_connect ("dns", dh->cfg);
174 if (NULL == dh->dns_connection) 174 if (NULL == dh->dns_connection)
175 return; 175 return;
@@ -508,10 +508,10 @@ GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
508void 508void
509GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *dh) 509GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *dh)
510{ 510{
511 if (GNUNET_SCHEDULER_NO_TASK != dh->reconnect_task) 511 if (NULL != dh->reconnect_task)
512 { 512 {
513 GNUNET_SCHEDULER_cancel (dh->reconnect_task); 513 GNUNET_SCHEDULER_cancel (dh->reconnect_task);
514 dh->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 514 dh->reconnect_task = NULL;
515 } 515 }
516 disconnect (dh); 516 disconnect (dh);
517 /* make sure client has no pending requests left over! */ 517 /* make sure client has no pending requests left over! */
diff --git a/src/dns/dnsstub.c b/src/dns/dnsstub.c
index 2e57a8877..6e4f7c799 100644
--- a/src/dns/dnsstub.c
+++ b/src/dns/dnsstub.c
@@ -67,7 +67,7 @@ struct GNUNET_DNSSTUB_RequestSocket
67 /** 67 /**
68 * Task for reading from dnsout4 and dnsout6. 68 * Task for reading from dnsout4 and dnsout6.
69 */ 69 */
70 GNUNET_SCHEDULER_TaskIdentifier read_task; 70 struct GNUNET_SCHEDULER_Task * read_task;
71 71
72 /** 72 /**
73 * When should this request time out? 73 * When should this request time out?
@@ -125,10 +125,10 @@ cleanup_rs (struct GNUNET_DNSSTUB_RequestSocket *rs)
125 GNUNET_NETWORK_socket_close (rs->dnsout6); 125 GNUNET_NETWORK_socket_close (rs->dnsout6);
126 rs->dnsout6 = NULL; 126 rs->dnsout6 = NULL;
127 } 127 }
128 if (GNUNET_SCHEDULER_NO_TASK != rs->read_task) 128 if (NULL != rs->read_task)
129 { 129 {
130 GNUNET_SCHEDULER_cancel (rs->read_task); 130 GNUNET_SCHEDULER_cancel (rs->read_task);
131 rs->read_task = GNUNET_SCHEDULER_NO_TASK; 131 rs->read_task = NULL;
132 } 132 }
133} 133}
134 134
@@ -223,10 +223,10 @@ get_request_socket (struct GNUNET_DNSSTUB_Context *ctx,
223 default: 223 default:
224 return NULL; 224 return NULL;
225 } 225 }
226 if (GNUNET_SCHEDULER_NO_TASK != rs->read_task) 226 if (NULL != rs->read_task)
227 { 227 {
228 GNUNET_SCHEDULER_cancel (rs->read_task); 228 GNUNET_SCHEDULER_cancel (rs->read_task);
229 rs->read_task = GNUNET_SCHEDULER_NO_TASK; 229 rs->read_task = NULL;
230 } 230 }
231 if ( (NULL == rs->dnsout4) && 231 if ( (NULL == rs->dnsout4) &&
232 (NULL == rs->dnsout6) ) 232 (NULL == rs->dnsout6) )
@@ -475,7 +475,7 @@ read_response (void *cls,
475 struct GNUNET_DNSSTUB_RequestSocket *rs = cls; 475 struct GNUNET_DNSSTUB_RequestSocket *rs = cls;
476 struct GNUNET_NETWORK_FDSet *rset; 476 struct GNUNET_NETWORK_FDSet *rset;
477 477
478 rs->read_task = GNUNET_SCHEDULER_NO_TASK; 478 rs->read_task = NULL;
479 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) 479 if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY))
480 { 480 {
481 /* timeout or shutdown */ 481 /* timeout or shutdown */