diff options
Diffstat (limited to 'src/dht/dht_api.c')
-rw-r--r-- | src/dht/dht_api.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 3a6fcdc53..7b83c14c3 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -115,7 +115,7 @@ struct GNUNET_DHT_PutHandle | |||
115 | GNUNET_DHT_PutContinuation cont; | 115 | GNUNET_DHT_PutContinuation cont; |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * Pending message associated with this PUT operation, | 118 | * Pending message associated with this PUT operation, |
119 | * NULL after the message has been transmitted to the service. | 119 | * NULL after the message has been transmitted to the service. |
120 | */ | 120 | */ |
121 | struct PendingMessage *pending; | 121 | struct PendingMessage *pending; |
@@ -181,7 +181,7 @@ struct GNUNET_DHT_GetHandle | |||
181 | /** | 181 | /** |
182 | * Key that this get request is for | 182 | * Key that this get request is for |
183 | */ | 183 | */ |
184 | struct GNUNET_HashCode key; | 184 | struct GNUNET_HashCode key; |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * Unique identifier for this request (for key collisions). | 187 | * Unique identifier for this request (for key collisions). |
@@ -201,7 +201,7 @@ struct GNUNET_DHT_GetHandle | |||
201 | unsigned int seen_results_end; | 201 | unsigned int seen_results_end; |
202 | 202 | ||
203 | /** | 203 | /** |
204 | * Offset into the 'seen_results' array marking the | 204 | * Offset into the 'seen_results' array marking the |
205 | * position up to where we've send the hash codes to | 205 | * position up to where we've send the hash codes to |
206 | * the DHT for blocking (needed as we might not be | 206 | * the DHT for blocking (needed as we might not be |
207 | * able to send all hash codes at once). | 207 | * able to send all hash codes at once). |
@@ -226,7 +226,7 @@ struct GNUNET_DHT_MonitorHandle | |||
226 | * DLL. | 226 | * DLL. |
227 | */ | 227 | */ |
228 | struct GNUNET_DHT_MonitorHandle *prev; | 228 | struct GNUNET_DHT_MonitorHandle *prev; |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * Main handle to this DHT api. | 231 | * Main handle to this DHT api. |
232 | */ | 232 | */ |
@@ -261,7 +261,7 @@ struct GNUNET_DHT_MonitorHandle | |||
261 | * Closure for cb. | 261 | * Closure for cb. |
262 | */ | 262 | */ |
263 | void *cb_cls; | 263 | void *cb_cls; |
264 | 264 | ||
265 | }; | 265 | }; |
266 | 266 | ||
267 | 267 | ||
@@ -297,7 +297,7 @@ struct GNUNET_DHT_Handle | |||
297 | struct PendingMessage *pending_tail; | 297 | struct PendingMessage *pending_tail; |
298 | 298 | ||
299 | /** | 299 | /** |
300 | * Head of linked list of messages we would like to monitor. | 300 | * Head of linked list of messages we would like to monitor. |
301 | */ | 301 | */ |
302 | struct GNUNET_DHT_MonitorHandle *monitor_head; | 302 | struct GNUNET_DHT_MonitorHandle *monitor_head; |
303 | 303 | ||
@@ -353,7 +353,7 @@ struct GNUNET_DHT_Handle | |||
353 | * @param msg the incoming message | 353 | * @param msg the incoming message |
354 | */ | 354 | */ |
355 | static void | 355 | static void |
356 | service_message_handler (void *cls, | 356 | service_message_handler (void *cls, |
357 | const struct GNUNET_MessageHeader *msg); | 357 | const struct GNUNET_MessageHeader *msg); |
358 | 358 | ||
359 | 359 | ||
@@ -401,7 +401,7 @@ queue_filter_messages (struct GNUNET_DHT_GetHandle *get_handle) | |||
401 | if (delta > max) | 401 | if (delta > max) |
402 | delta = max; | 402 | delta = max; |
403 | msize = sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage) + delta * sizeof (struct GNUNET_HashCode); | 403 | msize = sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage) + delta * sizeof (struct GNUNET_HashCode); |
404 | 404 | ||
405 | pm = GNUNET_malloc (sizeof (struct PendingMessage) + msize); | 405 | pm = GNUNET_malloc (sizeof (struct PendingMessage) + msize); |
406 | msg = (struct GNUNET_DHT_ClientGetResultSeenMessage *) &pm[1]; | 406 | msg = (struct GNUNET_DHT_ClientGetResultSeenMessage *) &pm[1]; |
407 | pm->msg = &msg->header; | 407 | pm->msg = &msg->header; |
@@ -419,7 +419,7 @@ queue_filter_messages (struct GNUNET_DHT_GetHandle *get_handle) | |||
419 | get_handle->seen_results_transmission_offset += delta; | 419 | get_handle->seen_results_transmission_offset += delta; |
420 | GNUNET_CONTAINER_DLL_insert_tail (get_handle->dht_handle->pending_head, | 420 | GNUNET_CONTAINER_DLL_insert_tail (get_handle->dht_handle->pending_head, |
421 | get_handle->dht_handle->pending_tail, | 421 | get_handle->dht_handle->pending_tail, |
422 | pm); | 422 | pm); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
@@ -434,8 +434,8 @@ queue_filter_messages (struct GNUNET_DHT_GetHandle *get_handle) | |||
434 | * @return #GNUNET_YES (always) | 434 | * @return #GNUNET_YES (always) |
435 | */ | 435 | */ |
436 | static int | 436 | static int |
437 | add_request_to_pending (void *cls, | 437 | add_request_to_pending (void *cls, |
438 | const struct GNUNET_HashCode *key, | 438 | const struct GNUNET_HashCode *key, |
439 | void *value) | 439 | void *value) |
440 | { | 440 | { |
441 | struct GNUNET_DHT_Handle *handle = cls; | 441 | struct GNUNET_DHT_Handle *handle = cls; |
@@ -472,7 +472,7 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle); | |||
472 | * @param tc scheduler context | 472 | * @param tc scheduler context |
473 | */ | 473 | */ |
474 | static void | 474 | static void |
475 | try_reconnect (void *cls, | 475 | try_reconnect (void *cls, |
476 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 476 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
477 | { | 477 | { |
478 | struct GNUNET_DHT_Handle *handle = cls; | 478 | struct GNUNET_DHT_Handle *handle = cls; |
@@ -542,8 +542,8 @@ do_disconnect (struct GNUNET_DHT_Handle *handle) | |||
542 | * @return number of bytes written to @a buf | 542 | * @return number of bytes written to @a buf |
543 | */ | 543 | */ |
544 | static size_t | 544 | static size_t |
545 | transmit_pending (void *cls, | 545 | transmit_pending (void *cls, |
546 | size_t size, | 546 | size_t size, |
547 | void *buf); | 547 | void *buf); |
548 | 548 | ||
549 | 549 | ||
@@ -591,8 +591,8 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle) | |||
591 | * @return number of bytes written to @a buf | 591 | * @return number of bytes written to @a buf |
592 | */ | 592 | */ |
593 | static size_t | 593 | static size_t |
594 | transmit_pending (void *cls, | 594 | transmit_pending (void *cls, |
595 | size_t size, | 595 | size_t size, |
596 | void *buf) | 596 | void *buf) |
597 | { | 597 | { |
598 | struct GNUNET_DHT_Handle *handle = cls; | 598 | struct GNUNET_DHT_Handle *handle = cls; |
@@ -601,7 +601,7 @@ transmit_pending (void *cls, | |||
601 | 601 | ||
602 | handle->th = NULL; | 602 | handle->th = NULL; |
603 | if (NULL == buf) | 603 | if (NULL == buf) |
604 | { | 604 | { |
605 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 605 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
606 | "Transmission to DHT service failed! Reconnecting!\n"); | 606 | "Transmission to DHT service failed! Reconnecting!\n"); |
607 | do_disconnect (handle); | 607 | do_disconnect (handle); |
@@ -653,8 +653,8 @@ transmit_pending (void *cls, | |||
653 | * #GNUNET_NO if the reply is malformed or we found a matching request | 653 | * #GNUNET_NO if the reply is malformed or we found a matching request |
654 | */ | 654 | */ |
655 | static int | 655 | static int |
656 | process_reply (void *cls, | 656 | process_reply (void *cls, |
657 | const struct GNUNET_HashCode *key, | 657 | const struct GNUNET_HashCode *key, |
658 | void *value) | 658 | void *value) |
659 | { | 659 | { |
660 | const struct GNUNET_DHT_ClientResultMessage *dht_msg = cls; | 660 | const struct GNUNET_DHT_ClientResultMessage *dht_msg = cls; |
@@ -700,14 +700,14 @@ process_reply (void *cls, | |||
700 | data = &get_path[get_path_length]; | 700 | data = &get_path[get_path_length]; |
701 | /* remember that we've seen this result */ | 701 | /* remember that we've seen this result */ |
702 | GNUNET_CRYPTO_hash (data, data_length, &hc); | 702 | GNUNET_CRYPTO_hash (data, data_length, &hc); |
703 | if (get_handle->seen_results_size == get_handle->seen_results_end) | 703 | if (get_handle->seen_results_size == get_handle->seen_results_end) |
704 | GNUNET_array_grow (get_handle->seen_results, | 704 | GNUNET_array_grow (get_handle->seen_results, |
705 | get_handle->seen_results_size, | 705 | get_handle->seen_results_size, |
706 | get_handle->seen_results_size * 2 + 1); | 706 | get_handle->seen_results_size * 2 + 1); |
707 | GNUNET_assert (get_handle->seen_results_end == get_handle->seen_results_transmission_offset); | 707 | GNUNET_assert (get_handle->seen_results_end == get_handle->seen_results_transmission_offset); |
708 | get_handle->seen_results[get_handle->seen_results_end++] = hc; | 708 | get_handle->seen_results[get_handle->seen_results_end++] = hc; |
709 | /* no need to block it explicitly, service already knows about it! */ | 709 | /* no need to block it explicitly, service already knows about it! */ |
710 | get_handle->seen_results_transmission_offset++; | 710 | get_handle->seen_results_transmission_offset++; |
711 | get_handle->iter (get_handle->iter_cls, | 711 | get_handle->iter (get_handle->iter_cls, |
712 | GNUNET_TIME_absolute_ntoh (dht_msg->expiration), key, | 712 | GNUNET_TIME_absolute_ntoh (dht_msg->expiration), key, |
713 | get_path, get_path_length, put_path, put_path_length, | 713 | get_path, get_path_length, put_path, put_path_length, |
@@ -746,7 +746,7 @@ process_monitor_get_message (struct GNUNET_DHT_Handle *handle, | |||
746 | ntohl (msg->desired_replication_level), | 746 | ntohl (msg->desired_replication_level), |
747 | ntohl (msg->get_path_length), | 747 | ntohl (msg->get_path_length), |
748 | (struct GNUNET_PeerIdentity *) &msg[1], | 748 | (struct GNUNET_PeerIdentity *) &msg[1], |
749 | &msg->key); | 749 | &msg->key); |
750 | } | 750 | } |
751 | return GNUNET_OK; | 751 | return GNUNET_OK; |
752 | } | 752 | } |
@@ -879,7 +879,7 @@ process_put_confirmation_message (struct GNUNET_DHT_Handle *handle, | |||
879 | cont = ph->cont; | 879 | cont = ph->cont; |
880 | cont_cls = ph->cont_cls; | 880 | cont_cls = ph->cont_cls; |
881 | GNUNET_DHT_put_cancel (ph); | 881 | GNUNET_DHT_put_cancel (ph); |
882 | if (NULL != cont) | 882 | if (NULL != cont) |
883 | cont (cont_cls, GNUNET_OK); | 883 | cont (cont_cls, GNUNET_OK); |
884 | return GNUNET_OK; | 884 | return GNUNET_OK; |
885 | } | 885 | } |
@@ -1132,11 +1132,11 @@ mark_put_message_gone (void *cls, | |||
1132 | * @param cont_cls closure for @a cont | 1132 | * @param cont_cls closure for @a cont |
1133 | */ | 1133 | */ |
1134 | struct GNUNET_DHT_PutHandle * | 1134 | struct GNUNET_DHT_PutHandle * |
1135 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | 1135 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, |
1136 | const struct GNUNET_HashCode * key, | 1136 | const struct GNUNET_HashCode * key, |
1137 | uint32_t desired_replication_level, | 1137 | uint32_t desired_replication_level, |
1138 | enum GNUNET_DHT_RouteOption options, | 1138 | enum GNUNET_DHT_RouteOption options, |
1139 | enum GNUNET_BLOCK_Type type, size_t size, | 1139 | enum GNUNET_BLOCK_Type type, size_t size, |
1140 | const void *data, | 1140 | const void *data, |
1141 | struct GNUNET_TIME_Absolute exp, | 1141 | struct GNUNET_TIME_Absolute exp, |
1142 | struct GNUNET_TIME_Relative timeout, | 1142 | struct GNUNET_TIME_Relative timeout, |
@@ -1194,7 +1194,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
1194 | * go out over the network (we can't stop that); However, if the PUT | 1194 | * go out over the network (we can't stop that); However, if the PUT |
1195 | * has not yet been sent to the service, cancelling the PUT will stop | 1195 | * has not yet been sent to the service, cancelling the PUT will stop |
1196 | * this from happening (but there is no way for the user of this API | 1196 | * this from happening (but there is no way for the user of this API |
1197 | * to tell if that is the case). The only use for this API is to | 1197 | * to tell if that is the case). The only use for this API is to |
1198 | * prevent a later call to 'cont' from #GNUNET_DHT_put (i.e. because | 1198 | * prevent a later call to 'cont' from #GNUNET_DHT_put (i.e. because |
1199 | * the system is shutting down). | 1199 | * the system is shutting down). |
1200 | * | 1200 | * |
@@ -1310,7 +1310,7 @@ GNUNET_DHT_get_filter_known_results (struct GNUNET_DHT_GetHandle *get_handle, | |||
1310 | unsigned int needed; | 1310 | unsigned int needed; |
1311 | 1311 | ||
1312 | needed = get_handle->seen_results_end + num_results; | 1312 | needed = get_handle->seen_results_end + num_results; |
1313 | if (needed > get_handle->seen_results_size) | 1313 | if (needed > get_handle->seen_results_size) |
1314 | GNUNET_array_grow (get_handle->seen_results, | 1314 | GNUNET_array_grow (get_handle->seen_results, |
1315 | get_handle->seen_results_size, | 1315 | get_handle->seen_results_size, |
1316 | needed); | 1316 | needed); |
@@ -1483,7 +1483,7 @@ GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle) | |||
1483 | pending); | 1483 | pending); |
1484 | pending->in_pending_queue = GNUNET_YES; | 1484 | pending->in_pending_queue = GNUNET_YES; |
1485 | process_pending_messages (handle->dht_handle); | 1485 | process_pending_messages (handle->dht_handle); |
1486 | 1486 | ||
1487 | GNUNET_free_non_null (handle->key); | 1487 | GNUNET_free_non_null (handle->key); |
1488 | GNUNET_free (handle); | 1488 | GNUNET_free (handle); |
1489 | } | 1489 | } |