diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-24 15:45:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-24 15:45:12 +0000 |
commit | 63b2e5ce20544b22da822848d6e3f3c495f381c3 (patch) | |
tree | 37f96e51db95aa443808449ab5e9de5fffc674a6 /src/datastore | |
parent | cf41dfe70790e400a5f89890512b7a9a3cbc820a (diff) | |
download | gnunet-63b2e5ce20544b22da822848d6e3f3c495f381c3.tar.gz gnunet-63b2e5ce20544b22da822848d6e3f3c495f381c3.zip |
fix over-allocation in datastore API
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/datastore_api.c | 167 |
1 files changed, 112 insertions, 55 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 832829e24..b2de3d35d 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2004-2013 GNUnet e.V. | 3 | Copyright (C) 2004-2013, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -57,7 +57,7 @@ struct StatusContext | |||
57 | GNUNET_DATASTORE_ContinuationWithStatus cont; | 57 | GNUNET_DATASTORE_ContinuationWithStatus cont; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Closure for cont. | 60 | * Closure for @e cont. |
61 | */ | 61 | */ |
62 | void *cont_cls; | 62 | void *cont_cls; |
63 | 63 | ||
@@ -75,7 +75,7 @@ struct ResultContext | |||
75 | GNUNET_DATASTORE_DatumProcessor proc; | 75 | GNUNET_DATASTORE_DatumProcessor proc; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Closure for proc. | 78 | * Closure for @e proc. |
79 | */ | 79 | */ |
80 | void *proc_cls; | 80 | void *proc_cls; |
81 | 81 | ||
@@ -130,7 +130,7 @@ struct GNUNET_DATASTORE_QueueEntry | |||
130 | GNUNET_DATASTORE_ContinuationWithStatus cont; | 130 | GNUNET_DATASTORE_ContinuationWithStatus cont; |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * Closure for 'cont'. | 133 | * Closure for @e cont. |
134 | */ | 134 | */ |
135 | void *cont_cls; | 135 | void *cont_cls; |
136 | 136 | ||
@@ -142,7 +142,7 @@ struct GNUNET_DATASTORE_QueueEntry | |||
142 | /** | 142 | /** |
143 | * Task for timeout signalling. | 143 | * Task for timeout signalling. |
144 | */ | 144 | */ |
145 | struct GNUNET_SCHEDULER_Task * task; | 145 | struct GNUNET_SCHEDULER_Task *task; |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * Timeout for the current operation. | 148 | * Timeout for the current operation. |
@@ -169,7 +169,7 @@ struct GNUNET_DATASTORE_QueueEntry | |||
169 | 169 | ||
170 | /** | 170 | /** |
171 | * Has this message been transmitted to the service? | 171 | * Has this message been transmitted to the service? |
172 | * Only ever GNUNET_YES for the head of the queue. | 172 | * Only ever #GNUNET_YES for the head of the queue. |
173 | * Note that the overall struct should end at a | 173 | * Note that the overall struct should end at a |
174 | * multiple of 64 bits. | 174 | * multiple of 64 bits. |
175 | */ | 175 | */ |
@@ -249,7 +249,6 @@ struct GNUNET_DATASTORE_Handle | |||
249 | }; | 249 | }; |
250 | 250 | ||
251 | 251 | ||
252 | |||
253 | /** | 252 | /** |
254 | * Connect to the datastore service. | 253 | * Connect to the datastore service. |
255 | * | 254 | * |
@@ -265,8 +264,7 @@ GNUNET_DATASTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
265 | c = GNUNET_CLIENT_connect ("datastore", cfg); | 264 | c = GNUNET_CLIENT_connect ("datastore", cfg); |
266 | if (c == NULL) | 265 | if (c == NULL) |
267 | return NULL; /* oops */ | 266 | return NULL; /* oops */ |
268 | h = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_Handle) + | 267 | h = GNUNET_new (struct GNUNET_DATASTORE_Handle); |
269 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1); | ||
270 | h->client = c; | 268 | h->client = c; |
271 | h->cfg = cfg; | 269 | h->cfg = cfg; |
272 | h->stats = GNUNET_STATISTICS_create ("datastore-api", cfg); | 270 | h->stats = GNUNET_STATISTICS_create ("datastore-api", cfg); |
@@ -284,7 +282,8 @@ disconnect_after_drop (void *cls) | |||
284 | { | 282 | { |
285 | struct GNUNET_DATASTORE_Handle *h = cls; | 283 | struct GNUNET_DATASTORE_Handle *h = cls; |
286 | 284 | ||
287 | GNUNET_DATASTORE_disconnect (h, GNUNET_NO); | 285 | GNUNET_DATASTORE_disconnect (h, |
286 | GNUNET_NO); | ||
288 | } | 287 | } |
289 | 288 | ||
290 | 289 | ||
@@ -313,7 +312,8 @@ transmit_drop (void *cls, size_t size, void *buf) | |||
313 | hdr = buf; | 312 | hdr = buf; |
314 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 313 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); |
315 | hdr->type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DROP); | 314 | hdr->type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DROP); |
316 | GNUNET_SCHEDULER_add_now (&disconnect_after_drop, h); | 315 | GNUNET_SCHEDULER_add_now (&disconnect_after_drop, |
316 | h); | ||
317 | return sizeof (struct GNUNET_MessageHeader); | 317 | return sizeof (struct GNUNET_MessageHeader); |
318 | } | 318 | } |
319 | 319 | ||
@@ -331,7 +331,8 @@ GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, | |||
331 | { | 331 | { |
332 | struct GNUNET_DATASTORE_QueueEntry *qe; | 332 | struct GNUNET_DATASTORE_QueueEntry *qe; |
333 | 333 | ||
334 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Datastore disconnect\n"); | 334 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
335 | "Datastore disconnect\n"); | ||
335 | if (NULL != h->th) | 336 | if (NULL != h->th) |
336 | { | 337 | { |
337 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); | 338 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); |
@@ -363,7 +364,8 @@ GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, | |||
363 | GNUNET_MessageHeader), | 364 | GNUNET_MessageHeader), |
364 | GNUNET_TIME_UNIT_SECONDS, | 365 | GNUNET_TIME_UNIT_SECONDS, |
365 | GNUNET_YES, | 366 | GNUNET_YES, |
366 | &transmit_drop, h)) | 367 | &transmit_drop, |
368 | h)) | ||
367 | return; | 369 | return; |
368 | GNUNET_CLIENT_disconnect (h->client); | 370 | GNUNET_CLIENT_disconnect (h->client); |
369 | h->client = NULL; | 371 | h->client = NULL; |
@@ -389,7 +391,8 @@ timeout_queue_entry (void *cls) | |||
389 | struct GNUNET_DATASTORE_Handle *h = qe->h; | 391 | struct GNUNET_DATASTORE_Handle *h = qe->h; |
390 | 392 | ||
391 | GNUNET_STATISTICS_update (h->stats, | 393 | GNUNET_STATISTICS_update (h->stats, |
392 | gettext_noop ("# queue entry timeouts"), 1, | 394 | gettext_noop ("# queue entry timeouts"), |
395 | 1, | ||
393 | GNUNET_NO); | 396 | GNUNET_NO); |
394 | qe->task = NULL; | 397 | qe->task = NULL; |
395 | GNUNET_assert (GNUNET_NO == qe->was_transmitted); | 398 | GNUNET_assert (GNUNET_NO == qe->was_transmitted); |
@@ -444,7 +447,9 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, | |||
444 | } | 447 | } |
445 | if (c >= max_queue_size) | 448 | if (c >= max_queue_size) |
446 | { | 449 | { |
447 | GNUNET_STATISTICS_update (h->stats, gettext_noop ("# queue overflows"), 1, | 450 | GNUNET_STATISTICS_update (h->stats, |
451 | gettext_noop ("# queue overflows"), | ||
452 | 1, | ||
448 | GNUNET_NO); | 453 | GNUNET_NO); |
449 | return NULL; | 454 | return NULL; |
450 | } | 455 | } |
@@ -472,12 +477,18 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, | |||
472 | } | 477 | } |
473 | c++; | 478 | c++; |
474 | #if INSANE_STATISTICS | 479 | #if INSANE_STATISTICS |
475 | GNUNET_STATISTICS_update (h->stats, gettext_noop ("# queue entries created"), | 480 | GNUNET_STATISTICS_update (h->stats, |
481 | gettext_noop ("# queue entries created"), | ||
476 | 1, GNUNET_NO); | 482 | 1, GNUNET_NO); |
477 | #endif | 483 | #endif |
478 | GNUNET_CONTAINER_DLL_insert_after (h->queue_head, h->queue_tail, pos, ret); | 484 | GNUNET_CONTAINER_DLL_insert_after (h->queue_head, |
485 | h->queue_tail, | ||
486 | pos, | ||
487 | ret); | ||
479 | h->queue_size++; | 488 | h->queue_size++; |
480 | ret->task = GNUNET_SCHEDULER_add_delayed (timeout, &timeout_queue_entry, ret); | 489 | ret->task = GNUNET_SCHEDULER_add_delayed (timeout, |
490 | &timeout_queue_entry, | ||
491 | ret); | ||
481 | for (pos = ret->next; NULL != pos; pos = pos->next) | 492 | for (pos = ret->next; NULL != pos; pos = pos->next) |
482 | { | 493 | { |
483 | if ((pos->max_queue < h->queue_size) && (pos->was_transmitted == GNUNET_NO)) | 494 | if ((pos->max_queue < h->queue_size) && (pos->was_transmitted == GNUNET_NO)) |
@@ -488,8 +499,12 @@ make_queue_entry (struct GNUNET_DATASTORE_Handle *h, | |||
488 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 499 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
489 | "Dropping request from datastore queue\n"); | 500 | "Dropping request from datastore queue\n"); |
490 | /* response_proc's expect request at the head of the queue! */ | 501 | /* response_proc's expect request at the head of the queue! */ |
491 | GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, pos); | 502 | GNUNET_CONTAINER_DLL_remove (h->queue_head, |
492 | GNUNET_CONTAINER_DLL_insert (h->queue_head, h->queue_tail, pos); | 503 | h->queue_tail, |
504 | pos); | ||
505 | GNUNET_CONTAINER_DLL_insert (h->queue_head, | ||
506 | h->queue_tail, | ||
507 | pos); | ||
493 | GNUNET_STATISTICS_update (h->stats, | 508 | GNUNET_STATISTICS_update (h->stats, |
494 | gettext_noop | 509 | gettext_noop |
495 | ("# Requests dropped from datastore queue"), 1, | 510 | ("# Requests dropped from datastore queue"), 1, |
@@ -559,7 +574,9 @@ do_disconnect (struct GNUNET_DATASTORE_Handle *h) | |||
559 | h->skip_next_messages = 0; | 574 | h->skip_next_messages = 0; |
560 | h->client = NULL; | 575 | h->client = NULL; |
561 | h->reconnect_task = | 576 | h->reconnect_task = |
562 | GNUNET_SCHEDULER_add_delayed (h->retry_time, &try_reconnect, h); | 577 | GNUNET_SCHEDULER_add_delayed (h->retry_time, |
578 | &try_reconnect, | ||
579 | h); | ||
563 | } | 580 | } |
564 | 581 | ||
565 | 582 | ||
@@ -700,10 +717,12 @@ process_queue (struct GNUNET_DATASTORE_Handle *h) | |||
700 | "Queueing %u byte request to DATASTORE\n", | 717 | "Queueing %u byte request to DATASTORE\n", |
701 | qe->message_size); | 718 | qe->message_size); |
702 | h->th | 719 | h->th |
703 | = GNUNET_CLIENT_notify_transmit_ready (h->client, qe->message_size, | 720 | = GNUNET_CLIENT_notify_transmit_ready (h->client, |
721 | qe->message_size, | ||
704 | GNUNET_TIME_absolute_get_remaining (qe->timeout), | 722 | GNUNET_TIME_absolute_get_remaining (qe->timeout), |
705 | GNUNET_YES, | 723 | GNUNET_YES, |
706 | &transmit_request, h); | 724 | &transmit_request, |
725 | h); | ||
707 | GNUNET_assert (GNUNET_NO == h->in_receive); | 726 | GNUNET_assert (GNUNET_NO == h->in_receive); |
708 | GNUNET_break (NULL != h->th); | 727 | GNUNET_break (NULL != h->th); |
709 | } | 728 | } |
@@ -738,7 +757,9 @@ free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe) | |||
738 | { | 757 | { |
739 | struct GNUNET_DATASTORE_Handle *h = qe->h; | 758 | struct GNUNET_DATASTORE_Handle *h = qe->h; |
740 | 759 | ||
741 | GNUNET_CONTAINER_DLL_remove (h->queue_head, h->queue_tail, qe); | 760 | GNUNET_CONTAINER_DLL_remove (h->queue_head, |
761 | h->queue_tail, | ||
762 | qe); | ||
742 | if (qe->task != NULL) | 763 | if (qe->task != NULL) |
743 | { | 764 | { |
744 | GNUNET_SCHEDULER_cancel (qe->task); | 765 | GNUNET_SCHEDULER_cancel (qe->task); |
@@ -883,7 +904,8 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
883 | union QueueContext qc; | 904 | union QueueContext qc; |
884 | 905 | ||
885 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 906 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
886 | "Asked to put %u bytes of data under key `%s' for %s\n", size, | 907 | "Asked to put %u bytes of data under key `%s' for %s\n", |
908 | size, | ||
887 | GNUNET_h2s (key), | 909 | GNUNET_h2s (key), |
888 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration), | 910 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (expiration), |
889 | GNUNET_YES)); | 911 | GNUNET_YES)); |
@@ -896,14 +918,18 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
896 | queue_priority, | 918 | queue_priority, |
897 | max_queue_size, | 919 | max_queue_size, |
898 | timeout, | 920 | timeout, |
899 | &process_status_message, &qc); | 921 | &process_status_message, |
922 | &qc); | ||
900 | if (qe == NULL) | 923 | if (qe == NULL) |
901 | { | 924 | { |
902 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Could not create queue entry for PUT\n"); | 925 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
926 | "Could not create queue entry for PUT\n"); | ||
903 | return NULL; | 927 | return NULL; |
904 | } | 928 | } |
905 | GNUNET_STATISTICS_update (h->stats, gettext_noop ("# PUT requests executed"), | 929 | GNUNET_STATISTICS_update (h->stats, |
906 | 1, GNUNET_NO); | 930 | gettext_noop ("# PUT requests executed"), |
931 | 1, | ||
932 | GNUNET_NO); | ||
907 | dm = (struct DataMessage *) &qe[1]; | 933 | dm = (struct DataMessage *) &qe[1]; |
908 | dm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_PUT); | 934 | dm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_PUT); |
909 | dm->header.size = htons (msize); | 935 | dm->header.size = htons (msize); |
@@ -939,7 +965,8 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, | |||
939 | * (or rather, will already have been invoked) | 965 | * (or rather, will already have been invoked) |
940 | */ | 966 | */ |
941 | struct GNUNET_DATASTORE_QueueEntry * | 967 | struct GNUNET_DATASTORE_QueueEntry * |
942 | GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, | 968 | GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, |
969 | uint64_t amount, | ||
943 | uint32_t entries, | 970 | uint32_t entries, |
944 | GNUNET_DATASTORE_ContinuationWithStatus cont, | 971 | GNUNET_DATASTORE_ContinuationWithStatus cont, |
945 | void *cont_cls) | 972 | void *cont_cls) |
@@ -952,7 +979,8 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, | |||
952 | cont = &drop_status_cont; | 979 | cont = &drop_status_cont; |
953 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 980 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
954 | "Asked to reserve %llu bytes of data and %u entries\n", | 981 | "Asked to reserve %llu bytes of data and %u entries\n", |
955 | (unsigned long long) amount, (unsigned int) entries); | 982 | (unsigned long long) amount, |
983 | (unsigned int) entries); | ||
956 | qc.sc.cont = cont; | 984 | qc.sc.cont = cont; |
957 | qc.sc.cont_cls = cont_cls; | 985 | qc.sc.cont_cls = cont_cls; |
958 | qe = make_queue_entry (h, | 986 | qe = make_queue_entry (h, |
@@ -960,7 +988,8 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, | |||
960 | UINT_MAX, | 988 | UINT_MAX, |
961 | UINT_MAX, | 989 | UINT_MAX, |
962 | GNUNET_TIME_UNIT_FOREVER_REL, | 990 | GNUNET_TIME_UNIT_FOREVER_REL, |
963 | &process_status_message, &qc); | 991 | &process_status_message, |
992 | &qc); | ||
964 | if (NULL == qe) | 993 | if (NULL == qe) |
965 | { | 994 | { |
966 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 995 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -968,7 +997,8 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, | |||
968 | return NULL; | 997 | return NULL; |
969 | } | 998 | } |
970 | GNUNET_STATISTICS_update (h->stats, | 999 | GNUNET_STATISTICS_update (h->stats, |
971 | gettext_noop ("# RESERVE requests executed"), 1, | 1000 | gettext_noop ("# RESERVE requests executed"), |
1001 | 1, | ||
972 | GNUNET_NO); | 1002 | GNUNET_NO); |
973 | rm = (struct ReserveMessage *) &qe[1]; | 1003 | rm = (struct ReserveMessage *) &qe[1]; |
974 | rm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE); | 1004 | rm->header.type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE); |
@@ -1003,7 +1033,8 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h, uint64_t amount, | |||
1003 | */ | 1033 | */ |
1004 | struct GNUNET_DATASTORE_QueueEntry * | 1034 | struct GNUNET_DATASTORE_QueueEntry * |
1005 | GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, | 1035 | GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, |
1006 | uint32_t rid, unsigned int queue_priority, | 1036 | uint32_t rid, |
1037 | unsigned int queue_priority, | ||
1007 | unsigned int max_queue_size, | 1038 | unsigned int max_queue_size, |
1008 | struct GNUNET_TIME_Relative timeout, | 1039 | struct GNUNET_TIME_Relative timeout, |
1009 | GNUNET_DATASTORE_ContinuationWithStatus cont, | 1040 | GNUNET_DATASTORE_ContinuationWithStatus cont, |
@@ -1015,12 +1046,18 @@ GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, | |||
1015 | 1046 | ||
1016 | if (cont == NULL) | 1047 | if (cont == NULL) |
1017 | cont = &drop_status_cont; | 1048 | cont = &drop_status_cont; |
1018 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to release reserve %d\n", rid); | 1049 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1050 | "Asked to release reserve %d\n", | ||
1051 | rid); | ||
1019 | qc.sc.cont = cont; | 1052 | qc.sc.cont = cont; |
1020 | qc.sc.cont_cls = cont_cls; | 1053 | qc.sc.cont_cls = cont_cls; |
1021 | qe = make_queue_entry (h, sizeof (struct ReleaseReserveMessage), | 1054 | qe = make_queue_entry (h, |
1022 | queue_priority, max_queue_size, timeout, | 1055 | sizeof (struct ReleaseReserveMessage), |
1023 | &process_status_message, &qc); | 1056 | queue_priority, |
1057 | max_queue_size, | ||
1058 | timeout, | ||
1059 | &process_status_message, | ||
1060 | &qc); | ||
1024 | if (qe == NULL) | 1061 | if (qe == NULL) |
1025 | { | 1062 | { |
1026 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1063 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1058,7 +1095,8 @@ GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, | |||
1058 | * (or rather, will already have been invoked) | 1095 | * (or rather, will already have been invoked) |
1059 | */ | 1096 | */ |
1060 | struct GNUNET_DATASTORE_QueueEntry * | 1097 | struct GNUNET_DATASTORE_QueueEntry * |
1061 | GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid, | 1098 | GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, |
1099 | uint64_t uid, | ||
1062 | uint32_t priority, | 1100 | uint32_t priority, |
1063 | struct GNUNET_TIME_Absolute expiration, | 1101 | struct GNUNET_TIME_Absolute expiration, |
1064 | unsigned int queue_priority, | 1102 | unsigned int queue_priority, |
@@ -1125,8 +1163,10 @@ GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, uint64_t uid, | |||
1125 | */ | 1163 | */ |
1126 | struct GNUNET_DATASTORE_QueueEntry * | 1164 | struct GNUNET_DATASTORE_QueueEntry * |
1127 | GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, | 1165 | GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, |
1128 | const struct GNUNET_HashCode * key, size_t size, | 1166 | const struct GNUNET_HashCode *key, |
1129 | const void *data, unsigned int queue_priority, | 1167 | size_t size, |
1168 | const void *data, | ||
1169 | unsigned int queue_priority, | ||
1130 | unsigned int max_queue_size, | 1170 | unsigned int max_queue_size, |
1131 | struct GNUNET_TIME_Relative timeout, | 1171 | struct GNUNET_TIME_Relative timeout, |
1132 | GNUNET_DATASTORE_ContinuationWithStatus cont, | 1172 | GNUNET_DATASTORE_ContinuationWithStatus cont, |
@@ -1139,17 +1179,25 @@ GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h, | |||
1139 | 1179 | ||
1140 | if (cont == NULL) | 1180 | if (cont == NULL) |
1141 | cont = &drop_status_cont; | 1181 | cont = &drop_status_cont; |
1142 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to remove %u bytes under key `%s'\n", | 1182 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1143 | size, GNUNET_h2s (key)); | 1183 | "Asked to remove %u bytes under key `%s'\n", |
1184 | size, | ||
1185 | GNUNET_h2s (key)); | ||
1144 | qc.sc.cont = cont; | 1186 | qc.sc.cont = cont; |
1145 | qc.sc.cont_cls = cont_cls; | 1187 | qc.sc.cont_cls = cont_cls; |
1146 | msize = sizeof (struct DataMessage) + size; | 1188 | msize = sizeof (struct DataMessage) + size; |
1147 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1189 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
1148 | qe = make_queue_entry (h, msize, queue_priority, max_queue_size, timeout, | 1190 | qe = make_queue_entry (h, |
1149 | &process_status_message, &qc); | 1191 | msize, |
1192 | queue_priority, | ||
1193 | max_queue_size, | ||
1194 | timeout, | ||
1195 | &process_status_message, | ||
1196 | &qc); | ||
1150 | if (qe == NULL) | 1197 | if (qe == NULL) |
1151 | { | 1198 | { |
1152 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Could not create queue entry for REMOVE\n"); | 1199 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1200 | "Could not create queue entry for REMOVE\n"); | ||
1153 | return NULL; | 1201 | return NULL; |
1154 | } | 1202 | } |
1155 | GNUNET_STATISTICS_update (h->stats, | 1203 | GNUNET_STATISTICS_update (h->stats, |
@@ -1372,13 +1420,19 @@ GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, | |||
1372 | GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY); | 1420 | GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY); |
1373 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1421 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1374 | "Asked to get %llu-th zero-anonymity entry of type %d in %s\n", | 1422 | "Asked to get %llu-th zero-anonymity entry of type %d in %s\n", |
1375 | (unsigned long long) offset, type, | 1423 | (unsigned long long) offset, |
1376 | GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES)); | 1424 | type, |
1425 | GNUNET_STRINGS_relative_time_to_string (timeout, | ||
1426 | GNUNET_YES)); | ||
1377 | qc.rc.proc = proc; | 1427 | qc.rc.proc = proc; |
1378 | qc.rc.proc_cls = proc_cls; | 1428 | qc.rc.proc_cls = proc_cls; |
1379 | qe = make_queue_entry (h, sizeof (struct GetZeroAnonymityMessage), | 1429 | qe = make_queue_entry (h, |
1380 | queue_priority, max_queue_size, timeout, | 1430 | sizeof (struct GetZeroAnonymityMessage), |
1381 | &process_result_message, &qc); | 1431 | queue_priority, |
1432 | max_queue_size, | ||
1433 | timeout, | ||
1434 | &process_result_message, | ||
1435 | &qc); | ||
1382 | if (NULL == qe) | 1436 | if (NULL == qe) |
1383 | { | 1437 | { |
1384 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1438 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1423,7 +1477,7 @@ GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h, | |||
1423 | struct GNUNET_DATASTORE_QueueEntry * | 1477 | struct GNUNET_DATASTORE_QueueEntry * |
1424 | GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, | 1478 | GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, |
1425 | uint64_t offset, | 1479 | uint64_t offset, |
1426 | const struct GNUNET_HashCode * key, | 1480 | const struct GNUNET_HashCode *key, |
1427 | enum GNUNET_BLOCK_Type type, | 1481 | enum GNUNET_BLOCK_Type type, |
1428 | unsigned int queue_priority, | 1482 | unsigned int queue_priority, |
1429 | unsigned int max_queue_size, | 1483 | unsigned int max_queue_size, |
@@ -1450,7 +1504,8 @@ GNUNET_DATASTORE_get_key (struct GNUNET_DATASTORE_Handle *h, | |||
1450 | &qc); | 1504 | &qc); |
1451 | if (qe == NULL) | 1505 | if (qe == NULL) |
1452 | { | 1506 | { |
1453 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Could not queue request for `%s'\n", | 1507 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1508 | "Could not queue request for `%s'\n", | ||
1454 | GNUNET_h2s (key)); | 1509 | GNUNET_h2s (key)); |
1455 | return NULL; | 1510 | return NULL; |
1456 | } | 1511 | } |
@@ -1493,8 +1548,10 @@ GNUNET_DATASTORE_cancel (struct GNUNET_DATASTORE_QueueEntry *qe) | |||
1493 | GNUNET_assert (GNUNET_SYSERR != qe->was_transmitted); | 1548 | GNUNET_assert (GNUNET_SYSERR != qe->was_transmitted); |
1494 | h = qe->h; | 1549 | h = qe->h; |
1495 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1550 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1496 | "Pending DATASTORE request %p cancelled (%d, %d)\n", qe, | 1551 | "Pending DATASTORE request %p cancelled (%d, %d)\n", |
1497 | qe->was_transmitted, h->queue_head == qe); | 1552 | qe, |
1553 | qe->was_transmitted, | ||
1554 | h->queue_head == qe); | ||
1498 | if (GNUNET_YES == qe->was_transmitted) | 1555 | if (GNUNET_YES == qe->was_transmitted) |
1499 | { | 1556 | { |
1500 | free_queue_entry (qe); | 1557 | free_queue_entry (qe); |