summaryrefslogtreecommitdiff
path: root/src/dht/dht_api.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/dht/dht_api.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/dht/dht_api.c')
-rw-r--r--src/dht/dht_api.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index be699e65e..5822702e0 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -66,7 +66,7 @@ struct PendingMessage
66 * Continuation to call when the request has been 66 * Continuation to call when the request has been
67 * transmitted (for the first time) to the service; can be NULL. 67 * transmitted (for the first time) to the service; can be NULL.
68 */ 68 */
69 GNUNET_SCHEDULER_Task cont; 69 GNUNET_SCHEDULER_TaskCallback cont;
70 70
71 /** 71 /**
72 * Closure for 'cont'. 72 * Closure for 'cont'.
@@ -155,7 +155,7 @@ struct GNUNET_DHT_PutHandle
155 /** 155 /**
156 * Timeout task for this operation. 156 * Timeout task for this operation.
157 */ 157 */
158 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 158 struct GNUNET_SCHEDULER_Task * timeout_task;
159 159
160 /** 160 /**
161 * Unique ID for the PUT operation. 161 * Unique ID for the PUT operation.
@@ -345,7 +345,7 @@ struct GNUNET_DHT_Handle
345 /** 345 /**
346 * Task for trying to reconnect. 346 * Task for trying to reconnect.
347 */ 347 */
348 GNUNET_SCHEDULER_TaskIdentifier reconnect_task; 348 struct GNUNET_SCHEDULER_Task * reconnect_task;
349 349
350 /** 350 /**
351 * How quickly should we retry? Used for exponential back-off on 351 * How quickly should we retry? Used for exponential back-off on
@@ -506,7 +506,7 @@ try_reconnect (void *cls,
506 506
507 LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting with DHT %p\n", handle); 507 LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting with DHT %p\n", handle);
508 handle->retry_time = GNUNET_TIME_STD_BACKOFF (handle->retry_time); 508 handle->retry_time = GNUNET_TIME_STD_BACKOFF (handle->retry_time);
509 handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 509 handle->reconnect_task = NULL;
510 if (GNUNET_YES != try_connect (handle)) 510 if (GNUNET_YES != try_connect (handle))
511 { 511 {
512 LOG (GNUNET_ERROR_TYPE_DEBUG, "dht reconnect failed(!)\n"); 512 LOG (GNUNET_ERROR_TYPE_DEBUG, "dht reconnect failed(!)\n");
@@ -531,7 +531,7 @@ do_disconnect (struct GNUNET_DHT_Handle *handle)
531 531
532 if (NULL == handle->client) 532 if (NULL == handle->client)
533 return; 533 return;
534 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == handle->reconnect_task); 534 GNUNET_assert (NULL == handle->reconnect_task);
535 if (NULL != handle->th) 535 if (NULL != handle->th)
536 GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th); 536 GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th);
537 handle->th = NULL; 537 handle->th = NULL;
@@ -1126,7 +1126,7 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle)
1126 GNUNET_CLIENT_disconnect (handle->client); 1126 GNUNET_CLIENT_disconnect (handle->client);
1127 handle->client = NULL; 1127 handle->client = NULL;
1128 } 1128 }
1129 if (GNUNET_SCHEDULER_NO_TASK != handle->reconnect_task) 1129 if (NULL != handle->reconnect_task)
1130 GNUNET_SCHEDULER_cancel (handle->reconnect_task); 1130 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
1131 GNUNET_CONTAINER_multihashmap_destroy (handle->active_requests); 1131 GNUNET_CONTAINER_multihashmap_destroy (handle->active_requests);
1132 GNUNET_free (handle); 1132 GNUNET_free (handle);
@@ -1146,7 +1146,7 @@ timeout_put_request (void *cls,
1146 struct GNUNET_DHT_PutHandle *ph = cls; 1146 struct GNUNET_DHT_PutHandle *ph = cls;
1147 struct GNUNET_DHT_Handle *handle = ph->dht_handle; 1147 struct GNUNET_DHT_Handle *handle = ph->dht_handle;
1148 1148
1149 ph->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1149 ph->timeout_task = NULL;
1150 if (NULL != ph->pending) 1150 if (NULL != ph->pending)
1151 { 1151 {
1152 GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, 1152 GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail,
@@ -1283,10 +1283,10 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph)
1283 GNUNET_free (ph->pending); 1283 GNUNET_free (ph->pending);
1284 ph->pending = NULL; 1284 ph->pending = NULL;
1285 } 1285 }
1286 if (ph->timeout_task != GNUNET_SCHEDULER_NO_TASK) 1286 if (ph->timeout_task != NULL)
1287 { 1287 {
1288 GNUNET_SCHEDULER_cancel (ph->timeout_task); 1288 GNUNET_SCHEDULER_cancel (ph->timeout_task);
1289 ph->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1289 ph->timeout_task = NULL;
1290 } 1290 }
1291 GNUNET_CONTAINER_DLL_remove (handle->put_head, 1291 GNUNET_CONTAINER_DLL_remove (handle->put_head,
1292 handle->put_tail, 1292 handle->put_tail,