diff options
Diffstat (limited to 'src/datastore/gnunet-service-datastore.c')
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 1510 |
1 files changed, 756 insertions, 754 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 41abf77ca..bd86fdad1 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -39,21 +39,21 @@ | |||
39 | /** | 39 | /** |
40 | * Limit size of bloom filter to 2 GB. | 40 | * Limit size of bloom filter to 2 GB. |
41 | */ | 41 | */ |
42 | #define MAX_BF_SIZE ((uint32_t)(1LL << 31)) | 42 | #define MAX_BF_SIZE ((uint32_t) (1LL << 31)) |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * How long are we at most keeping "expired" content | 45 | * How long are we at most keeping "expired" content |
46 | * past the expiration date in the database? | 46 | * past the expiration date in the database? |
47 | */ | 47 | */ |
48 | #define MAX_EXPIRE_DELAY \ | 48 | #define MAX_EXPIRE_DELAY \ |
49 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 15) | 49 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * How fast are we allowed to query the database for deleting | 52 | * How fast are we allowed to query the database for deleting |
53 | * expired content? (1 item per second). | 53 | * expired content? (1 item per second). |
54 | */ | 54 | */ |
55 | #define MIN_EXPIRE_DELAY \ | 55 | #define MIN_EXPIRE_DELAY \ |
56 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) | 56 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Name under which we store current space consumption. | 59 | * Name under which we store current space consumption. |
@@ -75,7 +75,8 @@ static struct GNUNET_SCHEDULER_Task *stat_timeout_task; | |||
75 | /** | 75 | /** |
76 | * Our datastore plugin. | 76 | * Our datastore plugin. |
77 | */ | 77 | */ |
78 | struct DatastorePlugin { | 78 | struct DatastorePlugin |
79 | { | ||
79 | /** | 80 | /** |
80 | * API of the transport as returned by the plugin's | 81 | * API of the transport as returned by the plugin's |
81 | * initialization function. | 82 | * initialization function. |
@@ -103,7 +104,8 @@ struct DatastorePlugin { | |||
103 | /** | 104 | /** |
104 | * Linked list of active reservations. | 105 | * Linked list of active reservations. |
105 | */ | 106 | */ |
106 | struct ReservationList { | 107 | struct ReservationList |
108 | { | ||
107 | /** | 109 | /** |
108 | * This is a linked list. | 110 | * This is a linked list. |
109 | */ | 111 | */ |
@@ -227,13 +229,13 @@ static int stats_worked; | |||
227 | * statistics service. | 229 | * statistics service. |
228 | */ | 230 | */ |
229 | static void | 231 | static void |
230 | sync_stats() | 232 | sync_stats () |
231 | { | 233 | { |
232 | GNUNET_STATISTICS_set(stats, quota_stat_name, payload, GNUNET_YES); | 234 | GNUNET_STATISTICS_set (stats, quota_stat_name, payload, GNUNET_YES); |
233 | GNUNET_STATISTICS_set(stats, | 235 | GNUNET_STATISTICS_set (stats, |
234 | "# utilization by current datastore", | 236 | "# utilization by current datastore", |
235 | payload, | 237 | payload, |
236 | GNUNET_NO); | 238 | GNUNET_NO); |
237 | last_sync = 0; | 239 | last_sync = 0; |
238 | } | 240 | } |
239 | 241 | ||
@@ -263,7 +265,7 @@ static struct GNUNET_SERVICE_Handle *service; | |||
263 | * @param cls not used | 265 | * @param cls not used |
264 | */ | 266 | */ |
265 | static void | 267 | static void |
266 | delete_expired(void *cls); | 268 | delete_expired (void *cls); |
267 | 269 | ||
268 | 270 | ||
269 | /** | 271 | /** |
@@ -288,57 +290,57 @@ delete_expired(void *cls); | |||
288 | * #GNUNET_NO to delete the item and continue (if supported) | 290 | * #GNUNET_NO to delete the item and continue (if supported) |
289 | */ | 291 | */ |
290 | static int | 292 | static int |
291 | expired_processor(void *cls, | 293 | expired_processor (void *cls, |
292 | const struct GNUNET_HashCode *key, | 294 | const struct GNUNET_HashCode *key, |
293 | uint32_t size, | 295 | uint32_t size, |
294 | const void *data, | 296 | const void *data, |
295 | enum GNUNET_BLOCK_Type type, | 297 | enum GNUNET_BLOCK_Type type, |
296 | uint32_t priority, | 298 | uint32_t priority, |
297 | uint32_t anonymity, | 299 | uint32_t anonymity, |
298 | uint32_t replication, | 300 | uint32_t replication, |
299 | struct GNUNET_TIME_Absolute expiration, | 301 | struct GNUNET_TIME_Absolute expiration, |
300 | uint64_t uid) | 302 | uint64_t uid) |
301 | { | 303 | { |
302 | struct GNUNET_TIME_Absolute now; | 304 | struct GNUNET_TIME_Absolute now; |
303 | 305 | ||
304 | if (NULL == key) | 306 | if (NULL == key) |
305 | { | 307 | { |
306 | expired_kill_task = | 308 | expired_kill_task = |
307 | GNUNET_SCHEDULER_add_delayed_with_priority(MAX_EXPIRE_DELAY, | 309 | GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY, |
308 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 310 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
309 | &delete_expired, | 311 | &delete_expired, |
310 | NULL); | 312 | NULL); |
311 | return GNUNET_SYSERR; | 313 | return GNUNET_SYSERR; |
312 | } | 314 | } |
313 | now = GNUNET_TIME_absolute_get(); | 315 | now = GNUNET_TIME_absolute_get (); |
314 | if (expiration.abs_value_us > now.abs_value_us) | 316 | if (expiration.abs_value_us > now.abs_value_us) |
315 | { | 317 | { |
316 | /* finished processing */ | 318 | /* finished processing */ |
317 | expired_kill_task = | 319 | expired_kill_task = |
318 | GNUNET_SCHEDULER_add_delayed_with_priority(MAX_EXPIRE_DELAY, | 320 | GNUNET_SCHEDULER_add_delayed_with_priority (MAX_EXPIRE_DELAY, |
319 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 321 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
320 | &delete_expired, | 322 | &delete_expired, |
321 | NULL); | 323 | NULL); |
322 | return GNUNET_SYSERR; | 324 | return GNUNET_SYSERR; |
323 | } | 325 | } |
324 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
325 | "Deleting content `%s' of type %u that expired %s ago\n", | 327 | "Deleting content `%s' of type %u that expired %s ago\n", |
326 | GNUNET_h2s(key), | 328 | GNUNET_h2s (key), |
327 | type, | 329 | type, |
328 | GNUNET_STRINGS_relative_time_to_string( | 330 | GNUNET_STRINGS_relative_time_to_string ( |
329 | GNUNET_TIME_absolute_get_difference(expiration, now), | 331 | GNUNET_TIME_absolute_get_difference (expiration, now), |
330 | GNUNET_YES)); | 332 | GNUNET_YES)); |
331 | min_expiration = now; | 333 | min_expiration = now; |
332 | GNUNET_STATISTICS_update(stats, | 334 | GNUNET_STATISTICS_update (stats, |
333 | gettext_noop("# bytes expired"), | 335 | gettext_noop ("# bytes expired"), |
334 | size, | 336 | size, |
335 | GNUNET_YES); | 337 | GNUNET_YES); |
336 | GNUNET_CONTAINER_bloomfilter_remove(filter, key); | 338 | GNUNET_CONTAINER_bloomfilter_remove (filter, key); |
337 | expired_kill_task = | 339 | expired_kill_task = |
338 | GNUNET_SCHEDULER_add_delayed_with_priority(MIN_EXPIRE_DELAY, | 340 | GNUNET_SCHEDULER_add_delayed_with_priority (MIN_EXPIRE_DELAY, |
339 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 341 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
340 | &delete_expired, | 342 | &delete_expired, |
341 | NULL); | 343 | NULL); |
342 | return GNUNET_NO; | 344 | return GNUNET_NO; |
343 | } | 345 | } |
344 | 346 | ||
@@ -352,10 +354,10 @@ expired_processor(void *cls, | |||
352 | * @param cls not used | 354 | * @param cls not used |
353 | */ | 355 | */ |
354 | static void | 356 | static void |
355 | delete_expired(void *cls) | 357 | delete_expired (void *cls) |
356 | { | 358 | { |
357 | expired_kill_task = NULL; | 359 | expired_kill_task = NULL; |
358 | plugin->api->get_expiration(plugin->api->cls, &expired_processor, NULL); | 360 | plugin->api->get_expiration (plugin->api->cls, &expired_processor, NULL); |
359 | } | 361 | } |
360 | 362 | ||
361 | 363 | ||
@@ -379,31 +381,31 @@ delete_expired(void *cls) | |||
379 | * #GNUNET_NO to delete the item and continue (if supported) | 381 | * #GNUNET_NO to delete the item and continue (if supported) |
380 | */ | 382 | */ |
381 | static int | 383 | static int |
382 | quota_processor(void *cls, | 384 | quota_processor (void *cls, |
383 | const struct GNUNET_HashCode *key, | 385 | const struct GNUNET_HashCode *key, |
384 | uint32_t size, | 386 | uint32_t size, |
385 | const void *data, | 387 | const void *data, |
386 | enum GNUNET_BLOCK_Type type, | 388 | enum GNUNET_BLOCK_Type type, |
387 | uint32_t priority, | 389 | uint32_t priority, |
388 | uint32_t anonymity, | 390 | uint32_t anonymity, |
389 | uint32_t replication, | 391 | uint32_t replication, |
390 | struct GNUNET_TIME_Absolute expiration, | 392 | struct GNUNET_TIME_Absolute expiration, |
391 | uint64_t uid) | 393 | uint64_t uid) |
392 | { | 394 | { |
393 | unsigned long long *need = cls; | 395 | unsigned long long *need = cls; |
394 | 396 | ||
395 | if (NULL == key) | 397 | if (NULL == key) |
396 | return GNUNET_SYSERR; | 398 | return GNUNET_SYSERR; |
397 | GNUNET_log( | 399 | GNUNET_log ( |
398 | GNUNET_ERROR_TYPE_DEBUG, | 400 | GNUNET_ERROR_TYPE_DEBUG, |
399 | "Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %s prior to expiration (still trying to free another %llu bytes)\n", | 401 | "Deleting %llu bytes of low-priority (%u) content `%s' of type %u at %s prior to expiration (still trying to free another %llu bytes)\n", |
400 | (unsigned long long)(size + GNUNET_DATASTORE_ENTRY_OVERHEAD), | 402 | (unsigned long long) (size + GNUNET_DATASTORE_ENTRY_OVERHEAD), |
401 | (unsigned int)priority, | 403 | (unsigned int) priority, |
402 | GNUNET_h2s(key), | 404 | GNUNET_h2s (key), |
403 | type, | 405 | type, |
404 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_remaining( | 406 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining ( |
405 | expiration), | 407 | expiration), |
406 | GNUNET_YES), | 408 | GNUNET_YES), |
407 | *need); | 409 | *need); |
408 | if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need) | 410 | if (size + GNUNET_DATASTORE_ENTRY_OVERHEAD > *need) |
409 | *need = 0; | 411 | *need = 0; |
@@ -413,11 +415,11 @@ quota_processor(void *cls, | |||
413 | min_expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | 415 | min_expiration = GNUNET_TIME_UNIT_FOREVER_ABS; |
414 | else | 416 | else |
415 | min_expiration = expiration; | 417 | min_expiration = expiration; |
416 | GNUNET_STATISTICS_update(stats, | 418 | GNUNET_STATISTICS_update (stats, |
417 | gettext_noop("# bytes purged (low-priority)"), | 419 | gettext_noop ("# bytes purged (low-priority)"), |
418 | size, | 420 | size, |
419 | GNUNET_YES); | 421 | GNUNET_YES); |
420 | GNUNET_CONTAINER_bloomfilter_remove(filter, key); | 422 | GNUNET_CONTAINER_bloomfilter_remove (filter, key); |
421 | return GNUNET_NO; | 423 | return GNUNET_NO; |
422 | } | 424 | } |
423 | 425 | ||
@@ -435,19 +437,19 @@ quota_processor(void *cls, | |||
435 | * number of bytes that should be removed). | 437 | * number of bytes that should be removed). |
436 | */ | 438 | */ |
437 | static void | 439 | static void |
438 | manage_space(unsigned long long need) | 440 | manage_space (unsigned long long need) |
439 | { | 441 | { |
440 | unsigned long long last; | 442 | unsigned long long last; |
441 | 443 | ||
442 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
443 | "Asked to free up %llu bytes of cache space\n", | 445 | "Asked to free up %llu bytes of cache space\n", |
444 | need); | 446 | need); |
445 | last = 0; | 447 | last = 0; |
446 | while ((need > 0) && (last != need)) | 448 | while ((need > 0) && (last != need)) |
447 | { | 449 | { |
448 | last = need; | 450 | last = need; |
449 | plugin->api->get_expiration(plugin->api->cls, "a_processor, &need); | 451 | plugin->api->get_expiration (plugin->api->cls, "a_processor, &need); |
450 | } | 452 | } |
451 | } | 453 | } |
452 | 454 | ||
453 | 455 | ||
@@ -459,25 +461,25 @@ manage_space(unsigned long long need) | |||
459 | * @param msg optional error message (can be NULL) | 461 | * @param msg optional error message (can be NULL) |
460 | */ | 462 | */ |
461 | static void | 463 | static void |
462 | transmit_status(struct GNUNET_SERVICE_Client *client, | 464 | transmit_status (struct GNUNET_SERVICE_Client *client, |
463 | int code, | 465 | int code, |
464 | const char *msg) | 466 | const char *msg) |
465 | { | 467 | { |
466 | struct GNUNET_MQ_Envelope *env; | 468 | struct GNUNET_MQ_Envelope *env; |
467 | struct StatusMessage *sm; | 469 | struct StatusMessage *sm; |
468 | size_t slen; | 470 | size_t slen; |
469 | 471 | ||
470 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
471 | "Transmitting `%s' message with value %d and message `%s'\n", | 473 | "Transmitting `%s' message with value %d and message `%s'\n", |
472 | "STATUS", | 474 | "STATUS", |
473 | code, | 475 | code, |
474 | msg != NULL ? msg : "(none)"); | 476 | msg != NULL ? msg : "(none)"); |
475 | slen = (msg == NULL) ? 0 : strlen(msg) + 1; | 477 | slen = (msg == NULL) ? 0 : strlen (msg) + 1; |
476 | env = GNUNET_MQ_msg_extra(sm, slen, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS); | 478 | env = GNUNET_MQ_msg_extra (sm, slen, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS); |
477 | sm->status = htonl(code); | 479 | sm->status = htonl (code); |
478 | sm->min_expiration = GNUNET_TIME_absolute_hton(min_expiration); | 480 | sm->min_expiration = GNUNET_TIME_absolute_hton (min_expiration); |
479 | GNUNET_memcpy(&sm[1], msg, slen); | 481 | GNUNET_memcpy (&sm[1], msg, slen); |
480 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); | 482 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); |
481 | } | 483 | } |
482 | 484 | ||
483 | 485 | ||
@@ -500,16 +502,16 @@ transmit_status(struct GNUNET_SERVICE_Client *client, | |||
500 | * #GNUNET_NO to delete the item and continue (if supported) | 502 | * #GNUNET_NO to delete the item and continue (if supported) |
501 | */ | 503 | */ |
502 | static int | 504 | static int |
503 | transmit_item(void *cls, | 505 | transmit_item (void *cls, |
504 | const struct GNUNET_HashCode *key, | 506 | const struct GNUNET_HashCode *key, |
505 | uint32_t size, | 507 | uint32_t size, |
506 | const void *data, | 508 | const void *data, |
507 | enum GNUNET_BLOCK_Type type, | 509 | enum GNUNET_BLOCK_Type type, |
508 | uint32_t priority, | 510 | uint32_t priority, |
509 | uint32_t anonymity, | 511 | uint32_t anonymity, |
510 | uint32_t replication, | 512 | uint32_t replication, |
511 | struct GNUNET_TIME_Absolute expiration, | 513 | struct GNUNET_TIME_Absolute expiration, |
512 | uint64_t uid) | 514 | uint64_t uid) |
513 | { | 515 | { |
514 | struct GNUNET_SERVICE_Client *client = cls; | 516 | struct GNUNET_SERVICE_Client *client = cls; |
515 | struct GNUNET_MQ_Envelope *env; | 517 | struct GNUNET_MQ_Envelope *env; |
@@ -517,39 +519,39 @@ transmit_item(void *cls, | |||
517 | struct DataMessage *dm; | 519 | struct DataMessage *dm; |
518 | 520 | ||
519 | if (NULL == key) | 521 | if (NULL == key) |
520 | { | 522 | { |
521 | /* transmit 'DATA_END' */ | 523 | /* transmit 'DATA_END' */ |
522 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Transmitting DATA_END message\n"); | 524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting DATA_END message\n"); |
523 | env = GNUNET_MQ_msg(end, GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END); | 525 | env = GNUNET_MQ_msg (end, GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END); |
524 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); | 526 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); |
525 | return GNUNET_OK; | 527 | return GNUNET_OK; |
526 | } | 528 | } |
527 | GNUNET_assert(sizeof(struct DataMessage) + size < GNUNET_MAX_MESSAGE_SIZE); | 529 | GNUNET_assert (sizeof(struct DataMessage) + size < GNUNET_MAX_MESSAGE_SIZE); |
528 | env = GNUNET_MQ_msg_extra(dm, size, GNUNET_MESSAGE_TYPE_DATASTORE_DATA); | 530 | env = GNUNET_MQ_msg_extra (dm, size, GNUNET_MESSAGE_TYPE_DATASTORE_DATA); |
529 | dm->rid = htonl(0); | 531 | dm->rid = htonl (0); |
530 | dm->size = htonl(size); | 532 | dm->size = htonl (size); |
531 | dm->type = htonl(type); | 533 | dm->type = htonl (type); |
532 | dm->priority = htonl(priority); | 534 | dm->priority = htonl (priority); |
533 | dm->anonymity = htonl(anonymity); | 535 | dm->anonymity = htonl (anonymity); |
534 | dm->replication = htonl(replication); | 536 | dm->replication = htonl (replication); |
535 | dm->expiration = GNUNET_TIME_absolute_hton(expiration); | 537 | dm->expiration = GNUNET_TIME_absolute_hton (expiration); |
536 | dm->uid = GNUNET_htonll(uid); | 538 | dm->uid = GNUNET_htonll (uid); |
537 | dm->key = *key; | 539 | dm->key = *key; |
538 | GNUNET_memcpy(&dm[1], data, size); | 540 | GNUNET_memcpy (&dm[1], data, size); |
539 | GNUNET_log( | 541 | GNUNET_log ( |
540 | GNUNET_ERROR_TYPE_DEBUG, | 542 | GNUNET_ERROR_TYPE_DEBUG, |
541 | "Transmitting DATA message for `%s' of type %u with expiration %s (in: %s)\n", | 543 | "Transmitting DATA message for `%s' of type %u with expiration %s (in: %s)\n", |
542 | GNUNET_h2s(key), | 544 | GNUNET_h2s (key), |
543 | type, | 545 | type, |
544 | GNUNET_STRINGS_absolute_time_to_string(expiration), | 546 | GNUNET_STRINGS_absolute_time_to_string (expiration), |
545 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_remaining( | 547 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining ( |
546 | expiration), | 548 | expiration), |
547 | GNUNET_YES)); | 549 | GNUNET_YES)); |
548 | GNUNET_STATISTICS_update(stats, | 550 | GNUNET_STATISTICS_update (stats, |
549 | gettext_noop("# results found"), | 551 | gettext_noop ("# results found"), |
550 | 1, | 552 | 1, |
551 | GNUNET_NO); | 553 | GNUNET_NO); |
552 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), env); | 554 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); |
553 | return GNUNET_OK; | 555 | return GNUNET_OK; |
554 | } | 556 | } |
555 | 557 | ||
@@ -561,7 +563,7 @@ transmit_item(void *cls, | |||
561 | * @param message the actual message | 563 | * @param message the actual message |
562 | */ | 564 | */ |
563 | static void | 565 | static void |
564 | handle_reserve(void *cls, const struct ReserveMessage *msg) | 566 | handle_reserve (void *cls, const struct ReserveMessage *msg) |
565 | { | 567 | { |
566 | /** | 568 | /** |
567 | * Static counter to produce reservation identifiers. | 569 | * Static counter to produce reservation identifiers. |
@@ -574,57 +576,57 @@ handle_reserve(void *cls, const struct ReserveMessage *msg) | |||
574 | uint64_t amount; | 576 | uint64_t amount; |
575 | uint32_t entries; | 577 | uint32_t entries; |
576 | 578 | ||
577 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Processing RESERVE request\n"); | 579 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing RESERVE request\n"); |
578 | amount = GNUNET_ntohll(msg->amount); | 580 | amount = GNUNET_ntohll (msg->amount); |
579 | entries = ntohl(msg->entries); | 581 | entries = ntohl (msg->entries); |
580 | used = payload + reserved; | 582 | used = payload + reserved; |
581 | req = | 583 | req = |
582 | amount + ((unsigned long long)GNUNET_DATASTORE_ENTRY_OVERHEAD) * entries; | 584 | amount + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * entries; |
583 | if (used + req > quota) | 585 | if (used + req > quota) |
586 | { | ||
587 | if (quota < used) | ||
588 | used = | ||
589 | quota; /* cheat a bit for error message (to avoid negative numbers) */ | ||
590 | GNUNET_log ( | ||
591 | GNUNET_ERROR_TYPE_WARNING, | ||
592 | _ ( | ||
593 | "Insufficient space (%llu bytes are available) to satisfy RESERVE request for %llu bytes\n"), | ||
594 | quota - used, | ||
595 | req); | ||
596 | if (cache_size < req) | ||
584 | { | 597 | { |
585 | if (quota < used) | 598 | /* TODO: document this in the FAQ; essentially, if this |
586 | used = | 599 | * message happens, the insertion request could be blocked |
587 | quota; /* cheat a bit for error message (to avoid negative numbers) */ | 600 | * by less-important content from migration because it is |
588 | GNUNET_log( | 601 | * larger than 1/8th of the overall available space, and |
602 | * we only reserve 1/8th for "fresh" insertions */ | ||
603 | GNUNET_log ( | ||
589 | GNUNET_ERROR_TYPE_WARNING, | 604 | GNUNET_ERROR_TYPE_WARNING, |
590 | _( | 605 | _ ( |
591 | "Insufficient space (%llu bytes are available) to satisfy RESERVE request for %llu bytes\n"), | 606 | "The requested amount (%llu bytes) is larger than the cache size (%llu bytes)\n"), |
592 | quota - used, | 607 | req, |
593 | req); | 608 | cache_size); |
594 | if (cache_size < req) | 609 | transmit_status (client, |
595 | { | 610 | 0, |
596 | /* TODO: document this in the FAQ; essentially, if this | 611 | gettext_noop ( |
597 | * message happens, the insertion request could be blocked | 612 | "Insufficient space to satisfy request and " |
598 | * by less-important content from migration because it is | 613 | "requested amount is larger than cache size")); |
599 | * larger than 1/8th of the overall available space, and | 614 | } |
600 | * we only reserve 1/8th for "fresh" insertions */ | 615 | else |
601 | GNUNET_log( | 616 | { |
602 | GNUNET_ERROR_TYPE_WARNING, | 617 | transmit_status (client, |
603 | _( | 618 | 0, |
604 | "The requested amount (%llu bytes) is larger than the cache size (%llu bytes)\n"), | 619 | gettext_noop ("Insufficient space to satisfy request")); |
605 | req, | ||
606 | cache_size); | ||
607 | transmit_status(client, | ||
608 | 0, | ||
609 | gettext_noop( | ||
610 | "Insufficient space to satisfy request and " | ||
611 | "requested amount is larger than cache size")); | ||
612 | } | ||
613 | else | ||
614 | { | ||
615 | transmit_status(client, | ||
616 | 0, | ||
617 | gettext_noop("Insufficient space to satisfy request")); | ||
618 | } | ||
619 | GNUNET_SERVICE_client_continue(client); | ||
620 | return; | ||
621 | } | 620 | } |
621 | GNUNET_SERVICE_client_continue (client); | ||
622 | return; | ||
623 | } | ||
622 | reserved += req; | 624 | reserved += req; |
623 | GNUNET_STATISTICS_set(stats, | 625 | GNUNET_STATISTICS_set (stats, |
624 | gettext_noop("# reserved"), | 626 | gettext_noop ("# reserved"), |
625 | reserved, | 627 | reserved, |
626 | GNUNET_NO); | 628 | GNUNET_NO); |
627 | e = GNUNET_new(struct ReservationList); | 629 | e = GNUNET_new (struct ReservationList); |
628 | e->next = reservations; | 630 | e->next = reservations; |
629 | reservations = e; | 631 | reservations = e; |
630 | e->client = client; | 632 | e->client = client; |
@@ -633,8 +635,8 @@ handle_reserve(void *cls, const struct ReserveMessage *msg) | |||
633 | e->rid = ++reservation_gen; | 635 | e->rid = ++reservation_gen; |
634 | if (reservation_gen < 0) | 636 | if (reservation_gen < 0) |
635 | reservation_gen = 0; /* wrap around */ | 637 | reservation_gen = 0; /* wrap around */ |
636 | transmit_status(client, e->rid, NULL); | 638 | transmit_status (client, e->rid, NULL); |
637 | GNUNET_SERVICE_client_continue(client); | 639 | GNUNET_SERVICE_client_continue (client); |
638 | } | 640 | } |
639 | 641 | ||
640 | 642 | ||
@@ -645,51 +647,51 @@ handle_reserve(void *cls, const struct ReserveMessage *msg) | |||
645 | * @param message the actual message | 647 | * @param message the actual message |
646 | */ | 648 | */ |
647 | static void | 649 | static void |
648 | handle_release_reserve(void *cls, const struct ReleaseReserveMessage *msg) | 650 | handle_release_reserve (void *cls, const struct ReleaseReserveMessage *msg) |
649 | { | 651 | { |
650 | struct GNUNET_SERVICE_Client *client = cls; | 652 | struct GNUNET_SERVICE_Client *client = cls; |
651 | struct ReservationList *pos; | 653 | struct ReservationList *pos; |
652 | struct ReservationList *prev; | 654 | struct ReservationList *prev; |
653 | struct ReservationList *next; | 655 | struct ReservationList *next; |
654 | int rid = ntohl(msg->rid); | 656 | int rid = ntohl (msg->rid); |
655 | unsigned long long rem; | 657 | unsigned long long rem; |
656 | 658 | ||
657 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Processing RELEASE_RESERVE request\n"); | 659 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing RELEASE_RESERVE request\n"); |
658 | next = reservations; | 660 | next = reservations; |
659 | prev = NULL; | 661 | prev = NULL; |
660 | while (NULL != (pos = next)) | 662 | while (NULL != (pos = next)) |
663 | { | ||
664 | next = pos->next; | ||
665 | if (rid == pos->rid) | ||
661 | { | 666 | { |
662 | next = pos->next; | 667 | if (prev == NULL) |
663 | if (rid == pos->rid) | 668 | reservations = next; |
664 | { | 669 | else |
665 | if (prev == NULL) | 670 | prev->next = next; |
666 | reservations = next; | 671 | rem = |
667 | else | 672 | pos->amount |
668 | prev->next = next; | 673 | + ((unsigned long long) GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->entries; |
669 | rem = | 674 | GNUNET_assert (reserved >= rem); |
670 | pos->amount + | 675 | reserved -= rem; |
671 | ((unsigned long long)GNUNET_DATASTORE_ENTRY_OVERHEAD) * pos->entries; | 676 | GNUNET_STATISTICS_set (stats, |
672 | GNUNET_assert(reserved >= rem); | 677 | gettext_noop ("# reserved"), |
673 | reserved -= rem; | 678 | reserved, |
674 | GNUNET_STATISTICS_set(stats, | 679 | GNUNET_NO); |
675 | gettext_noop("# reserved"), | 680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
676 | reserved, | 681 | "Returning %llu remaining reserved bytes to storage pool\n", |
677 | GNUNET_NO); | 682 | rem); |
678 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 683 | GNUNET_free (pos); |
679 | "Returning %llu remaining reserved bytes to storage pool\n", | 684 | transmit_status (client, GNUNET_OK, NULL); |
680 | rem); | 685 | GNUNET_SERVICE_client_continue (client); |
681 | GNUNET_free(pos); | 686 | return; |
682 | transmit_status(client, GNUNET_OK, NULL); | ||
683 | GNUNET_SERVICE_client_continue(client); | ||
684 | return; | ||
685 | } | ||
686 | prev = pos; | ||
687 | } | 687 | } |
688 | GNUNET_break(0); | 688 | prev = pos; |
689 | transmit_status(client, | 689 | } |
690 | GNUNET_SYSERR, | 690 | GNUNET_break (0); |
691 | gettext_noop("Could not find matching reservation")); | 691 | transmit_status (client, |
692 | GNUNET_SERVICE_client_continue(client); | 692 | GNUNET_SYSERR, |
693 | gettext_noop ("Could not find matching reservation")); | ||
694 | GNUNET_SERVICE_client_continue (client); | ||
693 | } | 695 | } |
694 | 696 | ||
695 | 697 | ||
@@ -700,18 +702,18 @@ handle_release_reserve(void *cls, const struct ReleaseReserveMessage *msg) | |||
700 | * @return #GNUNET_SYSERR is not well-formed, otherwise #GNUNET_OK | 702 | * @return #GNUNET_SYSERR is not well-formed, otherwise #GNUNET_OK |
701 | */ | 703 | */ |
702 | static int | 704 | static int |
703 | check_data(const struct DataMessage *dm) | 705 | check_data (const struct DataMessage *dm) |
704 | { | 706 | { |
705 | uint16_t size; | 707 | uint16_t size; |
706 | uint32_t dsize; | 708 | uint32_t dsize; |
707 | 709 | ||
708 | size = ntohs(dm->header.size); | 710 | size = ntohs (dm->header.size); |
709 | dsize = ntohl(dm->size); | 711 | dsize = ntohl (dm->size); |
710 | if (size != dsize + sizeof(struct DataMessage)) | 712 | if (size != dsize + sizeof(struct DataMessage)) |
711 | { | 713 | { |
712 | GNUNET_break(0); | 714 | GNUNET_break (0); |
713 | return GNUNET_SYSERR; | 715 | return GNUNET_SYSERR; |
714 | } | 716 | } |
715 | return GNUNET_OK; | 717 | return GNUNET_OK; |
716 | } | 718 | } |
717 | 719 | ||
@@ -727,38 +729,38 @@ check_data(const struct DataMessage *dm) | |||
727 | * @param msg error message on error | 729 | * @param msg error message on error |
728 | */ | 730 | */ |
729 | static void | 731 | static void |
730 | put_continuation(void *cls, | 732 | put_continuation (void *cls, |
731 | const struct GNUNET_HashCode *key, | 733 | const struct GNUNET_HashCode *key, |
732 | uint32_t size, | 734 | uint32_t size, |
733 | int status, | 735 | int status, |
734 | const char *msg) | 736 | const char *msg) |
735 | { | 737 | { |
736 | struct GNUNET_SERVICE_Client *client = cls; | 738 | struct GNUNET_SERVICE_Client *client = cls; |
737 | 739 | ||
738 | if (GNUNET_OK == status) | 740 | if (GNUNET_OK == status) |
739 | { | 741 | { |
740 | GNUNET_STATISTICS_update(stats, | 742 | GNUNET_STATISTICS_update (stats, |
741 | gettext_noop("# bytes stored"), | 743 | gettext_noop ("# bytes stored"), |
742 | size, | 744 | size, |
743 | GNUNET_YES); | 745 | GNUNET_YES); |
744 | GNUNET_CONTAINER_bloomfilter_add(filter, key); | 746 | GNUNET_CONTAINER_bloomfilter_add (filter, key); |
745 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 747 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
746 | "Successfully stored %u bytes under key `%s'\n", | 748 | "Successfully stored %u bytes under key `%s'\n", |
747 | size, | 749 | size, |
748 | GNUNET_h2s(key)); | 750 | GNUNET_h2s (key)); |
749 | } | 751 | } |
750 | transmit_status(client, | 752 | transmit_status (client, |
751 | GNUNET_SYSERR == status ? GNUNET_SYSERR : GNUNET_OK, | 753 | GNUNET_SYSERR == status ? GNUNET_SYSERR : GNUNET_OK, |
752 | msg); | 754 | msg); |
753 | if (quota - reserved - cache_size < payload) | 755 | if (quota - reserved - cache_size < payload) |
754 | { | 756 | { |
755 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 757 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
756 | _("Need %llu bytes more space (%llu allowed, using %llu)\n"), | 758 | _ ("Need %llu bytes more space (%llu allowed, using %llu)\n"), |
757 | (unsigned long long)size + GNUNET_DATASTORE_ENTRY_OVERHEAD, | 759 | (unsigned long long) size + GNUNET_DATASTORE_ENTRY_OVERHEAD, |
758 | (unsigned long long)(quota - reserved - cache_size), | 760 | (unsigned long long) (quota - reserved - cache_size), |
759 | (unsigned long long)payload); | 761 | (unsigned long long) payload); |
760 | manage_space(size + GNUNET_DATASTORE_ENTRY_OVERHEAD); | 762 | manage_space (size + GNUNET_DATASTORE_ENTRY_OVERHEAD); |
761 | } | 763 | } |
762 | } | 764 | } |
763 | 765 | ||
764 | 766 | ||
@@ -770,13 +772,13 @@ put_continuation(void *cls, | |||
770 | * @return #GNUNET_OK if @a dm is well-formed | 772 | * @return #GNUNET_OK if @a dm is well-formed |
771 | */ | 773 | */ |
772 | static int | 774 | static int |
773 | check_put(void *cls, const struct DataMessage *dm) | 775 | check_put (void *cls, const struct DataMessage *dm) |
774 | { | 776 | { |
775 | if (GNUNET_OK != check_data(dm)) | 777 | if (GNUNET_OK != check_data (dm)) |
776 | { | 778 | { |
777 | GNUNET_break(0); | 779 | GNUNET_break (0); |
778 | return GNUNET_SYSERR; | 780 | return GNUNET_SYSERR; |
779 | } | 781 | } |
780 | return GNUNET_OK; | 782 | return GNUNET_OK; |
781 | } | 783 | } |
782 | 784 | ||
@@ -788,53 +790,53 @@ check_put(void *cls, const struct DataMessage *dm) | |||
788 | * @param message the actual message | 790 | * @param message the actual message |
789 | */ | 791 | */ |
790 | static void | 792 | static void |
791 | handle_put(void *cls, const struct DataMessage *dm) | 793 | handle_put (void *cls, const struct DataMessage *dm) |
792 | { | 794 | { |
793 | struct GNUNET_SERVICE_Client *client = cls; | 795 | struct GNUNET_SERVICE_Client *client = cls; |
794 | int rid; | 796 | int rid; |
795 | struct ReservationList *pos; | 797 | struct ReservationList *pos; |
796 | uint32_t size; | 798 | uint32_t size; |
797 | 799 | ||
798 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 800 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
799 | "Processing PUT request for `%s' of type %u\n", | 801 | "Processing PUT request for `%s' of type %u\n", |
800 | GNUNET_h2s(&dm->key), | 802 | GNUNET_h2s (&dm->key), |
801 | (uint32_t)ntohl(dm->type)); | 803 | (uint32_t) ntohl (dm->type)); |
802 | rid = ntohl(dm->rid); | 804 | rid = ntohl (dm->rid); |
803 | size = ntohl(dm->size); | 805 | size = ntohl (dm->size); |
804 | if (rid > 0) | 806 | if (rid > 0) |
807 | { | ||
808 | pos = reservations; | ||
809 | while ((NULL != pos) && (rid != pos->rid)) | ||
810 | pos = pos->next; | ||
811 | GNUNET_break (pos != NULL); | ||
812 | if (NULL != pos) | ||
805 | { | 813 | { |
806 | pos = reservations; | 814 | GNUNET_break (pos->entries > 0); |
807 | while ((NULL != pos) && (rid != pos->rid)) | 815 | GNUNET_break (pos->amount >= size); |
808 | pos = pos->next; | 816 | pos->entries--; |
809 | GNUNET_break(pos != NULL); | 817 | pos->amount -= size; |
810 | if (NULL != pos) | 818 | reserved -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD); |
811 | { | 819 | GNUNET_STATISTICS_set (stats, |
812 | GNUNET_break(pos->entries > 0); | 820 | gettext_noop ("# reserved"), |
813 | GNUNET_break(pos->amount >= size); | 821 | reserved, |
814 | pos->entries--; | 822 | GNUNET_NO); |
815 | pos->amount -= size; | ||
816 | reserved -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD); | ||
817 | GNUNET_STATISTICS_set(stats, | ||
818 | gettext_noop("# reserved"), | ||
819 | reserved, | ||
820 | GNUNET_NO); | ||
821 | } | ||
822 | } | 823 | } |
824 | } | ||
823 | bool absent = | 825 | bool absent = |
824 | GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test(filter, &dm->key); | 826 | GNUNET_NO == GNUNET_CONTAINER_bloomfilter_test (filter, &dm->key); |
825 | plugin->api->put(plugin->api->cls, | 827 | plugin->api->put (plugin->api->cls, |
826 | &dm->key, | 828 | &dm->key, |
827 | absent, | 829 | absent, |
828 | ntohl(dm->size), | 830 | ntohl (dm->size), |
829 | &dm[1], | 831 | &dm[1], |
830 | ntohl(dm->type), | 832 | ntohl (dm->type), |
831 | ntohl(dm->priority), | 833 | ntohl (dm->priority), |
832 | ntohl(dm->anonymity), | 834 | ntohl (dm->anonymity), |
833 | ntohl(dm->replication), | 835 | ntohl (dm->replication), |
834 | GNUNET_TIME_absolute_ntoh(dm->expiration), | 836 | GNUNET_TIME_absolute_ntoh (dm->expiration), |
835 | &put_continuation, | 837 | &put_continuation, |
836 | client); | 838 | client); |
837 | GNUNET_SERVICE_client_continue(client); | 839 | GNUNET_SERVICE_client_continue (client); |
838 | } | 840 | } |
839 | 841 | ||
840 | 842 | ||
@@ -845,25 +847,25 @@ handle_put(void *cls, const struct DataMessage *dm) | |||
845 | * @param msg the actual message | 847 | * @param msg the actual message |
846 | */ | 848 | */ |
847 | static void | 849 | static void |
848 | handle_get(void *cls, const struct GetMessage *msg) | 850 | handle_get (void *cls, const struct GetMessage *msg) |
849 | { | 851 | { |
850 | struct GNUNET_SERVICE_Client *client = cls; | 852 | struct GNUNET_SERVICE_Client *client = cls; |
851 | 853 | ||
852 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 854 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
853 | "Processing GET request of type %u\n", | 855 | "Processing GET request of type %u\n", |
854 | (uint32_t)ntohl(msg->type)); | 856 | (uint32_t) ntohl (msg->type)); |
855 | GNUNET_STATISTICS_update(stats, | 857 | GNUNET_STATISTICS_update (stats, |
856 | gettext_noop("# GET requests received"), | 858 | gettext_noop ("# GET requests received"), |
857 | 1, | 859 | 1, |
858 | GNUNET_NO); | 860 | GNUNET_NO); |
859 | plugin->api->get_key(plugin->api->cls, | 861 | plugin->api->get_key (plugin->api->cls, |
860 | GNUNET_ntohll(msg->next_uid), | 862 | GNUNET_ntohll (msg->next_uid), |
861 | msg->random, | 863 | msg->random, |
862 | NULL, | 864 | NULL, |
863 | ntohl(msg->type), | 865 | ntohl (msg->type), |
864 | &transmit_item, | 866 | &transmit_item, |
865 | client); | 867 | client); |
866 | GNUNET_SERVICE_client_continue(client); | 868 | GNUNET_SERVICE_client_continue (client); |
867 | } | 869 | } |
868 | 870 | ||
869 | 871 | ||
@@ -874,50 +876,50 @@ handle_get(void *cls, const struct GetMessage *msg) | |||
874 | * @param msg the actual message | 876 | * @param msg the actual message |
875 | */ | 877 | */ |
876 | static void | 878 | static void |
877 | handle_get_key(void *cls, const struct GetKeyMessage *msg) | 879 | handle_get_key (void *cls, const struct GetKeyMessage *msg) |
878 | { | 880 | { |
879 | struct GNUNET_SERVICE_Client *client = cls; | 881 | struct GNUNET_SERVICE_Client *client = cls; |
880 | 882 | ||
881 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 883 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
882 | "Processing GET request for `%s' of type %u\n", | 884 | "Processing GET request for `%s' of type %u\n", |
883 | GNUNET_h2s(&msg->key), | 885 | GNUNET_h2s (&msg->key), |
884 | (uint32_t)ntohl(msg->type)); | 886 | (uint32_t) ntohl (msg->type)); |
885 | GNUNET_STATISTICS_update(stats, | 887 | GNUNET_STATISTICS_update (stats, |
886 | gettext_noop("# GET KEY requests received"), | 888 | gettext_noop ("# GET KEY requests received"), |
887 | 1, | 889 | 1, |
888 | GNUNET_NO); | 890 | GNUNET_NO); |
889 | if (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test(filter, &msg->key)) | 891 | if (GNUNET_YES != GNUNET_CONTAINER_bloomfilter_test (filter, &msg->key)) |
890 | { | 892 | { |
891 | /* don't bother database... */ | 893 | /* don't bother database... */ |
892 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 894 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
893 | "Empty result set for GET request for `%s' (bloomfilter).\n", | 895 | "Empty result set for GET request for `%s' (bloomfilter).\n", |
894 | GNUNET_h2s(&msg->key)); | 896 | GNUNET_h2s (&msg->key)); |
895 | GNUNET_STATISTICS_update(stats, | 897 | GNUNET_STATISTICS_update (stats, |
896 | gettext_noop( | 898 | gettext_noop ( |
897 | "# requests filtered by bloomfilter"), | 899 | "# requests filtered by bloomfilter"), |
898 | 1, | 900 | 1, |
899 | GNUNET_NO); | 901 | GNUNET_NO); |
900 | transmit_item(client, | 902 | transmit_item (client, |
901 | NULL, | 903 | NULL, |
902 | 0, | 904 | 0, |
903 | NULL, | 905 | NULL, |
904 | 0, | 906 | 0, |
905 | 0, | 907 | 0, |
906 | 0, | 908 | 0, |
907 | 0, | 909 | 0, |
908 | GNUNET_TIME_UNIT_ZERO_ABS, | 910 | GNUNET_TIME_UNIT_ZERO_ABS, |
909 | 0); | 911 | 0); |
910 | GNUNET_SERVICE_client_continue(client); | 912 | GNUNET_SERVICE_client_continue (client); |
911 | return; | 913 | return; |
912 | } | 914 | } |
913 | plugin->api->get_key(plugin->api->cls, | 915 | plugin->api->get_key (plugin->api->cls, |
914 | GNUNET_ntohll(msg->next_uid), | 916 | GNUNET_ntohll (msg->next_uid), |
915 | msg->random, | 917 | msg->random, |
916 | &msg->key, | 918 | &msg->key, |
917 | ntohl(msg->type), | 919 | ntohl (msg->type), |
918 | &transmit_item, | 920 | &transmit_item, |
919 | client); | 921 | client); |
920 | GNUNET_SERVICE_client_continue(client); | 922 | GNUNET_SERVICE_client_continue (client); |
921 | } | 923 | } |
922 | 924 | ||
923 | 925 | ||
@@ -928,18 +930,18 @@ handle_get_key(void *cls, const struct GetKeyMessage *msg) | |||
928 | * @param message the actual message | 930 | * @param message the actual message |
929 | */ | 931 | */ |
930 | static void | 932 | static void |
931 | handle_get_replication(void *cls, const struct GNUNET_MessageHeader *message) | 933 | handle_get_replication (void *cls, const struct GNUNET_MessageHeader *message) |
932 | { | 934 | { |
933 | struct GNUNET_SERVICE_Client *client = cls; | 935 | struct GNUNET_SERVICE_Client *client = cls; |
934 | 936 | ||
935 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Processing GET_REPLICATION request\n"); | 937 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing GET_REPLICATION request\n"); |
936 | GNUNET_STATISTICS_update(stats, | 938 | GNUNET_STATISTICS_update (stats, |
937 | gettext_noop( | 939 | gettext_noop ( |
938 | "# GET REPLICATION requests received"), | 940 | "# GET REPLICATION requests received"), |
939 | 1, | 941 | 1, |
940 | GNUNET_NO); | 942 | GNUNET_NO); |
941 | plugin->api->get_replication(plugin->api->cls, &transmit_item, client); | 943 | plugin->api->get_replication (plugin->api->cls, &transmit_item, client); |
942 | GNUNET_SERVICE_client_continue(client); | 944 | GNUNET_SERVICE_client_continue (client); |
943 | } | 945 | } |
944 | 946 | ||
945 | 947 | ||
@@ -950,31 +952,31 @@ handle_get_replication(void *cls, const struct GNUNET_MessageHeader *message) | |||
950 | * @param message the actual message | 952 | * @param message the actual message |
951 | */ | 953 | */ |
952 | static void | 954 | static void |
953 | handle_get_zero_anonymity(void *cls, const struct GetZeroAnonymityMessage *msg) | 955 | handle_get_zero_anonymity (void *cls, const struct GetZeroAnonymityMessage *msg) |
954 | { | 956 | { |
955 | struct GNUNET_SERVICE_Client *client = cls; | 957 | struct GNUNET_SERVICE_Client *client = cls; |
956 | enum GNUNET_BLOCK_Type type; | 958 | enum GNUNET_BLOCK_Type type; |
957 | 959 | ||
958 | type = (enum GNUNET_BLOCK_Type)ntohl(msg->type); | 960 | type = (enum GNUNET_BLOCK_Type) ntohl (msg->type); |
959 | if (type == GNUNET_BLOCK_TYPE_ANY) | 961 | if (type == GNUNET_BLOCK_TYPE_ANY) |
960 | { | 962 | { |
961 | GNUNET_break(0); | 963 | GNUNET_break (0); |
962 | GNUNET_SERVICE_client_drop(client); | 964 | GNUNET_SERVICE_client_drop (client); |
963 | return; | 965 | return; |
964 | } | 966 | } |
965 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
966 | "Processing GET_ZERO_ANONYMITY request\n"); | 968 | "Processing GET_ZERO_ANONYMITY request\n"); |
967 | GNUNET_STATISTICS_update(stats, | 969 | GNUNET_STATISTICS_update (stats, |
968 | gettext_noop( | 970 | gettext_noop ( |
969 | "# GET ZERO ANONYMITY requests received"), | 971 | "# GET ZERO ANONYMITY requests received"), |
970 | 1, | 972 | 1, |
971 | GNUNET_NO); | 973 | GNUNET_NO); |
972 | plugin->api->get_zero_anonymity(plugin->api->cls, | 974 | plugin->api->get_zero_anonymity (plugin->api->cls, |
973 | GNUNET_ntohll(msg->next_uid), | 975 | GNUNET_ntohll (msg->next_uid), |
974 | type, | 976 | type, |
975 | &transmit_item, | 977 | &transmit_item, |
976 | client); | 978 | client); |
977 | GNUNET_SERVICE_client_continue(client); | 979 | GNUNET_SERVICE_client_continue (client); |
978 | } | 980 | } |
979 | 981 | ||
980 | 982 | ||
@@ -989,36 +991,36 @@ handle_get_zero_anonymity(void *cls, const struct GetZeroAnonymityMessage *msg) | |||
989 | * @param msg error message on error | 991 | * @param msg error message on error |
990 | */ | 992 | */ |
991 | static void | 993 | static void |
992 | remove_continuation(void *cls, | 994 | remove_continuation (void *cls, |
993 | const struct GNUNET_HashCode *key, | 995 | const struct GNUNET_HashCode *key, |
994 | uint32_t size, | 996 | uint32_t size, |
995 | int status, | 997 | int status, |
996 | const char *msg) | 998 | const char *msg) |
997 | { | 999 | { |
998 | struct GNUNET_SERVICE_Client *client = cls; | 1000 | struct GNUNET_SERVICE_Client *client = cls; |
999 | 1001 | ||
1000 | if (GNUNET_SYSERR == status) | 1002 | if (GNUNET_SYSERR == status) |
1001 | { | 1003 | { |
1002 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "REMOVE request failed: %s.\n", msg); | 1004 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "REMOVE request failed: %s.\n", msg); |
1003 | transmit_status(client, GNUNET_NO, msg); | 1005 | transmit_status (client, GNUNET_NO, msg); |
1004 | return; | 1006 | return; |
1005 | } | 1007 | } |
1006 | if (GNUNET_NO == status) | 1008 | if (GNUNET_NO == status) |
1007 | { | 1009 | { |
1008 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1009 | "Content not found for REMOVE request.\n"); | 1011 | "Content not found for REMOVE request.\n"); |
1010 | transmit_status(client, GNUNET_NO, _("Content not found")); | 1012 | transmit_status (client, GNUNET_NO, _ ("Content not found")); |
1011 | return; | 1013 | return; |
1012 | } | 1014 | } |
1013 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1015 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1014 | "Item matches REMOVE request for key `%s'.\n", | 1016 | "Item matches REMOVE request for key `%s'.\n", |
1015 | GNUNET_h2s(key)); | 1017 | GNUNET_h2s (key)); |
1016 | GNUNET_STATISTICS_update(stats, | 1018 | GNUNET_STATISTICS_update (stats, |
1017 | gettext_noop("# bytes removed (explicit request)"), | 1019 | gettext_noop ("# bytes removed (explicit request)"), |
1018 | size, | 1020 | size, |
1019 | GNUNET_YES); | 1021 | GNUNET_YES); |
1020 | GNUNET_CONTAINER_bloomfilter_remove(filter, key); | 1022 | GNUNET_CONTAINER_bloomfilter_remove (filter, key); |
1021 | transmit_status(client, GNUNET_OK, NULL); | 1023 | transmit_status (client, GNUNET_OK, NULL); |
1022 | } | 1024 | } |
1023 | 1025 | ||
1024 | 1026 | ||
@@ -1030,13 +1032,13 @@ remove_continuation(void *cls, | |||
1030 | * @return #GNUNET_OK if @a dm is well-formed | 1032 | * @return #GNUNET_OK if @a dm is well-formed |
1031 | */ | 1033 | */ |
1032 | static int | 1034 | static int |
1033 | check_remove(void *cls, const struct DataMessage *dm) | 1035 | check_remove (void *cls, const struct DataMessage *dm) |
1034 | { | 1036 | { |
1035 | if (GNUNET_OK != check_data(dm)) | 1037 | if (GNUNET_OK != check_data (dm)) |
1036 | { | 1038 | { |
1037 | GNUNET_break(0); | 1039 | GNUNET_break (0); |
1038 | return GNUNET_SYSERR; | 1040 | return GNUNET_SYSERR; |
1039 | } | 1041 | } |
1040 | return GNUNET_OK; | 1042 | return GNUNET_OK; |
1041 | } | 1043 | } |
1042 | 1044 | ||
@@ -1049,24 +1051,24 @@ check_remove(void *cls, const struct DataMessage *dm) | |||
1049 | * @param message the actual message | 1051 | * @param message the actual message |
1050 | */ | 1052 | */ |
1051 | static void | 1053 | static void |
1052 | handle_remove(void *cls, const struct DataMessage *dm) | 1054 | handle_remove (void *cls, const struct DataMessage *dm) |
1053 | { | 1055 | { |
1054 | struct GNUNET_SERVICE_Client *client = cls; | 1056 | struct GNUNET_SERVICE_Client *client = cls; |
1055 | 1057 | ||
1056 | GNUNET_STATISTICS_update(stats, | 1058 | GNUNET_STATISTICS_update (stats, |
1057 | gettext_noop("# REMOVE requests received"), | 1059 | gettext_noop ("# REMOVE requests received"), |
1058 | 1, | 1060 | 1, |
1059 | GNUNET_NO); | 1061 | GNUNET_NO); |
1060 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1062 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1061 | "Processing REMOVE request for `%s'\n", | 1063 | "Processing REMOVE request for `%s'\n", |
1062 | GNUNET_h2s(&dm->key)); | 1064 | GNUNET_h2s (&dm->key)); |
1063 | plugin->api->remove_key(plugin->api->cls, | 1065 | plugin->api->remove_key (plugin->api->cls, |
1064 | &dm->key, | 1066 | &dm->key, |
1065 | ntohl(dm->size), | 1067 | ntohl (dm->size), |
1066 | &dm[1], | 1068 | &dm[1], |
1067 | &remove_continuation, | 1069 | &remove_continuation, |
1068 | client); | 1070 | client); |
1069 | GNUNET_SERVICE_client_continue(client); | 1071 | GNUNET_SERVICE_client_continue (client); |
1070 | } | 1072 | } |
1071 | 1073 | ||
1072 | 1074 | ||
@@ -1077,13 +1079,13 @@ handle_remove(void *cls, const struct DataMessage *dm) | |||
1077 | * @param message the actual message | 1079 | * @param message the actual message |
1078 | */ | 1080 | */ |
1079 | static void | 1081 | static void |
1080 | handle_drop(void *cls, const struct GNUNET_MessageHeader *message) | 1082 | handle_drop (void *cls, const struct GNUNET_MessageHeader *message) |
1081 | { | 1083 | { |
1082 | struct GNUNET_SERVICE_Client *client = cls; | 1084 | struct GNUNET_SERVICE_Client *client = cls; |
1083 | 1085 | ||
1084 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Processing DROP request\n"); | 1086 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Processing DROP request\n"); |
1085 | do_drop = GNUNET_YES; | 1087 | do_drop = GNUNET_YES; |
1086 | GNUNET_SERVICE_client_continue(client); | 1088 | GNUNET_SERVICE_client_continue (client); |
1087 | } | 1089 | } |
1088 | 1090 | ||
1089 | 1091 | ||
@@ -1096,27 +1098,27 @@ handle_drop(void *cls, const struct GNUNET_MessageHeader *message) | |||
1096 | * 0 for "reset to empty" | 1098 | * 0 for "reset to empty" |
1097 | */ | 1099 | */ |
1098 | static void | 1100 | static void |
1099 | disk_utilization_change_cb(void *cls, int delta) | 1101 | disk_utilization_change_cb (void *cls, int delta) |
1100 | { | 1102 | { |
1101 | if ((delta < 0) && (payload < -delta)) | 1103 | if ((delta < 0) && (payload < -delta)) |
1102 | { | 1104 | { |
1103 | GNUNET_log( | 1105 | GNUNET_log ( |
1104 | GNUNET_ERROR_TYPE_WARNING, | 1106 | GNUNET_ERROR_TYPE_WARNING, |
1105 | _( | 1107 | _ ( |
1106 | "Datastore payload must have been inaccurate (%lld < %lld). Recomputing it.\n"), | 1108 | "Datastore payload must have been inaccurate (%lld < %lld). Recomputing it.\n"), |
1107 | (long long)payload, | 1109 | (long long) payload, |
1108 | (long long)-delta); | 1110 | (long long) -delta); |
1109 | plugin->api->estimate_size(plugin->api->cls, &payload); | 1111 | plugin->api->estimate_size (plugin->api->cls, &payload); |
1110 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1112 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1111 | _("New payload: %lld\n"), | 1113 | _ ("New payload: %lld\n"), |
1112 | (long long)payload); | 1114 | (long long) payload); |
1113 | sync_stats(); | 1115 | sync_stats (); |
1114 | return; | 1116 | return; |
1115 | } | 1117 | } |
1116 | payload += delta; | 1118 | payload += delta; |
1117 | last_sync++; | 1119 | last_sync++; |
1118 | if (last_sync >= MAX_STAT_SYNC_LAG) | 1120 | if (last_sync >= MAX_STAT_SYNC_LAG) |
1119 | sync_stats(); | 1121 | sync_stats (); |
1120 | } | 1122 | } |
1121 | 1123 | ||
1122 | 1124 | ||
@@ -1131,20 +1133,20 @@ disk_utilization_change_cb(void *cls, int delta) | |||
1131 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | 1133 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
1132 | */ | 1134 | */ |
1133 | static int | 1135 | static int |
1134 | process_stat_in(void *cls, | 1136 | process_stat_in (void *cls, |
1135 | const char *subsystem, | 1137 | const char *subsystem, |
1136 | const char *name, | 1138 | const char *name, |
1137 | uint64_t value, | 1139 | uint64_t value, |
1138 | int is_persistent) | 1140 | int is_persistent) |
1139 | { | 1141 | { |
1140 | GNUNET_assert(GNUNET_NO == stats_worked); | 1142 | GNUNET_assert (GNUNET_NO == stats_worked); |
1141 | stats_worked = GNUNET_YES; | 1143 | stats_worked = GNUNET_YES; |
1142 | payload += value; | 1144 | payload += value; |
1143 | GNUNET_log( | 1145 | GNUNET_log ( |
1144 | GNUNET_ERROR_TYPE_DEBUG, | 1146 | GNUNET_ERROR_TYPE_DEBUG, |
1145 | "Notification from statistics about existing payload (%llu), new payload is %llu\n", | 1147 | "Notification from statistics about existing payload (%llu), new payload is %llu\n", |
1146 | (unsigned long long)value, | 1148 | (unsigned long long) value, |
1147 | (unsigned long long)payload); | 1149 | (unsigned long long) payload); |
1148 | return GNUNET_OK; | 1150 | return GNUNET_OK; |
1149 | } | 1151 | } |
1150 | 1152 | ||
@@ -1153,32 +1155,32 @@ process_stat_in(void *cls, | |||
1153 | * Load the datastore plugin. | 1155 | * Load the datastore plugin. |
1154 | */ | 1156 | */ |
1155 | static struct DatastorePlugin * | 1157 | static struct DatastorePlugin * |
1156 | load_plugin() | 1158 | load_plugin () |
1157 | { | 1159 | { |
1158 | struct DatastorePlugin *ret; | 1160 | struct DatastorePlugin *ret; |
1159 | char *libname; | 1161 | char *libname; |
1160 | 1162 | ||
1161 | ret = GNUNET_new(struct DatastorePlugin); | 1163 | ret = GNUNET_new (struct DatastorePlugin); |
1162 | ret->env.cfg = cfg; | 1164 | ret->env.cfg = cfg; |
1163 | ret->env.duc = &disk_utilization_change_cb; | 1165 | ret->env.duc = &disk_utilization_change_cb; |
1164 | ret->env.cls = NULL; | 1166 | ret->env.cls = NULL; |
1165 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1167 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1166 | _("Loading `%s' datastore plugin\n"), | 1168 | _ ("Loading `%s' datastore plugin\n"), |
1167 | plugin_name); | 1169 | plugin_name); |
1168 | GNUNET_asprintf(&libname, "libgnunet_plugin_datastore_%s", plugin_name); | 1170 | GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", plugin_name); |
1169 | ret->short_name = GNUNET_strdup(plugin_name); | 1171 | ret->short_name = GNUNET_strdup (plugin_name); |
1170 | ret->lib_name = libname; | 1172 | ret->lib_name = libname; |
1171 | ret->api = GNUNET_PLUGIN_load(libname, &ret->env); | 1173 | ret->api = GNUNET_PLUGIN_load (libname, &ret->env); |
1172 | if (NULL == ret->api) | 1174 | if (NULL == ret->api) |
1173 | { | 1175 | { |
1174 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1176 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1175 | _("Failed to load datastore plugin for `%s'\n"), | 1177 | _ ("Failed to load datastore plugin for `%s'\n"), |
1176 | plugin_name); | 1178 | plugin_name); |
1177 | GNUNET_free(ret->short_name); | 1179 | GNUNET_free (ret->short_name); |
1178 | GNUNET_free(libname); | 1180 | GNUNET_free (libname); |
1179 | GNUNET_free(ret); | 1181 | GNUNET_free (ret); |
1180 | return NULL; | 1182 | return NULL; |
1181 | } | 1183 | } |
1182 | return ret; | 1184 | return ret; |
1183 | } | 1185 | } |
1184 | 1186 | ||
@@ -1190,14 +1192,14 @@ load_plugin() | |||
1190 | * @param plug plugin to unload | 1192 | * @param plug plugin to unload |
1191 | */ | 1193 | */ |
1192 | static void | 1194 | static void |
1193 | unload_plugin(struct DatastorePlugin *plug) | 1195 | unload_plugin (struct DatastorePlugin *plug) |
1194 | { | 1196 | { |
1195 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1196 | "Datastore service is unloading plugin...\n"); | 1198 | "Datastore service is unloading plugin...\n"); |
1197 | GNUNET_break(NULL == GNUNET_PLUGIN_unload(plug->lib_name, plug->api)); | 1199 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); |
1198 | GNUNET_free(plug->lib_name); | 1200 | GNUNET_free (plug->lib_name); |
1199 | GNUNET_free(plug->short_name); | 1201 | GNUNET_free (plug->short_name); |
1200 | GNUNET_free(plug); | 1202 | GNUNET_free (plug); |
1201 | } | 1203 | } |
1202 | 1204 | ||
1203 | 1205 | ||
@@ -1205,13 +1207,13 @@ unload_plugin(struct DatastorePlugin *plug) | |||
1205 | * Initialization complete, start operating the service. | 1207 | * Initialization complete, start operating the service. |
1206 | */ | 1208 | */ |
1207 | static void | 1209 | static void |
1208 | begin_service() | 1210 | begin_service () |
1209 | { | 1211 | { |
1210 | GNUNET_SERVICE_resume(service); | 1212 | GNUNET_SERVICE_resume (service); |
1211 | expired_kill_task = | 1213 | expired_kill_task = |
1212 | GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_IDLE, | 1214 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1213 | &delete_expired, | 1215 | &delete_expired, |
1214 | NULL); | 1216 | NULL); |
1215 | } | 1217 | } |
1216 | 1218 | ||
1217 | 1219 | ||
@@ -1223,22 +1225,22 @@ begin_service() | |||
1223 | * @param count number of times to add key | 1225 | * @param count number of times to add key |
1224 | */ | 1226 | */ |
1225 | static void | 1227 | static void |
1226 | add_key_to_bloomfilter(void *cls, | 1228 | add_key_to_bloomfilter (void *cls, |
1227 | const struct GNUNET_HashCode *key, | 1229 | const struct GNUNET_HashCode *key, |
1228 | unsigned int count) | 1230 | unsigned int count) |
1229 | { | 1231 | { |
1230 | struct GNUNET_CONTAINER_BloomFilter *bf = cls; | 1232 | struct GNUNET_CONTAINER_BloomFilter *bf = cls; |
1231 | 1233 | ||
1232 | if (NULL == key) | 1234 | if (NULL == key) |
1233 | { | 1235 | { |
1234 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1236 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1235 | _("Bloomfilter construction complete.\n")); | 1237 | _ ("Bloomfilter construction complete.\n")); |
1236 | begin_service(); | 1238 | begin_service (); |
1237 | return; | 1239 | return; |
1238 | } | 1240 | } |
1239 | 1241 | ||
1240 | while (0 < count--) | 1242 | while (0 < count--) |
1241 | GNUNET_CONTAINER_bloomfilter_add(bf, key); | 1243 | GNUNET_CONTAINER_bloomfilter_add (bf, key); |
1242 | } | 1244 | } |
1243 | 1245 | ||
1244 | 1246 | ||
@@ -1250,54 +1252,54 @@ add_key_to_bloomfilter(void *cls, | |||
1250 | * @param success #GNUNET_NO if we failed to read the stat | 1252 | * @param success #GNUNET_NO if we failed to read the stat |
1251 | */ | 1253 | */ |
1252 | static void | 1254 | static void |
1253 | process_stat_done(void *cls, int success) | 1255 | process_stat_done (void *cls, int success) |
1254 | { | 1256 | { |
1255 | stat_get = NULL; | 1257 | stat_get = NULL; |
1256 | if (NULL != stat_timeout_task) | 1258 | if (NULL != stat_timeout_task) |
1257 | { | 1259 | { |
1258 | GNUNET_SCHEDULER_cancel(stat_timeout_task); | 1260 | GNUNET_SCHEDULER_cancel (stat_timeout_task); |
1259 | stat_timeout_task = NULL; | 1261 | stat_timeout_task = NULL; |
1260 | } | 1262 | } |
1261 | plugin = load_plugin(); | 1263 | plugin = load_plugin (); |
1262 | if (NULL == plugin) | 1264 | if (NULL == plugin) |
1265 | { | ||
1266 | GNUNET_CONTAINER_bloomfilter_free (filter); | ||
1267 | filter = NULL; | ||
1268 | if (NULL != stats) | ||
1263 | { | 1269 | { |
1264 | GNUNET_CONTAINER_bloomfilter_free(filter); | 1270 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); |
1265 | filter = NULL; | 1271 | stats = NULL; |
1266 | if (NULL != stats) | ||
1267 | { | ||
1268 | GNUNET_STATISTICS_destroy(stats, GNUNET_YES); | ||
1269 | stats = NULL; | ||
1270 | } | ||
1271 | return; | ||
1272 | } | 1272 | } |
1273 | return; | ||
1274 | } | ||
1273 | 1275 | ||
1274 | if (GNUNET_NO == stats_worked) | 1276 | if (GNUNET_NO == stats_worked) |
1275 | { | 1277 | { |
1276 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1277 | "Failed to obtain value from statistics service, recomputing it\n"); | 1279 | "Failed to obtain value from statistics service, recomputing it\n"); |
1278 | plugin->api->estimate_size(plugin->api->cls, &payload); | 1280 | plugin->api->estimate_size (plugin->api->cls, &payload); |
1279 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1281 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1280 | _("New payload: %lld\n"), | 1282 | _ ("New payload: %lld\n"), |
1281 | (long long)payload); | 1283 | (long long) payload); |
1282 | } | 1284 | } |
1283 | 1285 | ||
1284 | if (GNUNET_YES == refresh_bf) | 1286 | if (GNUNET_YES == refresh_bf) |
1287 | { | ||
1288 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1289 | _ ("Rebuilding bloomfilter. Please be patient.\n")); | ||
1290 | if (NULL != plugin->api->get_keys) | ||
1285 | { | 1291 | { |
1286 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1292 | plugin->api->get_keys (plugin->api->cls, &add_key_to_bloomfilter, filter); |
1287 | _("Rebuilding bloomfilter. Please be patient.\n")); | 1293 | return; |
1288 | if (NULL != plugin->api->get_keys) | 1294 | } |
1289 | { | 1295 | else |
1290 | plugin->api->get_keys(plugin->api->cls, &add_key_to_bloomfilter, filter); | 1296 | { |
1291 | return; | 1297 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1292 | } | 1298 | _ ( |
1293 | else | 1299 | "Plugin does not support get_keys function. Please fix!\n")); |
1294 | { | ||
1295 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
1296 | _( | ||
1297 | "Plugin does not support get_keys function. Please fix!\n")); | ||
1298 | } | ||
1299 | } | 1300 | } |
1300 | begin_service(); | 1301 | } |
1302 | begin_service (); | ||
1301 | } | 1303 | } |
1302 | 1304 | ||
1303 | 1305 | ||
@@ -1307,11 +1309,11 @@ process_stat_done(void *cls, int success) | |||
1307 | * @param cls NULL | 1309 | * @param cls NULL |
1308 | */ | 1310 | */ |
1309 | static void | 1311 | static void |
1310 | stat_timeout(void *cls) | 1312 | stat_timeout (void *cls) |
1311 | { | 1313 | { |
1312 | stat_timeout_task = NULL; | 1314 | stat_timeout_task = NULL; |
1313 | GNUNET_STATISTICS_get_cancel(stat_get); | 1315 | GNUNET_STATISTICS_get_cancel (stat_get); |
1314 | process_stat_done(NULL, GNUNET_NO); | 1316 | process_stat_done (NULL, GNUNET_NO); |
1315 | } | 1317 | } |
1316 | 1318 | ||
1317 | 1319 | ||
@@ -1319,51 +1321,51 @@ stat_timeout(void *cls) | |||
1319 | * Task run during shutdown. | 1321 | * Task run during shutdown. |
1320 | */ | 1322 | */ |
1321 | static void | 1323 | static void |
1322 | cleaning_task(void *cls) | 1324 | cleaning_task (void *cls) |
1323 | { | 1325 | { |
1324 | cleaning_done = GNUNET_YES; | 1326 | cleaning_done = GNUNET_YES; |
1325 | if (NULL != expired_kill_task) | 1327 | if (NULL != expired_kill_task) |
1326 | { | 1328 | { |
1327 | GNUNET_SCHEDULER_cancel(expired_kill_task); | 1329 | GNUNET_SCHEDULER_cancel (expired_kill_task); |
1328 | expired_kill_task = NULL; | 1330 | expired_kill_task = NULL; |
1329 | } | 1331 | } |
1330 | if (GNUNET_YES == do_drop) | 1332 | if (GNUNET_YES == do_drop) |
1331 | { | 1333 | { |
1332 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Dropping database!\n"); | 1334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dropping database!\n"); |
1333 | plugin->api->drop(plugin->api->cls); | 1335 | plugin->api->drop (plugin->api->cls); |
1334 | payload = 0; | 1336 | payload = 0; |
1335 | last_sync++; | 1337 | last_sync++; |
1336 | } | 1338 | } |
1337 | if (NULL != plugin) | 1339 | if (NULL != plugin) |
1338 | { | 1340 | { |
1339 | unload_plugin(plugin); | 1341 | unload_plugin (plugin); |
1340 | plugin = NULL; | 1342 | plugin = NULL; |
1341 | } | 1343 | } |
1342 | if (NULL != filter) | 1344 | if (NULL != filter) |
1343 | { | 1345 | { |
1344 | GNUNET_CONTAINER_bloomfilter_free(filter); | 1346 | GNUNET_CONTAINER_bloomfilter_free (filter); |
1345 | filter = NULL; | 1347 | filter = NULL; |
1346 | } | 1348 | } |
1347 | if (NULL != stat_get) | 1349 | if (NULL != stat_get) |
1348 | { | 1350 | { |
1349 | GNUNET_STATISTICS_get_cancel(stat_get); | 1351 | GNUNET_STATISTICS_get_cancel (stat_get); |
1350 | stat_get = NULL; | 1352 | stat_get = NULL; |
1351 | } | 1353 | } |
1352 | if (NULL != stat_timeout_task) | 1354 | if (NULL != stat_timeout_task) |
1353 | { | 1355 | { |
1354 | GNUNET_SCHEDULER_cancel(stat_timeout_task); | 1356 | GNUNET_SCHEDULER_cancel (stat_timeout_task); |
1355 | stat_timeout_task = NULL; | 1357 | stat_timeout_task = NULL; |
1356 | } | 1358 | } |
1357 | GNUNET_free_non_null(plugin_name); | 1359 | GNUNET_free_non_null (plugin_name); |
1358 | plugin_name = NULL; | 1360 | plugin_name = NULL; |
1359 | if (last_sync > 0) | 1361 | if (last_sync > 0) |
1360 | sync_stats(); | 1362 | sync_stats (); |
1361 | if (NULL != stats) | 1363 | if (NULL != stats) |
1362 | { | 1364 | { |
1363 | GNUNET_STATISTICS_destroy(stats, GNUNET_YES); | 1365 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); |
1364 | stats = NULL; | 1366 | stats = NULL; |
1365 | } | 1367 | } |
1366 | GNUNET_free(quota_stat_name); | 1368 | GNUNET_free (quota_stat_name); |
1367 | quota_stat_name = NULL; | 1369 | quota_stat_name = NULL; |
1368 | } | 1370 | } |
1369 | 1371 | ||
@@ -1377,9 +1379,9 @@ cleaning_task(void *cls) | |||
1377 | * @return @a client | 1379 | * @return @a client |
1378 | */ | 1380 | */ |
1379 | static void * | 1381 | static void * |
1380 | client_connect_cb(void *cls, | 1382 | client_connect_cb (void *cls, |
1381 | struct GNUNET_SERVICE_Client *client, | 1383 | struct GNUNET_SERVICE_Client *client, |
1382 | struct GNUNET_MQ_Handle *mq) | 1384 | struct GNUNET_MQ_Handle *mq) |
1383 | { | 1385 | { |
1384 | return client; | 1386 | return client; |
1385 | } | 1387 | } |
@@ -1394,39 +1396,39 @@ client_connect_cb(void *cls, | |||
1394 | * @param app_ctx must match @a client | 1396 | * @param app_ctx must match @a client |
1395 | */ | 1397 | */ |
1396 | static void | 1398 | static void |
1397 | client_disconnect_cb(void *cls, | 1399 | client_disconnect_cb (void *cls, |
1398 | struct GNUNET_SERVICE_Client *client, | 1400 | struct GNUNET_SERVICE_Client *client, |
1399 | void *app_ctx) | 1401 | void *app_ctx) |
1400 | { | 1402 | { |
1401 | struct ReservationList *pos; | 1403 | struct ReservationList *pos; |
1402 | struct ReservationList *prev; | 1404 | struct ReservationList *prev; |
1403 | struct ReservationList *next; | 1405 | struct ReservationList *next; |
1404 | 1406 | ||
1405 | GNUNET_assert(app_ctx == client); | 1407 | GNUNET_assert (app_ctx == client); |
1406 | prev = NULL; | 1408 | prev = NULL; |
1407 | pos = reservations; | 1409 | pos = reservations; |
1408 | while (NULL != pos) | 1410 | while (NULL != pos) |
1411 | { | ||
1412 | next = pos->next; | ||
1413 | if (pos->client == client) | ||
1409 | { | 1414 | { |
1410 | next = pos->next; | 1415 | if (NULL == prev) |
1411 | if (pos->client == client) | 1416 | reservations = next; |
1412 | { | ||
1413 | if (NULL == prev) | ||
1414 | reservations = next; | ||
1415 | else | ||
1416 | prev->next = next; | ||
1417 | reserved -= pos->amount + pos->entries * GNUNET_DATASTORE_ENTRY_OVERHEAD; | ||
1418 | GNUNET_free(pos); | ||
1419 | } | ||
1420 | else | 1417 | else |
1421 | { | 1418 | prev->next = next; |
1422 | prev = pos; | 1419 | reserved -= pos->amount + pos->entries * GNUNET_DATASTORE_ENTRY_OVERHEAD; |
1423 | } | 1420 | GNUNET_free (pos); |
1424 | pos = next; | ||
1425 | } | 1421 | } |
1426 | GNUNET_STATISTICS_set(stats, | 1422 | else |
1427 | gettext_noop("# reserved"), | 1423 | { |
1428 | reserved, | 1424 | prev = pos; |
1429 | GNUNET_NO); | 1425 | } |
1426 | pos = next; | ||
1427 | } | ||
1428 | GNUNET_STATISTICS_set (stats, | ||
1429 | gettext_noop ("# reserved"), | ||
1430 | reserved, | ||
1431 | GNUNET_NO); | ||
1430 | } | 1432 | } |
1431 | 1433 | ||
1432 | 1434 | ||
@@ -1438,9 +1440,9 @@ client_disconnect_cb(void *cls, | |||
1438 | * @param c configuration to use | 1440 | * @param c configuration to use |
1439 | */ | 1441 | */ |
1440 | static void | 1442 | static void |
1441 | run(void *cls, | 1443 | run (void *cls, |
1442 | const struct GNUNET_CONFIGURATION_Handle *c, | 1444 | const struct GNUNET_CONFIGURATION_Handle *c, |
1443 | struct GNUNET_SERVICE_Handle *serv) | 1445 | struct GNUNET_SERVICE_Handle *serv) |
1444 | { | 1446 | { |
1445 | char *fn; | 1447 | char *fn; |
1446 | char *pfn; | 1448 | char *pfn; |
@@ -1448,199 +1450,199 @@ run(void *cls, | |||
1448 | 1450 | ||
1449 | service = serv; | 1451 | service = serv; |
1450 | cfg = c; | 1452 | cfg = c; |
1451 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, | 1453 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, |
1452 | "DATASTORE", | 1454 | "DATASTORE", |
1453 | "DATABASE", | 1455 | "DATABASE", |
1454 | &plugin_name)) | 1456 | &plugin_name)) |
1455 | { | 1457 | { |
1456 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, | 1458 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
1457 | "DATABASE", | 1459 | "DATABASE", |
1458 | "DATASTORE"); | 1460 | "DATASTORE"); |
1459 | return; | 1461 | return; |
1460 | } | 1462 | } |
1461 | GNUNET_asprintf("a_stat_name, | 1463 | GNUNET_asprintf ("a_stat_name, |
1462 | _("# bytes used in file-sharing datastore `%s'"), | 1464 | _ ("# bytes used in file-sharing datastore `%s'"), |
1463 | plugin_name); | 1465 | plugin_name); |
1464 | if (GNUNET_OK != | 1466 | if (GNUNET_OK != |
1465 | GNUNET_CONFIGURATION_get_value_size(cfg, "DATASTORE", "QUOTA", "a)) | 1467 | GNUNET_CONFIGURATION_get_value_size (cfg, "DATASTORE", "QUOTA", "a)) |
1466 | { | 1468 | { |
1467 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, "QUOTA", "DATASTORE"); | 1469 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "QUOTA", "DATASTORE"); |
1468 | return; | 1470 | return; |
1469 | } | 1471 | } |
1470 | stats = GNUNET_STATISTICS_create("datastore", cfg); | 1472 | stats = GNUNET_STATISTICS_create ("datastore", cfg); |
1471 | GNUNET_STATISTICS_set(stats, gettext_noop("# quota"), quota, GNUNET_NO); | 1473 | GNUNET_STATISTICS_set (stats, gettext_noop ("# quota"), quota, GNUNET_NO); |
1472 | cache_size = quota / 8; /* Or should we make this an option? */ | 1474 | cache_size = quota / 8; /* Or should we make this an option? */ |
1473 | GNUNET_STATISTICS_set(stats, | 1475 | GNUNET_STATISTICS_set (stats, |
1474 | gettext_noop("# cache size"), | 1476 | gettext_noop ("# cache size"), |
1475 | cache_size, | 1477 | cache_size, |
1476 | GNUNET_NO); | 1478 | GNUNET_NO); |
1477 | if (quota / (32 * 1024LL) > MAX_BF_SIZE) | 1479 | if (quota / (32 * 1024LL) > MAX_BF_SIZE) |
1478 | bf_size = MAX_BF_SIZE; | 1480 | bf_size = MAX_BF_SIZE; |
1479 | else | 1481 | else |
1480 | bf_size = | 1482 | bf_size = |
1481 | quota / (32 * 1024LL); /* 8 bit per entry, 1 bit per 32 kb in DB */ | 1483 | quota / (32 * 1024LL); /* 8 bit per entry, 1 bit per 32 kb in DB */ |
1482 | fn = NULL; | 1484 | fn = NULL; |
1483 | if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(cfg, | 1485 | if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, |
1484 | "DATASTORE", | 1486 | "DATASTORE", |
1485 | "BLOOMFILTER", | 1487 | "BLOOMFILTER", |
1486 | &fn)) || | 1488 | &fn)) || |
1487 | (GNUNET_OK != GNUNET_DISK_directory_create_for_file(fn))) | 1489 | (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn))) |
1488 | { | 1490 | { |
1489 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1491 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1490 | _("Could not use specified filename `%s' for bloomfilter.\n"), | 1492 | _ ("Could not use specified filename `%s' for bloomfilter.\n"), |
1491 | NULL != fn ? fn : ""); | 1493 | NULL != fn ? fn : ""); |
1492 | GNUNET_free_non_null(fn); | 1494 | GNUNET_free_non_null (fn); |
1493 | fn = NULL; | 1495 | fn = NULL; |
1494 | } | 1496 | } |
1495 | if (NULL != fn) | 1497 | if (NULL != fn) |
1498 | { | ||
1499 | GNUNET_asprintf (&pfn, "%s.%s", fn, plugin_name); | ||
1500 | if (GNUNET_YES == GNUNET_DISK_file_test (pfn)) | ||
1496 | { | 1501 | { |
1497 | GNUNET_asprintf(&pfn, "%s.%s", fn, plugin_name); | 1502 | filter = |
1498 | if (GNUNET_YES == GNUNET_DISK_file_test(pfn)) | 1503 | GNUNET_CONTAINER_bloomfilter_load (pfn, |
1504 | bf_size, | ||
1505 | 5); /* approx. 3% false positives at max use */ | ||
1506 | if (NULL == filter) | ||
1507 | { | ||
1508 | /* file exists but not valid, remove and try again, but refresh */ | ||
1509 | if (0 != unlink (pfn)) | ||
1499 | { | 1510 | { |
1500 | filter = | 1511 | /* failed to remove, run without file */ |
1501 | GNUNET_CONTAINER_bloomfilter_load(pfn, | 1512 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1502 | bf_size, | 1513 | _ ("Failed to remove bogus bloomfilter file `%s'\n"), |
1503 | 5); /* approx. 3% false positives at max use */ | 1514 | pfn); |
1504 | if (NULL == filter) | 1515 | GNUNET_free (pfn); |
1505 | { | 1516 | pfn = NULL; |
1506 | /* file exists but not valid, remove and try again, but refresh */ | 1517 | filter = GNUNET_CONTAINER_bloomfilter_load ( |
1507 | if (0 != unlink(pfn)) | 1518 | NULL, |
1508 | { | 1519 | bf_size, |
1509 | /* failed to remove, run without file */ | 1520 | 5); /* approx. 3% false positives at max use */ |
1510 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1521 | refresh_bf = GNUNET_YES; |
1511 | _("Failed to remove bogus bloomfilter file `%s'\n"), | ||
1512 | pfn); | ||
1513 | GNUNET_free(pfn); | ||
1514 | pfn = NULL; | ||
1515 | filter = GNUNET_CONTAINER_bloomfilter_load( | ||
1516 | NULL, | ||
1517 | bf_size, | ||
1518 | 5); /* approx. 3% false positives at max use */ | ||
1519 | refresh_bf = GNUNET_YES; | ||
1520 | } | ||
1521 | else | ||
1522 | { | ||
1523 | /* try again after remove */ | ||
1524 | filter = GNUNET_CONTAINER_bloomfilter_load( | ||
1525 | pfn, | ||
1526 | bf_size, | ||
1527 | 5); /* approx. 3% false positives at max use */ | ||
1528 | refresh_bf = GNUNET_YES; | ||
1529 | if (NULL == filter) | ||
1530 | { | ||
1531 | /* failed yet again, give up on using file */ | ||
1532 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
1533 | _("Failed to remove bogus bloomfilter file `%s'\n"), | ||
1534 | pfn); | ||
1535 | GNUNET_free(pfn); | ||
1536 | pfn = NULL; | ||
1537 | filter = GNUNET_CONTAINER_bloomfilter_init( | ||
1538 | NULL, | ||
1539 | bf_size, | ||
1540 | 5); /* approx. 3% false positives at max use */ | ||
1541 | } | ||
1542 | } | ||
1543 | } | ||
1544 | else | ||
1545 | { | ||
1546 | /* normal case: have an existing valid bf file, no need to refresh */ | ||
1547 | refresh_bf = GNUNET_NO; | ||
1548 | } | ||
1549 | } | 1522 | } |
1550 | else | 1523 | else |
1551 | { | 1524 | { |
1552 | filter = | 1525 | /* try again after remove */ |
1553 | GNUNET_CONTAINER_bloomfilter_load(pfn, | 1526 | filter = GNUNET_CONTAINER_bloomfilter_load ( |
1554 | bf_size, | 1527 | pfn, |
1555 | 5); /* approx. 3% false positives at max use */ | 1528 | bf_size, |
1529 | 5); /* approx. 3% false positives at max use */ | ||
1556 | refresh_bf = GNUNET_YES; | 1530 | refresh_bf = GNUNET_YES; |
1531 | if (NULL == filter) | ||
1532 | { | ||
1533 | /* failed yet again, give up on using file */ | ||
1534 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1535 | _ ("Failed to remove bogus bloomfilter file `%s'\n"), | ||
1536 | pfn); | ||
1537 | GNUNET_free (pfn); | ||
1538 | pfn = NULL; | ||
1539 | filter = GNUNET_CONTAINER_bloomfilter_init ( | ||
1540 | NULL, | ||
1541 | bf_size, | ||
1542 | 5); /* approx. 3% false positives at max use */ | ||
1543 | } | ||
1557 | } | 1544 | } |
1558 | GNUNET_free(pfn); | 1545 | } |
1546 | else | ||
1547 | { | ||
1548 | /* normal case: have an existing valid bf file, no need to refresh */ | ||
1549 | refresh_bf = GNUNET_NO; | ||
1550 | } | ||
1559 | } | 1551 | } |
1560 | else | 1552 | else |
1561 | { | 1553 | { |
1562 | filter = | 1554 | filter = |
1563 | GNUNET_CONTAINER_bloomfilter_init(NULL, | 1555 | GNUNET_CONTAINER_bloomfilter_load (pfn, |
1564 | bf_size, | 1556 | bf_size, |
1565 | 5); /* approx. 3% false positives at max use */ | 1557 | 5); /* approx. 3% false positives at max use */ |
1566 | refresh_bf = GNUNET_YES; | 1558 | refresh_bf = GNUNET_YES; |
1567 | } | 1559 | } |
1568 | GNUNET_free_non_null(fn); | 1560 | GNUNET_free (pfn); |
1561 | } | ||
1562 | else | ||
1563 | { | ||
1564 | filter = | ||
1565 | GNUNET_CONTAINER_bloomfilter_init (NULL, | ||
1566 | bf_size, | ||
1567 | 5); /* approx. 3% false positives at max use */ | ||
1568 | refresh_bf = GNUNET_YES; | ||
1569 | } | ||
1570 | GNUNET_free_non_null (fn); | ||
1569 | if (NULL == filter) | 1571 | if (NULL == filter) |
1572 | { | ||
1573 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1574 | _ ("Failed to initialize bloomfilter.\n")); | ||
1575 | if (NULL != stats) | ||
1570 | { | 1576 | { |
1571 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1577 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); |
1572 | _("Failed to initialize bloomfilter.\n")); | 1578 | stats = NULL; |
1573 | if (NULL != stats) | ||
1574 | { | ||
1575 | GNUNET_STATISTICS_destroy(stats, GNUNET_YES); | ||
1576 | stats = NULL; | ||
1577 | } | ||
1578 | return; | ||
1579 | } | 1579 | } |
1580 | GNUNET_SERVICE_suspend(service); | 1580 | return; |
1581 | stat_get = GNUNET_STATISTICS_get(stats, | 1581 | } |
1582 | "datastore", | 1582 | GNUNET_SERVICE_suspend (service); |
1583 | quota_stat_name, | 1583 | stat_get = GNUNET_STATISTICS_get (stats, |
1584 | &process_stat_done, | 1584 | "datastore", |
1585 | &process_stat_in, | 1585 | quota_stat_name, |
1586 | NULL); | 1586 | &process_stat_done, |
1587 | &process_stat_in, | ||
1588 | NULL); | ||
1587 | if (NULL == stat_get) | 1589 | if (NULL == stat_get) |
1588 | process_stat_done(NULL, GNUNET_SYSERR); | 1590 | process_stat_done (NULL, GNUNET_SYSERR); |
1589 | else | 1591 | else |
1590 | stat_timeout_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, | 1592 | stat_timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
1591 | &stat_timeout, | 1593 | &stat_timeout, |
1592 | NULL); | 1594 | NULL); |
1593 | GNUNET_SCHEDULER_add_shutdown(&cleaning_task, NULL); | 1595 | GNUNET_SCHEDULER_add_shutdown (&cleaning_task, NULL); |
1594 | } | 1596 | } |
1595 | 1597 | ||
1596 | 1598 | ||
1597 | /** | 1599 | /** |
1598 | * Define "main" method using service macro. | 1600 | * Define "main" method using service macro. |
1599 | */ | 1601 | */ |
1600 | GNUNET_SERVICE_MAIN( | 1602 | GNUNET_SERVICE_MAIN ( |
1601 | "datastore", | 1603 | "datastore", |
1602 | GNUNET_SERVICE_OPTION_NONE, | 1604 | GNUNET_SERVICE_OPTION_NONE, |
1603 | &run, | 1605 | &run, |
1604 | &client_connect_cb, | 1606 | &client_connect_cb, |
1605 | &client_disconnect_cb, | 1607 | &client_disconnect_cb, |
1606 | NULL, | 1608 | NULL, |
1607 | GNUNET_MQ_hd_fixed_size(reserve, | 1609 | GNUNET_MQ_hd_fixed_size (reserve, |
1608 | GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE, | 1610 | GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE, |
1609 | struct ReserveMessage, | 1611 | struct ReserveMessage, |
1610 | NULL), | 1612 | NULL), |
1611 | GNUNET_MQ_hd_fixed_size(release_reserve, | 1613 | GNUNET_MQ_hd_fixed_size (release_reserve, |
1612 | GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE, | 1614 | GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE, |
1613 | struct ReleaseReserveMessage, | 1615 | struct ReleaseReserveMessage, |
1614 | NULL), | 1616 | NULL), |
1615 | GNUNET_MQ_hd_var_size(put, | 1617 | GNUNET_MQ_hd_var_size (put, |
1616 | GNUNET_MESSAGE_TYPE_DATASTORE_PUT, | 1618 | GNUNET_MESSAGE_TYPE_DATASTORE_PUT, |
1617 | struct DataMessage, | 1619 | struct DataMessage, |
1618 | NULL), | 1620 | NULL), |
1619 | GNUNET_MQ_hd_fixed_size(get, | 1621 | GNUNET_MQ_hd_fixed_size (get, |
1620 | GNUNET_MESSAGE_TYPE_DATASTORE_GET, | 1622 | GNUNET_MESSAGE_TYPE_DATASTORE_GET, |
1621 | struct GetMessage, | 1623 | struct GetMessage, |
1622 | NULL), | 1624 | NULL), |
1623 | GNUNET_MQ_hd_fixed_size(get_key, | 1625 | GNUNET_MQ_hd_fixed_size (get_key, |
1624 | GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY, | 1626 | GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY, |
1625 | struct GetKeyMessage, | 1627 | struct GetKeyMessage, |
1626 | NULL), | 1628 | NULL), |
1627 | GNUNET_MQ_hd_fixed_size(get_replication, | 1629 | GNUNET_MQ_hd_fixed_size (get_replication, |
1628 | GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION, | 1630 | GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION, |
1629 | struct GNUNET_MessageHeader, | 1631 | struct GNUNET_MessageHeader, |
1630 | NULL), | 1632 | NULL), |
1631 | GNUNET_MQ_hd_fixed_size(get_zero_anonymity, | 1633 | GNUNET_MQ_hd_fixed_size (get_zero_anonymity, |
1632 | GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, | 1634 | GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, |
1633 | struct GetZeroAnonymityMessage, | 1635 | struct GetZeroAnonymityMessage, |
1634 | NULL), | 1636 | NULL), |
1635 | GNUNET_MQ_hd_var_size(remove, | 1637 | GNUNET_MQ_hd_var_size (remove, |
1636 | GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, | 1638 | GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, |
1637 | struct DataMessage, | 1639 | struct DataMessage, |
1638 | NULL), | 1640 | NULL), |
1639 | GNUNET_MQ_hd_fixed_size(drop, | 1641 | GNUNET_MQ_hd_fixed_size (drop, |
1640 | GNUNET_MESSAGE_TYPE_DATASTORE_DROP, | 1642 | GNUNET_MESSAGE_TYPE_DATASTORE_DROP, |
1641 | struct GNUNET_MessageHeader, | 1643 | struct GNUNET_MessageHeader, |
1642 | NULL), | 1644 | NULL), |
1643 | GNUNET_MQ_handler_end()); | 1645 | GNUNET_MQ_handler_end ()); |
1644 | 1646 | ||
1645 | 1647 | ||
1646 | /* end of gnunet-service-datastore.c */ | 1648 | /* end of gnunet-service-datastore.c */ |