diff options
Diffstat (limited to 'src/fs/gnunet-service-fs.c')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 1118 |
1 files changed, 566 insertions, 552 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 70aff8a75..40b3f6c1d 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -59,7 +59,8 @@ | |||
59 | * time interval, remaining cover traffic counters are | 59 | * time interval, remaining cover traffic counters are |
60 | * decremented by 1/16th. | 60 | * decremented by 1/16th. |
61 | */ | 61 | */ |
62 | #define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) | 62 | #define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply ( \ |
63 | GNUNET_TIME_UNIT_SECONDS, 5) | ||
63 | 64 | ||
64 | /** | 65 | /** |
65 | * Collect an instane number of statistics? May cause excessive IPC. | 66 | * Collect an instane number of statistics? May cause excessive IPC. |
@@ -72,7 +73,8 @@ | |||
72 | * Doubly-linked list of requests we are performing | 73 | * Doubly-linked list of requests we are performing |
73 | * on behalf of the same client. | 74 | * on behalf of the same client. |
74 | */ | 75 | */ |
75 | struct ClientRequest { | 76 | struct ClientRequest |
77 | { | ||
76 | /** | 78 | /** |
77 | * This is a doubly-linked list. | 79 | * This is a doubly-linked list. |
78 | */ | 80 | */ |
@@ -96,7 +98,7 @@ struct ClientRequest { | |||
96 | /** | 98 | /** |
97 | * Task scheduled to destroy the request. | 99 | * Task scheduled to destroy the request. |
98 | */ | 100 | */ |
99 | struct GNUNET_SCHEDULER_Task * kill_task; | 101 | struct GNUNET_SCHEDULER_Task *kill_task; |
100 | }; | 102 | }; |
101 | 103 | ||
102 | 104 | ||
@@ -104,7 +106,8 @@ struct ClientRequest { | |||
104 | * Replies to be transmitted to the client. The actual | 106 | * Replies to be transmitted to the client. The actual |
105 | * response message is allocated after this struct. | 107 | * response message is allocated after this struct. |
106 | */ | 108 | */ |
107 | struct ClientResponse { | 109 | struct ClientResponse |
110 | { | ||
108 | /** | 111 | /** |
109 | * This is a doubly-linked list. | 112 | * This is a doubly-linked list. |
110 | */ | 113 | */ |
@@ -131,7 +134,8 @@ struct ClientResponse { | |||
131 | * Information we track while handling an index | 134 | * Information we track while handling an index |
132 | * start request from a client. | 135 | * start request from a client. |
133 | */ | 136 | */ |
134 | struct IndexStartContext { | 137 | struct IndexStartContext |
138 | { | ||
135 | /** | 139 | /** |
136 | * This is a doubly linked list. | 140 | * This is a doubly linked list. |
137 | */ | 141 | */ |
@@ -167,7 +171,8 @@ struct IndexStartContext { | |||
167 | /** | 171 | /** |
168 | * A local client. | 172 | * A local client. |
169 | */ | 173 | */ |
170 | struct GSF_LocalClient { | 174 | struct GSF_LocalClient |
175 | { | ||
171 | /** | 176 | /** |
172 | * ID of the client. | 177 | * ID of the client. |
173 | */ | 178 | */ |
@@ -316,7 +321,7 @@ static struct GNUNET_CRYPTO_EddsaPrivateKey *pk; | |||
316 | /** | 321 | /** |
317 | * ID of our task that we use to age the cover counters. | 322 | * ID of our task that we use to age the cover counters. |
318 | */ | 323 | */ |
319 | static struct GNUNET_SCHEDULER_Task * cover_age_task; | 324 | static struct GNUNET_SCHEDULER_Task *cover_age_task; |
320 | 325 | ||
321 | /** | 326 | /** |
322 | * Datastore 'GET' load tracking. | 327 | * Datastore 'GET' load tracking. |
@@ -333,13 +338,13 @@ static struct GNUNET_LOAD_Value *datastore_get_load; | |||
333 | * @return handle to local client entry | 338 | * @return handle to local client entry |
334 | */ | 339 | */ |
335 | static void * | 340 | static void * |
336 | client_connect_cb(void *cls, | 341 | client_connect_cb (void *cls, |
337 | struct GNUNET_SERVICE_Client *client, | 342 | struct GNUNET_SERVICE_Client *client, |
338 | struct GNUNET_MQ_Handle *mq) | 343 | struct GNUNET_MQ_Handle *mq) |
339 | { | 344 | { |
340 | struct GSF_LocalClient *pos; | 345 | struct GSF_LocalClient *pos; |
341 | 346 | ||
342 | pos = GNUNET_new(struct GSF_LocalClient); | 347 | pos = GNUNET_new (struct GSF_LocalClient); |
343 | pos->client = client; | 348 | pos->client = client; |
344 | pos->mq = mq; | 349 | pos->mq = mq; |
345 | return pos; | 350 | return pos; |
@@ -352,22 +357,22 @@ client_connect_cb(void *cls, | |||
352 | * @param cls the client request to free | 357 | * @param cls the client request to free |
353 | */ | 358 | */ |
354 | static void | 359 | static void |
355 | client_request_destroy(void *cls) | 360 | client_request_destroy (void *cls) |
356 | { | 361 | { |
357 | struct ClientRequest *cr = cls; | 362 | struct ClientRequest *cr = cls; |
358 | struct GSF_LocalClient *lc = cr->lc; | 363 | struct GSF_LocalClient *lc = cr->lc; |
359 | 364 | ||
360 | cr->kill_task = NULL; | 365 | cr->kill_task = NULL; |
361 | GNUNET_CONTAINER_DLL_remove(lc->cr_head, | 366 | GNUNET_CONTAINER_DLL_remove (lc->cr_head, |
362 | lc->cr_tail, | 367 | lc->cr_tail, |
363 | cr); | 368 | cr); |
364 | GSF_pending_request_cancel_(cr->pr, | 369 | GSF_pending_request_cancel_ (cr->pr, |
365 | GNUNET_YES); | 370 | GNUNET_YES); |
366 | GNUNET_STATISTICS_update(GSF_stats, | 371 | GNUNET_STATISTICS_update (GSF_stats, |
367 | gettext_noop("# client searches active"), | 372 | gettext_noop ("# client searches active"), |
368 | -1, | 373 | -1, |
369 | GNUNET_NO); | 374 | GNUNET_NO); |
370 | GNUNET_free(cr); | 375 | GNUNET_free (cr); |
371 | } | 376 | } |
372 | 377 | ||
373 | 378 | ||
@@ -390,15 +395,15 @@ client_request_destroy(void *cls) | |||
390 | * @param data_len number of bytes in @a data | 395 | * @param data_len number of bytes in @a data |
391 | */ | 396 | */ |
392 | static void | 397 | static void |
393 | client_response_handler(void *cls, | 398 | client_response_handler (void *cls, |
394 | enum GNUNET_BLOCK_EvaluationResult eval, | 399 | enum GNUNET_BLOCK_EvaluationResult eval, |
395 | struct GSF_PendingRequest *pr, | 400 | struct GSF_PendingRequest *pr, |
396 | uint32_t reply_anonymity_level, | 401 | uint32_t reply_anonymity_level, |
397 | struct GNUNET_TIME_Absolute expiration, | 402 | struct GNUNET_TIME_Absolute expiration, |
398 | struct GNUNET_TIME_Absolute last_transmission, | 403 | struct GNUNET_TIME_Absolute last_transmission, |
399 | enum GNUNET_BLOCK_Type type, | 404 | enum GNUNET_BLOCK_Type type, |
400 | const void *data, | 405 | const void *data, |
401 | size_t data_len) | 406 | size_t data_len) |
402 | { | 407 | { |
403 | struct ClientRequest *cr = cls; | 408 | struct ClientRequest *cr = cls; |
404 | struct GSF_LocalClient *lc; | 409 | struct GSF_LocalClient *lc; |
@@ -407,52 +412,52 @@ client_response_handler(void *cls, | |||
407 | const struct GSF_PendingRequestData *prd; | 412 | const struct GSF_PendingRequestData *prd; |
408 | 413 | ||
409 | if (NULL == data) | 414 | if (NULL == data) |
410 | { | 415 | { |
411 | /* local-only request, with no result, clean up. */ | 416 | /* local-only request, with no result, clean up. */ |
412 | if (NULL == cr->kill_task) | 417 | if (NULL == cr->kill_task) |
413 | cr->kill_task = GNUNET_SCHEDULER_add_now(&client_request_destroy, | 418 | cr->kill_task = GNUNET_SCHEDULER_add_now (&client_request_destroy, |
414 | cr); | 419 | cr); |
415 | return; | 420 | return; |
416 | } | 421 | } |
417 | prd = GSF_pending_request_get_data_(pr); | 422 | prd = GSF_pending_request_get_data_ (pr); |
418 | GNUNET_break(type != GNUNET_BLOCK_TYPE_ANY); | 423 | GNUNET_break (type != GNUNET_BLOCK_TYPE_ANY); |
419 | if ((prd->type != type) && (prd->type != GNUNET_BLOCK_TYPE_ANY)) | 424 | if ((prd->type != type) && (prd->type != GNUNET_BLOCK_TYPE_ANY)) |
420 | { | 425 | { |
421 | GNUNET_break(0); | 426 | GNUNET_break (0); |
422 | return; | 427 | return; |
423 | } | 428 | } |
424 | GNUNET_STATISTICS_update(GSF_stats, | 429 | GNUNET_STATISTICS_update (GSF_stats, |
425 | gettext_noop | 430 | gettext_noop |
426 | ("# replies received for local clients"), 1, | 431 | ("# replies received for local clients"), 1, |
427 | GNUNET_NO); | 432 | GNUNET_NO); |
428 | GNUNET_assert(pr == cr->pr); | 433 | GNUNET_assert (pr == cr->pr); |
429 | lc = cr->lc; | 434 | lc = cr->lc; |
430 | env = GNUNET_MQ_msg_extra(pm, | 435 | env = GNUNET_MQ_msg_extra (pm, |
431 | data_len, | 436 | data_len, |
432 | GNUNET_MESSAGE_TYPE_FS_PUT); | 437 | GNUNET_MESSAGE_TYPE_FS_PUT); |
433 | pm->type = htonl(type); | 438 | pm->type = htonl (type); |
434 | pm->expiration = GNUNET_TIME_absolute_hton(expiration); | 439 | pm->expiration = GNUNET_TIME_absolute_hton (expiration); |
435 | pm->last_transmission = GNUNET_TIME_absolute_hton(last_transmission); | 440 | pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission); |
436 | pm->num_transmissions = htonl(prd->num_transmissions); | 441 | pm->num_transmissions = htonl (prd->num_transmissions); |
437 | pm->respect_offered = htonl(prd->respect_offered); | 442 | pm->respect_offered = htonl (prd->respect_offered); |
438 | GNUNET_memcpy(&pm[1], | 443 | GNUNET_memcpy (&pm[1], |
439 | data, | 444 | data, |
440 | data_len); | 445 | data_len); |
441 | GNUNET_MQ_send(lc->mq, | 446 | GNUNET_MQ_send (lc->mq, |
442 | env); | 447 | env); |
443 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 448 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
444 | "Queued reply to query `%s' for local client\n", | 449 | "Queued reply to query `%s' for local client\n", |
445 | GNUNET_h2s(&prd->query)); | 450 | GNUNET_h2s (&prd->query)); |
446 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != eval) | 451 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != eval) |
447 | { | 452 | { |
448 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
449 | "Evaluation %d - keeping query alive\n", | 454 | "Evaluation %d - keeping query alive\n", |
450 | (int)eval); | 455 | (int) eval); |
451 | return; | 456 | return; |
452 | } | 457 | } |
453 | if (NULL == cr->kill_task) | 458 | if (NULL == cr->kill_task) |
454 | cr->kill_task = GNUNET_SCHEDULER_add_now(&client_request_destroy, | 459 | cr->kill_task = GNUNET_SCHEDULER_add_now (&client_request_destroy, |
455 | cr); | 460 | cr); |
456 | } | 461 | } |
457 | 462 | ||
458 | 463 | ||
@@ -465,9 +470,9 @@ client_response_handler(void *cls, | |||
465 | * @param app_ctx the `struct GSF_LocalClient` | 470 | * @param app_ctx the `struct GSF_LocalClient` |
466 | */ | 471 | */ |
467 | static void | 472 | static void |
468 | client_disconnect_cb(void *cls, | 473 | client_disconnect_cb (void *cls, |
469 | struct GNUNET_SERVICE_Client *client, | 474 | struct GNUNET_SERVICE_Client *client, |
470 | void *app_ctx) | 475 | void *app_ctx) |
471 | { | 476 | { |
472 | struct GSF_LocalClient *lc = app_ctx; | 477 | struct GSF_LocalClient *lc = app_ctx; |
473 | struct IndexStartContext *isc; | 478 | struct IndexStartContext *isc; |
@@ -475,27 +480,27 @@ client_disconnect_cb(void *cls, | |||
475 | struct ClientResponse *res; | 480 | struct ClientResponse *res; |
476 | 481 | ||
477 | while (NULL != (cr = lc->cr_head)) | 482 | while (NULL != (cr = lc->cr_head)) |
478 | { | 483 | { |
479 | if (NULL != cr->kill_task) | 484 | if (NULL != cr->kill_task) |
480 | GNUNET_SCHEDULER_cancel(cr->kill_task); | 485 | GNUNET_SCHEDULER_cancel (cr->kill_task); |
481 | client_request_destroy(cr); | 486 | client_request_destroy (cr); |
482 | } | 487 | } |
483 | while (NULL != (res = lc->res_head)) | 488 | while (NULL != (res = lc->res_head)) |
484 | { | 489 | { |
485 | GNUNET_CONTAINER_DLL_remove(lc->res_head, | 490 | GNUNET_CONTAINER_DLL_remove (lc->res_head, |
486 | lc->res_tail, | 491 | lc->res_tail, |
487 | res); | 492 | res); |
488 | GNUNET_free(res); | 493 | GNUNET_free (res); |
489 | } | 494 | } |
490 | while (NULL != (isc = lc->isc_head)) | 495 | while (NULL != (isc = lc->isc_head)) |
491 | { | 496 | { |
492 | GNUNET_CONTAINER_DLL_remove(lc->isc_head, | 497 | GNUNET_CONTAINER_DLL_remove (lc->isc_head, |
493 | lc->isc_tail, | 498 | lc->isc_tail, |
494 | isc); | 499 | isc); |
495 | GNUNET_CRYPTO_hash_file_cancel(isc->fhc); | 500 | GNUNET_CRYPTO_hash_file_cancel (isc->fhc); |
496 | GNUNET_free(isc); | 501 | GNUNET_free (isc); |
497 | } | 502 | } |
498 | GNUNET_free(lc); | 503 | GNUNET_free (lc); |
499 | } | 504 | } |
500 | 505 | ||
501 | 506 | ||
@@ -508,14 +513,14 @@ client_disconnect_cb(void *cls, | |||
508 | * @param cls unused closure | 513 | * @param cls unused closure |
509 | */ | 514 | */ |
510 | static void | 515 | static void |
511 | age_cover_counters(void *cls) | 516 | age_cover_counters (void *cls) |
512 | { | 517 | { |
513 | GSF_cover_content_count = (GSF_cover_content_count * 15) / 16; | 518 | GSF_cover_content_count = (GSF_cover_content_count * 15) / 16; |
514 | GSF_cover_query_count = (GSF_cover_query_count * 15) / 16; | 519 | GSF_cover_query_count = (GSF_cover_query_count * 15) / 16; |
515 | cover_age_task = | 520 | cover_age_task = |
516 | GNUNET_SCHEDULER_add_delayed(COVER_AGE_FREQUENCY, | 521 | GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, |
517 | &age_cover_counters, | 522 | &age_cover_counters, |
518 | NULL); | 523 | NULL); |
519 | } | 524 | } |
520 | 525 | ||
521 | 526 | ||
@@ -526,12 +531,12 @@ age_cover_counters(void *cls) | |||
526 | * @param start time when the datastore request was issued | 531 | * @param start time when the datastore request was issued |
527 | */ | 532 | */ |
528 | void | 533 | void |
529 | GSF_update_datastore_delay_(struct GNUNET_TIME_Absolute start) | 534 | GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start) |
530 | { | 535 | { |
531 | struct GNUNET_TIME_Relative delay; | 536 | struct GNUNET_TIME_Relative delay; |
532 | 537 | ||
533 | delay = GNUNET_TIME_absolute_get_duration(start); | 538 | delay = GNUNET_TIME_absolute_get_duration (start); |
534 | GNUNET_LOAD_update(datastore_get_load, delay.rel_value_us); | 539 | GNUNET_LOAD_update (datastore_get_load, delay.rel_value_us); |
535 | } | 540 | } |
536 | 541 | ||
537 | 542 | ||
@@ -546,11 +551,11 @@ GSF_update_datastore_delay_(struct GNUNET_TIME_Absolute start) | |||
546 | * #GNUNET_SYSERR to process for free (load low) | 551 | * #GNUNET_SYSERR to process for free (load low) |
547 | */ | 552 | */ |
548 | int | 553 | int |
549 | GSF_test_get_load_too_high_(uint32_t priority) | 554 | GSF_test_get_load_too_high_ (uint32_t priority) |
550 | { | 555 | { |
551 | double ld; | 556 | double ld; |
552 | 557 | ||
553 | ld = GNUNET_LOAD_get_load(datastore_get_load); | 558 | ld = GNUNET_LOAD_get_load (datastore_get_load); |
554 | if (ld < 1) | 559 | if (ld < 1) |
555 | return GNUNET_SYSERR; | 560 | return GNUNET_SYSERR; |
556 | if (ld <= priority) | 561 | if (ld <= priority) |
@@ -571,30 +576,30 @@ GSF_test_get_load_too_high_(uint32_t priority) | |||
571 | * @param prop performance data for the address (as far as known) | 576 | * @param prop performance data for the address (as far as known) |
572 | */ | 577 | */ |
573 | static void | 578 | static void |
574 | update_latencies(void *cls, | 579 | update_latencies (void *cls, |
575 | const struct GNUNET_HELLO_Address *address, | 580 | const struct GNUNET_HELLO_Address *address, |
576 | int active, | 581 | int active, |
577 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 582 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
578 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 583 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
579 | const struct GNUNET_ATS_Properties *prop) | 584 | const struct GNUNET_ATS_Properties *prop) |
580 | { | 585 | { |
581 | if (NULL == address) | 586 | if (NULL == address) |
582 | { | 587 | { |
583 | /* ATS service temporarily disconnected */ | 588 | /* ATS service temporarily disconnected */ |
584 | return; | 589 | return; |
585 | } | 590 | } |
586 | 591 | ||
587 | if (GNUNET_YES != active) | 592 | if (GNUNET_YES != active) |
588 | return; | 593 | return; |
589 | GSF_update_peer_latency_(&address->peer, | 594 | GSF_update_peer_latency_ (&address->peer, |
590 | prop->delay); | 595 | prop->delay); |
591 | GSF_avg_latency.rel_value_us = | 596 | GSF_avg_latency.rel_value_us = |
592 | (GSF_avg_latency.rel_value_us * 31 + | 597 | (GSF_avg_latency.rel_value_us * 31 |
593 | GNUNET_MIN(5000, prop->delay.rel_value_us)) / 32; | 598 | + GNUNET_MIN (5000, prop->delay.rel_value_us)) / 32; |
594 | GNUNET_STATISTICS_set(GSF_stats, | 599 | GNUNET_STATISTICS_set (GSF_stats, |
595 | gettext_noop("# running average P2P latency (ms)"), | 600 | gettext_noop ("# running average P2P latency (ms)"), |
596 | GSF_avg_latency.rel_value_us / 1000LL, | 601 | GSF_avg_latency.rel_value_us / 1000LL, |
597 | GNUNET_NO); | 602 | GNUNET_NO); |
598 | } | 603 | } |
599 | 604 | ||
600 | 605 | ||
@@ -607,17 +612,17 @@ update_latencies(void *cls, | |||
607 | * #GNUNET_SYSERR to close it (signal serious error) | 612 | * #GNUNET_SYSERR to close it (signal serious error) |
608 | */ | 613 | */ |
609 | static int | 614 | static int |
610 | check_p2p_put(void *cls, | 615 | check_p2p_put (void *cls, |
611 | const struct PutMessage *put) | 616 | const struct PutMessage *put) |
612 | { | 617 | { |
613 | enum GNUNET_BLOCK_Type type; | 618 | enum GNUNET_BLOCK_Type type; |
614 | 619 | ||
615 | type = ntohl(put->type); | 620 | type = ntohl (put->type); |
616 | if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type) | 621 | if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type) |
617 | { | 622 | { |
618 | GNUNET_break_op(0); | 623 | GNUNET_break_op (0); |
619 | return GNUNET_SYSERR; | 624 | return GNUNET_SYSERR; |
620 | } | 625 | } |
621 | return GNUNET_OK; | 626 | return GNUNET_OK; |
622 | } | 627 | } |
623 | 628 | ||
@@ -632,25 +637,25 @@ check_p2p_put(void *cls, | |||
632 | * @param ppd peer performance data | 637 | * @param ppd peer performance data |
633 | */ | 638 | */ |
634 | static void | 639 | static void |
635 | consider_request_for_forwarding(void *cls, | 640 | consider_request_for_forwarding (void *cls, |
636 | const struct GNUNET_PeerIdentity *peer, | 641 | const struct GNUNET_PeerIdentity *peer, |
637 | struct GSF_ConnectedPeer *cp, | 642 | struct GSF_ConnectedPeer *cp, |
638 | const struct GSF_PeerPerformanceData *ppd) | 643 | const struct GSF_PeerPerformanceData *ppd) |
639 | { | 644 | { |
640 | struct GSF_PendingRequest *pr = cls; | 645 | struct GSF_PendingRequest *pr = cls; |
641 | 646 | ||
642 | if (GNUNET_YES != | 647 | if (GNUNET_YES != |
643 | GSF_pending_request_test_target_(pr, peer)) | 648 | GSF_pending_request_test_target_ (pr, peer)) |
644 | { | 649 | { |
645 | #if INSANE_STATISTICS | 650 | #if INSANE_STATISTICS |
646 | GNUNET_STATISTICS_update(GSF_stats, | 651 | GNUNET_STATISTICS_update (GSF_stats, |
647 | gettext_noop("# Loopback routes suppressed"), 1, | 652 | gettext_noop ("# Loopback routes suppressed"), 1, |
648 | GNUNET_NO); | 653 | GNUNET_NO); |
649 | #endif | 654 | #endif |
650 | return; | 655 | return; |
651 | } | 656 | } |
652 | GSF_plan_add_(cp, | 657 | GSF_plan_add_ (cp, |
653 | pr); | 658 | pr); |
654 | } | 659 | } |
655 | 660 | ||
656 | 661 | ||
@@ -665,17 +670,17 @@ consider_request_for_forwarding(void *cls, | |||
665 | * @param result final datastore lookup result | 670 | * @param result final datastore lookup result |
666 | */ | 671 | */ |
667 | void | 672 | void |
668 | GSF_consider_forwarding(void *cls, | 673 | GSF_consider_forwarding (void *cls, |
669 | struct GSF_PendingRequest *pr, | 674 | struct GSF_PendingRequest *pr, |
670 | enum GNUNET_BLOCK_EvaluationResult result) | 675 | enum GNUNET_BLOCK_EvaluationResult result) |
671 | { | 676 | { |
672 | if (GNUNET_BLOCK_EVALUATION_OK_LAST == result) | 677 | if (GNUNET_BLOCK_EVALUATION_OK_LAST == result) |
673 | return; /* we're done... */ | 678 | return; /* we're done... */ |
674 | if (GNUNET_YES != | 679 | if (GNUNET_YES != |
675 | GSF_pending_request_test_active_(pr)) | 680 | GSF_pending_request_test_active_ (pr)) |
676 | return; /* request is not actually active, skip! */ | 681 | return; /* request is not actually active, skip! */ |
677 | GSF_iterate_connected_peers_(&consider_request_for_forwarding, | 682 | GSF_iterate_connected_peers_ (&consider_request_for_forwarding, |
678 | pr); | 683 | pr); |
679 | } | 684 | } |
680 | 685 | ||
681 | 686 | ||
@@ -688,35 +693,37 @@ GSF_consider_forwarding(void *cls, | |||
688 | * #GNUNET_SYSERR to close it (signal serious error) | 693 | * #GNUNET_SYSERR to close it (signal serious error) |
689 | */ | 694 | */ |
690 | static int | 695 | static int |
691 | check_p2p_get(void *cls, | 696 | check_p2p_get (void *cls, |
692 | const struct GetMessage *gm) | 697 | const struct GetMessage *gm) |
693 | { | 698 | { |
694 | size_t msize; | 699 | size_t msize; |
695 | unsigned int bm; | 700 | unsigned int bm; |
696 | unsigned int bits; | 701 | unsigned int bits; |
697 | size_t bfsize; | 702 | size_t bfsize; |
698 | 703 | ||
699 | msize = ntohs(gm->header.size); | 704 | msize = ntohs (gm->header.size); |
700 | bm = ntohl(gm->hash_bitmap); | 705 | bm = ntohl (gm->hash_bitmap); |
701 | bits = 0; | 706 | bits = 0; |
702 | while (bm > 0) | 707 | while (bm > 0) |
703 | { | 708 | { |
704 | if (1 == (bm & 1)) | 709 | if (1 == (bm & 1)) |
705 | bits++; | 710 | bits++; |
706 | bm >>= 1; | 711 | bm >>= 1; |
707 | } | 712 | } |
708 | if (msize < sizeof(struct GetMessage) + bits * sizeof(struct GNUNET_PeerIdentity)) | 713 | if (msize < sizeof(struct GetMessage) + bits * sizeof(struct |
709 | { | 714 | GNUNET_PeerIdentity)) |
710 | GNUNET_break_op(0); | 715 | { |
711 | return GNUNET_SYSERR; | 716 | GNUNET_break_op (0); |
712 | } | 717 | return GNUNET_SYSERR; |
713 | bfsize = msize - sizeof(struct GetMessage) - bits * sizeof(struct GNUNET_PeerIdentity); | 718 | } |
719 | bfsize = msize - sizeof(struct GetMessage) - bits * sizeof(struct | ||
720 | GNUNET_PeerIdentity); | ||
714 | /* bfsize must be power of 2, check! */ | 721 | /* bfsize must be power of 2, check! */ |
715 | if (0 != ((bfsize - 1) & bfsize)) | 722 | if (0 != ((bfsize - 1) & bfsize)) |
716 | { | 723 | { |
717 | GNUNET_break_op(0); | 724 | GNUNET_break_op (0); |
718 | return GNUNET_SYSERR; | 725 | return GNUNET_SYSERR; |
719 | } | 726 | } |
720 | return GNUNET_OK; | 727 | return GNUNET_OK; |
721 | } | 728 | } |
722 | 729 | ||
@@ -732,48 +739,48 @@ check_p2p_get(void *cls, | |||
732 | * @param result final datastore lookup result | 739 | * @param result final datastore lookup result |
733 | */ | 740 | */ |
734 | static void | 741 | static void |
735 | start_p2p_processing(void *cls, | 742 | start_p2p_processing (void *cls, |
736 | struct GSF_PendingRequest *pr, | 743 | struct GSF_PendingRequest *pr, |
737 | enum GNUNET_BLOCK_EvaluationResult result) | 744 | enum GNUNET_BLOCK_EvaluationResult result) |
738 | { | 745 | { |
739 | struct GSF_LocalClient *lc = cls; | 746 | struct GSF_LocalClient *lc = cls; |
740 | struct GSF_PendingRequestData *prd; | 747 | struct GSF_PendingRequestData *prd; |
741 | 748 | ||
742 | GNUNET_SERVICE_client_continue(lc->client); | 749 | GNUNET_SERVICE_client_continue (lc->client); |
743 | if (GNUNET_BLOCK_EVALUATION_OK_LAST == result) | 750 | if (GNUNET_BLOCK_EVALUATION_OK_LAST == result) |
744 | return; /* we're done, 'pr' was already destroyed... */ | 751 | return; /* we're done, 'pr' was already destroyed... */ |
745 | prd = GSF_pending_request_get_data_(pr); | 752 | prd = GSF_pending_request_get_data_ (pr); |
746 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
747 | "Finished database lookup for local request `%s' with result %d\n", | 754 | "Finished database lookup for local request `%s' with result %d\n", |
748 | GNUNET_h2s(&prd->query), | 755 | GNUNET_h2s (&prd->query), |
749 | result); | 756 | result); |
750 | if (0 == prd->anonymity_level) | 757 | if (0 == prd->anonymity_level) |
758 | { | ||
759 | switch (prd->type) | ||
751 | { | 760 | { |
752 | switch (prd->type) | 761 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: |
753 | { | 762 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: |
754 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: | 763 | /* the above block types MAY be available via 'cadet' */ |
755 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: | 764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
756 | /* the above block types MAY be available via 'cadet' */ | 765 | "Considering cadet-based download for block\n"); |
757 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 766 | GSF_cadet_lookup_ (pr); |
758 | "Considering cadet-based download for block\n"); | 767 | break; |
759 | GSF_cadet_lookup_(pr); | 768 | |
760 | break; | 769 | case GNUNET_BLOCK_TYPE_FS_UBLOCK: |
761 | 770 | /* the above block types are in the DHT */ | |
762 | case GNUNET_BLOCK_TYPE_FS_UBLOCK: | 771 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
763 | /* the above block types are in the DHT */ | 772 | "Considering DHT-based search for block\n"); |
764 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 773 | GSF_dht_lookup_ (pr); |
765 | "Considering DHT-based search for block\n"); | 774 | break; |
766 | GSF_dht_lookup_(pr); | 775 | |
767 | break; | 776 | default: |
768 | 777 | GNUNET_break (0); | |
769 | default: | 778 | break; |
770 | GNUNET_break(0); | ||
771 | break; | ||
772 | } | ||
773 | } | 779 | } |
774 | GSF_consider_forwarding(NULL, | 780 | } |
775 | pr, | 781 | GSF_consider_forwarding (NULL, |
776 | result); | 782 | pr, |
783 | result); | ||
777 | } | 784 | } |
778 | 785 | ||
779 | 786 | ||
@@ -786,17 +793,17 @@ start_p2p_processing(void *cls, | |||
786 | * @return #GNUNET_OK if @a sm is well-formed | 793 | * @return #GNUNET_OK if @a sm is well-formed |
787 | */ | 794 | */ |
788 | static int | 795 | static int |
789 | check_client_start_search(void *cls, | 796 | check_client_start_search (void *cls, |
790 | const struct SearchMessage *sm) | 797 | const struct SearchMessage *sm) |
791 | { | 798 | { |
792 | uint16_t msize; | 799 | uint16_t msize; |
793 | 800 | ||
794 | msize = ntohs(sm->header.size) - sizeof(struct SearchMessage); | 801 | msize = ntohs (sm->header.size) - sizeof(struct SearchMessage); |
795 | if (0 != msize % sizeof(struct GNUNET_HashCode)) | 802 | if (0 != msize % sizeof(struct GNUNET_HashCode)) |
796 | { | 803 | { |
797 | GNUNET_break(0); | 804 | GNUNET_break (0); |
798 | return GNUNET_SYSERR; | 805 | return GNUNET_SYSERR; |
799 | } | 806 | } |
800 | return GNUNET_OK; | 807 | return GNUNET_OK; |
801 | } | 808 | } |
802 | 809 | ||
@@ -812,8 +819,8 @@ check_client_start_search(void *cls, | |||
812 | * @param sm the actual message | 819 | * @param sm the actual message |
813 | */ | 820 | */ |
814 | static void | 821 | static void |
815 | handle_client_start_search(void *cls, | 822 | handle_client_start_search (void *cls, |
816 | const struct SearchMessage *sm) | 823 | const struct SearchMessage *sm) |
817 | { | 824 | { |
818 | static struct GNUNET_PeerIdentity all_zeros; | 825 | static struct GNUNET_PeerIdentity all_zeros; |
819 | struct GSF_LocalClient *lc = cls; | 826 | struct GSF_LocalClient *lc = cls; |
@@ -824,90 +831,93 @@ handle_client_start_search(void *cls, | |||
824 | enum GNUNET_BLOCK_Type type; | 831 | enum GNUNET_BLOCK_Type type; |
825 | enum GSF_PendingRequestOptions options; | 832 | enum GSF_PendingRequestOptions options; |
826 | 833 | ||
827 | GNUNET_STATISTICS_update(GSF_stats, | 834 | GNUNET_STATISTICS_update (GSF_stats, |
828 | gettext_noop("# client searches received"), | 835 | gettext_noop ("# client searches received"), |
829 | 1, | 836 | 1, |
830 | GNUNET_NO); | 837 | GNUNET_NO); |
831 | msize = ntohs(sm->header.size) - sizeof(struct SearchMessage); | 838 | msize = ntohs (sm->header.size) - sizeof(struct SearchMessage); |
832 | sc = msize / sizeof(struct GNUNET_HashCode); | 839 | sc = msize / sizeof(struct GNUNET_HashCode); |
833 | type = ntohl(sm->type); | 840 | type = ntohl (sm->type); |
834 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 841 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
835 | "Received request for `%s' of type %u from local client\n", | 842 | "Received request for `%s' of type %u from local client\n", |
836 | GNUNET_h2s(&sm->query), | 843 | GNUNET_h2s (&sm->query), |
837 | (unsigned int)type); | 844 | (unsigned int) type); |
838 | cr = NULL; | 845 | cr = NULL; |
839 | /* detect duplicate UBLOCK requests */ | 846 | /* detect duplicate UBLOCK requests */ |
840 | if ((type == GNUNET_BLOCK_TYPE_FS_UBLOCK) || | 847 | if ((type == GNUNET_BLOCK_TYPE_FS_UBLOCK) || |
841 | (type == GNUNET_BLOCK_TYPE_ANY)) | 848 | (type == GNUNET_BLOCK_TYPE_ANY)) |
849 | { | ||
850 | cr = lc->cr_head; | ||
851 | while (NULL != cr) | ||
842 | { | 852 | { |
843 | cr = lc->cr_head; | 853 | prd = GSF_pending_request_get_data_ (cr->pr); |
844 | while (NULL != cr) | 854 | /* only unify with queries that hae not yet started local processing |
845 | { | 855 | (SEARCH_MESSAGE_OPTION_CONTINUED was always set) and that have a |
846 | prd = GSF_pending_request_get_data_(cr->pr); | 856 | matching query and type */ |
847 | /* only unify with queries that hae not yet started local processing | 857 | if ((GNUNET_YES != prd->has_started) && |
848 | (SEARCH_MESSAGE_OPTION_CONTINUED was always set) and that have a | 858 | (0 != memcmp (&prd->query, |
849 | matching query and type */ | 859 | &sm->query, |
850 | if ((GNUNET_YES != prd->has_started) && | 860 | sizeof(struct GNUNET_HashCode))) && |
851 | (0 != memcmp(&prd->query, | 861 | (prd->type == type)) |
852 | &sm->query, | 862 | break; |
853 | sizeof(struct GNUNET_HashCode))) && | 863 | cr = cr->next; |
854 | (prd->type == type)) | ||
855 | break; | ||
856 | cr = cr->next; | ||
857 | } | ||
858 | } | 864 | } |
865 | } | ||
859 | if (NULL != cr) | 866 | if (NULL != cr) |
860 | { | 867 | { |
861 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
862 | "Have existing request, merging content-seen lists.\n"); | 869 | "Have existing request, merging content-seen lists.\n"); |
863 | GSF_pending_request_update_(cr->pr, | 870 | GSF_pending_request_update_ (cr->pr, |
864 | (const struct GNUNET_HashCode *)&sm[1], | 871 | (const struct GNUNET_HashCode *) &sm[1], |
865 | sc); | 872 | sc); |
866 | GNUNET_STATISTICS_update(GSF_stats, | 873 | GNUNET_STATISTICS_update (GSF_stats, |
867 | gettext_noop("# client searches updated (merged content seen list)"), | 874 | gettext_noop ( |
868 | 1, | 875 | "# client searches updated (merged content seen list)"), |
869 | GNUNET_NO); | 876 | 1, |
870 | } | 877 | GNUNET_NO); |
878 | } | ||
871 | else | 879 | else |
872 | { | 880 | { |
873 | GNUNET_STATISTICS_update(GSF_stats, | 881 | GNUNET_STATISTICS_update (GSF_stats, |
874 | gettext_noop("# client searches active"), | 882 | gettext_noop ("# client searches active"), |
875 | 1, | 883 | 1, |
876 | GNUNET_NO); | 884 | GNUNET_NO); |
877 | cr = GNUNET_new(struct ClientRequest); | 885 | cr = GNUNET_new (struct ClientRequest); |
878 | cr->lc = lc; | 886 | cr->lc = lc; |
879 | GNUNET_CONTAINER_DLL_insert(lc->cr_head, | 887 | GNUNET_CONTAINER_DLL_insert (lc->cr_head, |
880 | lc->cr_tail, | 888 | lc->cr_tail, |
881 | cr); | 889 | cr); |
882 | options = GSF_PRO_LOCAL_REQUEST; | 890 | options = GSF_PRO_LOCAL_REQUEST; |
883 | if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl(sm->options))) | 891 | if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options))) |
884 | options |= GSF_PRO_LOCAL_ONLY; | 892 | options |= GSF_PRO_LOCAL_ONLY; |
885 | cr->pr = GSF_pending_request_create_(options, type, | 893 | cr->pr = GSF_pending_request_create_ (options, type, |
886 | &sm->query, | 894 | &sm->query, |
887 | (0 != | 895 | (0 != |
888 | memcmp(&sm->target, | 896 | memcmp (&sm->target, |
889 | &all_zeros, | 897 | &all_zeros, |
890 | sizeof(struct GNUNET_PeerIdentity))) | 898 | sizeof(struct |
891 | ? &sm->target : NULL, NULL, 0, | 899 | GNUNET_PeerIdentity))) |
892 | 0 /* bf */, | 900 | ? &sm->target : NULL, NULL, 0, |
893 | ntohl(sm->anonymity_level), | 901 | 0 /* bf */, |
894 | 0 /* priority */, | 902 | ntohl (sm->anonymity_level), |
895 | 0 /* ttl */, | 903 | 0 /* priority */, |
896 | 0 /* sender PID */, | 904 | 0 /* ttl */, |
897 | 0 /* origin PID */, | 905 | 0 /* sender PID */, |
898 | (const struct GNUNET_HashCode *)&sm[1], sc, | 906 | 0 /* origin PID */, |
899 | &client_response_handler, | 907 | (const struct |
900 | cr); | 908 | GNUNET_HashCode *) &sm[1], sc, |
901 | } | 909 | &client_response_handler, |
902 | if (0 != (SEARCH_MESSAGE_OPTION_CONTINUED & ntohl(sm->options))) | 910 | cr); |
903 | { | 911 | } |
904 | GNUNET_SERVICE_client_continue(lc->client); | 912 | if (0 != (SEARCH_MESSAGE_OPTION_CONTINUED & ntohl (sm->options))) |
905 | return; | 913 | { |
906 | } | 914 | GNUNET_SERVICE_client_continue (lc->client); |
907 | GSF_pending_request_get_data_(cr->pr)->has_started = GNUNET_YES; | 915 | return; |
908 | GSF_local_lookup_(cr->pr, | 916 | } |
909 | &start_p2p_processing, | 917 | GSF_pending_request_get_data_ (cr->pr)->has_started = GNUNET_YES; |
910 | lc); | 918 | GSF_local_lookup_ (cr->pr, |
919 | &start_p2p_processing, | ||
920 | lc); | ||
911 | } | 921 | } |
912 | 922 | ||
913 | 923 | ||
@@ -918,8 +928,8 @@ handle_client_start_search(void *cls, | |||
918 | * @param msg the actual message | 928 | * @param msg the actual message |
919 | */ | 929 | */ |
920 | static void | 930 | static void |
921 | handle_client_loc_sign(void *cls, | 931 | handle_client_loc_sign (void *cls, |
922 | const struct RequestLocSignatureMessage *msg) | 932 | const struct RequestLocSignatureMessage *msg) |
923 | { | 933 | { |
924 | struct GSF_LocalClient *lc = cls; | 934 | struct GSF_LocalClient *lc = cls; |
925 | struct GNUNET_FS_Uri base; | 935 | struct GNUNET_FS_Uri base; |
@@ -927,24 +937,26 @@ handle_client_loc_sign(void *cls, | |||
927 | struct GNUNET_MQ_Envelope *env; | 937 | struct GNUNET_MQ_Envelope *env; |
928 | struct ResponseLocSignatureMessage *resp; | 938 | struct ResponseLocSignatureMessage *resp; |
929 | 939 | ||
930 | GNUNET_break(GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT == | 940 | GNUNET_break (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT == |
931 | ntohl(msg->purpose)); | 941 | ntohl (msg->purpose)); |
932 | base.type = GNUNET_FS_URI_CHK; | 942 | base.type = GNUNET_FS_URI_CHK; |
933 | base.data.chk.chk = msg->chk; | 943 | base.data.chk.chk = msg->chk; |
934 | base.data.chk.file_length = GNUNET_ntohll(msg->file_length); | 944 | base.data.chk.file_length = GNUNET_ntohll (msg->file_length); |
935 | loc = GNUNET_FS_uri_loc_create(&base, | 945 | loc = GNUNET_FS_uri_loc_create (&base, |
936 | pk, | 946 | pk, |
937 | GNUNET_TIME_absolute_ntoh(msg->expiration_time)); | 947 | GNUNET_TIME_absolute_ntoh ( |
938 | env = GNUNET_MQ_msg(resp, | 948 | msg->expiration_time)); |
939 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE); | 949 | env = GNUNET_MQ_msg (resp, |
940 | resp->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); | 950 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE); |
941 | resp->expiration_time = GNUNET_TIME_absolute_hton(loc->data.loc.expirationTime); | 951 | resp->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); |
952 | resp->expiration_time = GNUNET_TIME_absolute_hton ( | ||
953 | loc->data.loc.expirationTime); | ||
942 | resp->signature = loc->data.loc.contentSignature; | 954 | resp->signature = loc->data.loc.contentSignature; |
943 | resp->peer = loc->data.loc.peer; | 955 | resp->peer = loc->data.loc.peer; |
944 | GNUNET_FS_uri_destroy(loc); | 956 | GNUNET_FS_uri_destroy (loc); |
945 | GNUNET_MQ_send(lc->mq, | 957 | GNUNET_MQ_send (lc->mq, |
946 | env); | 958 | env); |
947 | GNUNET_SERVICE_client_continue(lc->client); | 959 | GNUNET_SERVICE_client_continue (lc->client); |
948 | } | 960 | } |
949 | 961 | ||
950 | 962 | ||
@@ -956,24 +968,24 @@ handle_client_loc_sign(void *cls, | |||
956 | * @return #GNUNET_OK if @a ism is well-formed | 968 | * @return #GNUNET_OK if @a ism is well-formed |
957 | */ | 969 | */ |
958 | static int | 970 | static int |
959 | check_client_index_start(void *cls, | 971 | check_client_index_start (void *cls, |
960 | const struct IndexStartMessage *ism) | 972 | const struct IndexStartMessage *ism) |
961 | { | 973 | { |
962 | char *fn; | 974 | char *fn; |
963 | 975 | ||
964 | GNUNET_MQ_check_zero_termination(ism); | 976 | GNUNET_MQ_check_zero_termination (ism); |
965 | if (0 != ism->reserved) | 977 | if (0 != ism->reserved) |
966 | { | 978 | { |
967 | GNUNET_break(0); | 979 | GNUNET_break (0); |
968 | return GNUNET_SYSERR; | 980 | return GNUNET_SYSERR; |
969 | } | 981 | } |
970 | fn = GNUNET_STRINGS_filename_expand((const char *)&ism[1]); | 982 | fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]); |
971 | if (NULL == fn) | 983 | if (NULL == fn) |
972 | { | 984 | { |
973 | GNUNET_break(0); | 985 | GNUNET_break (0); |
974 | return GNUNET_SYSERR; | 986 | return GNUNET_SYSERR; |
975 | } | 987 | } |
976 | GNUNET_free(fn); | 988 | GNUNET_free (fn); |
977 | return GNUNET_OK; | 989 | return GNUNET_OK; |
978 | } | 990 | } |
979 | 991 | ||
@@ -985,21 +997,21 @@ check_client_index_start(void *cls, | |||
985 | * @param isc the data about the index info entry for the request | 997 | * @param isc the data about the index info entry for the request |
986 | */ | 998 | */ |
987 | static void | 999 | static void |
988 | signal_index_ok(struct IndexStartContext *isc) | 1000 | signal_index_ok (struct IndexStartContext *isc) |
989 | { | 1001 | { |
990 | struct GSF_LocalClient *lc = isc->lc; | 1002 | struct GSF_LocalClient *lc = isc->lc; |
991 | struct GNUNET_MQ_Envelope *env; | 1003 | struct GNUNET_MQ_Envelope *env; |
992 | struct GNUNET_MessageHeader *msg; | 1004 | struct GNUNET_MessageHeader *msg; |
993 | 1005 | ||
994 | GNUNET_FS_add_to_index(isc->filename, | 1006 | GNUNET_FS_add_to_index (isc->filename, |
995 | &isc->file_id); | 1007 | &isc->file_id); |
996 | env = GNUNET_MQ_msg(msg, | 1008 | env = GNUNET_MQ_msg (msg, |
997 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK); | 1009 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK); |
998 | GNUNET_MQ_send(lc->mq, | 1010 | GNUNET_MQ_send (lc->mq, |
999 | env); | 1011 | env); |
1000 | GNUNET_free(isc->filename); | 1012 | GNUNET_free (isc->filename); |
1001 | GNUNET_free(isc); | 1013 | GNUNET_free (isc); |
1002 | GNUNET_SERVICE_client_continue(lc->client); | 1014 | GNUNET_SERVICE_client_continue (lc->client); |
1003 | } | 1015 | } |
1004 | 1016 | ||
1005 | 1017 | ||
@@ -1011,36 +1023,37 @@ signal_index_ok(struct IndexStartContext *isc) | |||
1011 | * @param res resulting hash, NULL on error | 1023 | * @param res resulting hash, NULL on error |
1012 | */ | 1024 | */ |
1013 | static void | 1025 | static void |
1014 | hash_for_index_val(void *cls, | 1026 | hash_for_index_val (void *cls, |
1015 | const struct GNUNET_HashCode *res) | 1027 | const struct GNUNET_HashCode *res) |
1016 | { | 1028 | { |
1017 | struct IndexStartContext *isc = cls; | 1029 | struct IndexStartContext *isc = cls; |
1018 | struct GSF_LocalClient *lc = isc->lc; | 1030 | struct GSF_LocalClient *lc = isc->lc; |
1019 | struct GNUNET_MQ_Envelope *env; | 1031 | struct GNUNET_MQ_Envelope *env; |
1020 | struct GNUNET_MessageHeader *msg; | 1032 | struct GNUNET_MessageHeader *msg; |
1021 | 1033 | ||
1022 | GNUNET_CONTAINER_DLL_remove(lc->isc_head, | 1034 | GNUNET_CONTAINER_DLL_remove (lc->isc_head, |
1023 | lc->isc_tail, | 1035 | lc->isc_tail, |
1024 | isc); | 1036 | isc); |
1025 | isc->fhc = NULL; | 1037 | isc->fhc = NULL; |
1026 | if ((NULL == res) || | 1038 | if ((NULL == res) || |
1027 | (0 != memcmp(res, | 1039 | (0 != memcmp (res, |
1028 | &isc->file_id, | 1040 | &isc->file_id, |
1029 | sizeof(struct GNUNET_HashCode)))) | 1041 | sizeof(struct GNUNET_HashCode)))) |
1030 | { | 1042 | { |
1031 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 1043 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1032 | _("Hash mismatch trying to index file `%s' which does not have hash `%s'\n"), | 1044 | _ ( |
1033 | isc->filename, | 1045 | "Hash mismatch trying to index file `%s' which does not have hash `%s'\n"), |
1034 | GNUNET_h2s(&isc->file_id)); | 1046 | isc->filename, |
1035 | env = GNUNET_MQ_msg(msg, | 1047 | GNUNET_h2s (&isc->file_id)); |
1036 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED); | 1048 | env = GNUNET_MQ_msg (msg, |
1037 | GNUNET_MQ_send(lc->mq, | 1049 | GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED); |
1038 | env); | 1050 | GNUNET_MQ_send (lc->mq, |
1039 | GNUNET_SERVICE_client_continue(lc->client); | 1051 | env); |
1040 | GNUNET_free(isc); | 1052 | GNUNET_SERVICE_client_continue (lc->client); |
1041 | return; | 1053 | GNUNET_free (isc); |
1042 | } | 1054 | return; |
1043 | signal_index_ok(isc); | 1055 | } |
1056 | signal_index_ok (isc); | ||
1044 | } | 1057 | } |
1045 | 1058 | ||
1046 | 1059 | ||
@@ -1051,8 +1064,8 @@ hash_for_index_val(void *cls, | |||
1051 | * @param message the actual message | 1064 | * @param message the actual message |
1052 | */ | 1065 | */ |
1053 | static void | 1066 | static void |
1054 | handle_client_index_start(void *cls, | 1067 | handle_client_index_start (void *cls, |
1055 | const struct IndexStartMessage *ism) | 1068 | const struct IndexStartMessage *ism) |
1056 | { | 1069 | { |
1057 | struct GSF_LocalClient *lc = cls; | 1070 | struct GSF_LocalClient *lc = cls; |
1058 | struct IndexStartContext *isc; | 1071 | struct IndexStartContext *isc; |
@@ -1062,49 +1075,49 @@ handle_client_index_start(void *cls, | |||
1062 | uint64_t mydev; | 1075 | uint64_t mydev; |
1063 | uint64_t myino; | 1076 | uint64_t myino; |
1064 | 1077 | ||
1065 | fn = GNUNET_STRINGS_filename_expand((const char *)&ism[1]); | 1078 | fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]); |
1066 | GNUNET_assert(NULL != fn); | 1079 | GNUNET_assert (NULL != fn); |
1067 | dev = GNUNET_ntohll(ism->device); | 1080 | dev = GNUNET_ntohll (ism->device); |
1068 | ino = GNUNET_ntohll(ism->inode); | 1081 | ino = GNUNET_ntohll (ism->inode); |
1069 | isc = GNUNET_new(struct IndexStartContext); | 1082 | isc = GNUNET_new (struct IndexStartContext); |
1070 | isc->filename = fn; | 1083 | isc->filename = fn; |
1071 | isc->file_id = ism->file_id; | 1084 | isc->file_id = ism->file_id; |
1072 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1085 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1073 | "Received START_INDEX message for file `%s'\n", | 1086 | "Received START_INDEX message for file `%s'\n", |
1074 | isc->filename); | 1087 | isc->filename); |
1075 | isc->lc = lc; | 1088 | isc->lc = lc; |
1076 | mydev = 0; | 1089 | mydev = 0; |
1077 | myino = 0; | 1090 | myino = 0; |
1078 | if (((dev != 0) || | 1091 | if (((dev != 0) || |
1079 | (ino != 0)) && | 1092 | (ino != 0)) && |
1080 | (GNUNET_OK == GNUNET_DISK_file_get_identifiers(fn, | 1093 | (GNUNET_OK == GNUNET_DISK_file_get_identifiers (fn, |
1081 | &mydev, | 1094 | &mydev, |
1082 | &myino)) && | 1095 | &myino)) && |
1083 | (dev == mydev) && | 1096 | (dev == mydev) && |
1084 | (ino == myino)) | 1097 | (ino == myino)) |
1085 | { | 1098 | { |
1086 | /* fast validation OK! */ | 1099 | /* fast validation OK! */ |
1087 | signal_index_ok(isc); | 1100 | signal_index_ok (isc); |
1088 | return; | 1101 | return; |
1089 | } | 1102 | } |
1090 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1091 | "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n", | 1104 | "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n", |
1092 | (unsigned long long)ino, | 1105 | (unsigned long long) ino, |
1093 | (unsigned long long)myino, | 1106 | (unsigned long long) myino, |
1094 | (unsigned int)dev, | 1107 | (unsigned int) dev, |
1095 | (unsigned int)mydev); | 1108 | (unsigned int) mydev); |
1096 | /* slow validation, need to hash full file (again) */ | 1109 | /* slow validation, need to hash full file (again) */ |
1097 | GNUNET_CONTAINER_DLL_insert(lc->isc_head, | 1110 | GNUNET_CONTAINER_DLL_insert (lc->isc_head, |
1098 | lc->isc_tail, | 1111 | lc->isc_tail, |
1099 | isc); | 1112 | isc); |
1100 | isc->fhc = GNUNET_CRYPTO_hash_file(GNUNET_SCHEDULER_PRIORITY_IDLE, | 1113 | isc->fhc = GNUNET_CRYPTO_hash_file (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1101 | isc->filename, | 1114 | isc->filename, |
1102 | HASHING_BLOCKSIZE, | 1115 | HASHING_BLOCKSIZE, |
1103 | &hash_for_index_val, | 1116 | &hash_for_index_val, |
1104 | isc); | 1117 | isc); |
1105 | if (NULL == isc->fhc) | 1118 | if (NULL == isc->fhc) |
1106 | hash_for_index_val(isc, | 1119 | hash_for_index_val (isc, |
1107 | NULL); | 1120 | NULL); |
1108 | } | 1121 | } |
1109 | 1122 | ||
1110 | 1123 | ||
@@ -1115,13 +1128,13 @@ handle_client_index_start(void *cls, | |||
1115 | * @param message the actual message | 1128 | * @param message the actual message |
1116 | */ | 1129 | */ |
1117 | static void | 1130 | static void |
1118 | handle_client_index_list_get(void *cls, | 1131 | handle_client_index_list_get (void *cls, |
1119 | const struct GNUNET_MessageHeader *message) | 1132 | const struct GNUNET_MessageHeader *message) |
1120 | { | 1133 | { |
1121 | struct GSF_LocalClient *lc = cls; | 1134 | struct GSF_LocalClient *lc = cls; |
1122 | 1135 | ||
1123 | GNUNET_FS_indexing_send_list(lc->mq); | 1136 | GNUNET_FS_indexing_send_list (lc->mq); |
1124 | GNUNET_SERVICE_client_continue(lc->client); | 1137 | GNUNET_SERVICE_client_continue (lc->client); |
1125 | } | 1138 | } |
1126 | 1139 | ||
1127 | 1140 | ||
@@ -1132,25 +1145,25 @@ handle_client_index_list_get(void *cls, | |||
1132 | * @param message the actual message | 1145 | * @param message the actual message |
1133 | */ | 1146 | */ |
1134 | static void | 1147 | static void |
1135 | handle_client_unindex(void *cls, | 1148 | handle_client_unindex (void *cls, |
1136 | const struct UnindexMessage *um) | 1149 | const struct UnindexMessage *um) |
1137 | { | 1150 | { |
1138 | struct GSF_LocalClient *lc = cls; | 1151 | struct GSF_LocalClient *lc = cls; |
1139 | struct GNUNET_MQ_Envelope *env; | 1152 | struct GNUNET_MQ_Envelope *env; |
1140 | struct GNUNET_MessageHeader *msg; | 1153 | struct GNUNET_MessageHeader *msg; |
1141 | int found; | 1154 | int found; |
1142 | 1155 | ||
1143 | GNUNET_break(0 == um->reserved); | 1156 | GNUNET_break (0 == um->reserved); |
1144 | found = GNUNET_FS_indexing_do_unindex(&um->file_id); | 1157 | found = GNUNET_FS_indexing_do_unindex (&um->file_id); |
1145 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1146 | "Client requested unindexing of file `%s': %s\n", | 1159 | "Client requested unindexing of file `%s': %s\n", |
1147 | GNUNET_h2s(&um->file_id), | 1160 | GNUNET_h2s (&um->file_id), |
1148 | found ? "found" : "not found"); | 1161 | found ? "found" : "not found"); |
1149 | env = GNUNET_MQ_msg(msg, | 1162 | env = GNUNET_MQ_msg (msg, |
1150 | GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK); | 1163 | GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK); |
1151 | GNUNET_MQ_send(lc->mq, | 1164 | GNUNET_MQ_send (lc->mq, |
1152 | env); | 1165 | env); |
1153 | GNUNET_SERVICE_client_continue(lc->client); | 1166 | GNUNET_SERVICE_client_continue (lc->client); |
1154 | } | 1167 | } |
1155 | 1168 | ||
1156 | 1169 | ||
@@ -1160,44 +1173,44 @@ handle_client_unindex(void *cls, | |||
1160 | * @param cls unused | 1173 | * @param cls unused |
1161 | */ | 1174 | */ |
1162 | static void | 1175 | static void |
1163 | shutdown_task(void *cls) | 1176 | shutdown_task (void *cls) |
1164 | { | 1177 | { |
1165 | GSF_cadet_stop_server(); | 1178 | GSF_cadet_stop_server (); |
1166 | if (NULL != GSF_core) | 1179 | if (NULL != GSF_core) |
1167 | { | 1180 | { |
1168 | GNUNET_CORE_disconnect(GSF_core); | 1181 | GNUNET_CORE_disconnect (GSF_core); |
1169 | GSF_core = NULL; | 1182 | GSF_core = NULL; |
1170 | } | 1183 | } |
1171 | if (NULL != GSF_ats) | 1184 | if (NULL != GSF_ats) |
1172 | { | 1185 | { |
1173 | GNUNET_ATS_performance_done(GSF_ats); | 1186 | GNUNET_ATS_performance_done (GSF_ats); |
1174 | GSF_ats = NULL; | 1187 | GSF_ats = NULL; |
1175 | } | 1188 | } |
1176 | GSF_put_done_(); | 1189 | GSF_put_done_ (); |
1177 | GSF_push_done_(); | 1190 | GSF_push_done_ (); |
1178 | GSF_pending_request_done_(); | 1191 | GSF_pending_request_done_ (); |
1179 | GSF_plan_done(); | 1192 | GSF_plan_done (); |
1180 | GSF_connected_peer_done_(); | 1193 | GSF_connected_peer_done_ (); |
1181 | GNUNET_DATASTORE_disconnect(GSF_dsh, | 1194 | GNUNET_DATASTORE_disconnect (GSF_dsh, |
1182 | GNUNET_NO); | 1195 | GNUNET_NO); |
1183 | GSF_dsh = NULL; | 1196 | GSF_dsh = NULL; |
1184 | GNUNET_DHT_disconnect(GSF_dht); | 1197 | GNUNET_DHT_disconnect (GSF_dht); |
1185 | GSF_dht = NULL; | 1198 | GSF_dht = NULL; |
1186 | GNUNET_BLOCK_context_destroy(GSF_block_ctx); | 1199 | GNUNET_BLOCK_context_destroy (GSF_block_ctx); |
1187 | GSF_block_ctx = NULL; | 1200 | GSF_block_ctx = NULL; |
1188 | GNUNET_CONFIGURATION_destroy(block_cfg); | 1201 | GNUNET_CONFIGURATION_destroy (block_cfg); |
1189 | block_cfg = NULL; | 1202 | block_cfg = NULL; |
1190 | GNUNET_STATISTICS_destroy(GSF_stats, GNUNET_NO); | 1203 | GNUNET_STATISTICS_destroy (GSF_stats, GNUNET_NO); |
1191 | GSF_stats = NULL; | 1204 | GSF_stats = NULL; |
1192 | if (NULL != cover_age_task) | 1205 | if (NULL != cover_age_task) |
1193 | { | 1206 | { |
1194 | GNUNET_SCHEDULER_cancel(cover_age_task); | 1207 | GNUNET_SCHEDULER_cancel (cover_age_task); |
1195 | cover_age_task = NULL; | 1208 | cover_age_task = NULL; |
1196 | } | 1209 | } |
1197 | GNUNET_FS_indexing_done(); | 1210 | GNUNET_FS_indexing_done (); |
1198 | GNUNET_LOAD_value_free(datastore_get_load); | 1211 | GNUNET_LOAD_value_free (datastore_get_load); |
1199 | datastore_get_load = NULL; | 1212 | datastore_get_load = NULL; |
1200 | GNUNET_LOAD_value_free(GSF_rt_entry_lifetime); | 1213 | GNUNET_LOAD_value_free (GSF_rt_entry_lifetime); |
1201 | GSF_rt_entry_lifetime = NULL; | 1214 | GSF_rt_entry_lifetime = NULL; |
1202 | } | 1215 | } |
1203 | 1216 | ||
@@ -1213,16 +1226,16 @@ shutdown_task(void *cls) | |||
1213 | * @param my_identity ID of this peer, NULL if we failed | 1226 | * @param my_identity ID of this peer, NULL if we failed |
1214 | */ | 1227 | */ |
1215 | static void | 1228 | static void |
1216 | peer_init_handler(void *cls, | 1229 | peer_init_handler (void *cls, |
1217 | const struct GNUNET_PeerIdentity *my_identity) | 1230 | const struct GNUNET_PeerIdentity *my_identity) |
1218 | { | 1231 | { |
1219 | if (0 != GNUNET_memcmp(&GSF_my_id, | 1232 | if (0 != GNUNET_memcmp (&GSF_my_id, |
1220 | my_identity)) | 1233 | my_identity)) |
1221 | { | 1234 | { |
1222 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1235 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1223 | "Peer identity mismatch, refusing to start!\n"); | 1236 | "Peer identity mismatch, refusing to start!\n"); |
1224 | GNUNET_SCHEDULER_shutdown(); | 1237 | GNUNET_SCHEDULER_shutdown (); |
1225 | } | 1238 | } |
1226 | } | 1239 | } |
1227 | 1240 | ||
1228 | 1241 | ||
@@ -1232,25 +1245,25 @@ peer_init_handler(void *cls, | |||
1232 | * @param c configuration to use | 1245 | * @param c configuration to use |
1233 | */ | 1246 | */ |
1234 | static int | 1247 | static int |
1235 | main_init(const struct GNUNET_CONFIGURATION_Handle *c) | 1248 | main_init (const struct GNUNET_CONFIGURATION_Handle *c) |
1236 | { | 1249 | { |
1237 | struct GNUNET_MQ_MessageHandler no_p2p_handlers[] = { | 1250 | struct GNUNET_MQ_MessageHandler no_p2p_handlers[] = { |
1238 | GNUNET_MQ_handler_end() | 1251 | GNUNET_MQ_handler_end () |
1239 | }; | 1252 | }; |
1240 | struct GNUNET_MQ_MessageHandler p2p_handlers[] = { | 1253 | struct GNUNET_MQ_MessageHandler p2p_handlers[] = { |
1241 | GNUNET_MQ_hd_var_size(p2p_get, | 1254 | GNUNET_MQ_hd_var_size (p2p_get, |
1242 | GNUNET_MESSAGE_TYPE_FS_GET, | 1255 | GNUNET_MESSAGE_TYPE_FS_GET, |
1243 | struct GetMessage, | 1256 | struct GetMessage, |
1244 | NULL), | 1257 | NULL), |
1245 | GNUNET_MQ_hd_var_size(p2p_put, | 1258 | GNUNET_MQ_hd_var_size (p2p_put, |
1246 | GNUNET_MESSAGE_TYPE_FS_PUT, | 1259 | GNUNET_MESSAGE_TYPE_FS_PUT, |
1247 | struct PutMessage, | 1260 | struct PutMessage, |
1248 | NULL), | 1261 | NULL), |
1249 | GNUNET_MQ_hd_fixed_size(p2p_migration_stop, | 1262 | GNUNET_MQ_hd_fixed_size (p2p_migration_stop, |
1250 | GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP, | 1263 | GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP, |
1251 | struct MigrationStopMessage, | 1264 | struct MigrationStopMessage, |
1252 | NULL), | 1265 | NULL), |
1253 | GNUNET_MQ_handler_end() | 1266 | GNUNET_MQ_handler_end () |
1254 | }; | 1267 | }; |
1255 | int anon_p2p_off; | 1268 | int anon_p2p_off; |
1256 | char *keyfile; | 1269 | char *keyfile; |
@@ -1258,54 +1271,55 @@ main_init(const struct GNUNET_CONFIGURATION_Handle *c) | |||
1258 | /* this option is really only for testcases that need to disable | 1271 | /* this option is really only for testcases that need to disable |
1259 | _anonymous_ file-sharing for some reason */ | 1272 | _anonymous_ file-sharing for some reason */ |
1260 | anon_p2p_off = (GNUNET_YES == | 1273 | anon_p2p_off = (GNUNET_YES == |
1261 | GNUNET_CONFIGURATION_get_value_yesno(GSF_cfg, | 1274 | GNUNET_CONFIGURATION_get_value_yesno (GSF_cfg, |
1262 | "fs", | 1275 | "fs", |
1263 | "DISABLE_ANON_TRANSFER")); | 1276 | "DISABLE_ANON_TRANSFER")); |
1264 | 1277 | ||
1265 | if (GNUNET_OK != | 1278 | if (GNUNET_OK != |
1266 | GNUNET_CONFIGURATION_get_value_filename(GSF_cfg, | 1279 | GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, |
1267 | "PEER", | 1280 | "PEER", |
1268 | "PRIVATE_KEY", | 1281 | "PRIVATE_KEY", |
1269 | &keyfile)) | 1282 | &keyfile)) |
1270 | { | 1283 | { |
1271 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1284 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1272 | _("FS service is lacking HOSTKEY configuration setting. Exiting.\n")); | 1285 | _ ( |
1273 | GNUNET_SCHEDULER_shutdown(); | 1286 | "FS service is lacking HOSTKEY configuration setting. Exiting.\n")); |
1274 | return GNUNET_SYSERR; | 1287 | GNUNET_SCHEDULER_shutdown (); |
1275 | } | 1288 | return GNUNET_SYSERR; |
1276 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file(keyfile); | 1289 | } |
1277 | GNUNET_free(keyfile); | 1290 | pk = GNUNET_CRYPTO_eddsa_key_create_from_file (keyfile); |
1278 | GNUNET_assert(NULL != pk); | 1291 | GNUNET_free (keyfile); |
1279 | GNUNET_CRYPTO_eddsa_key_get_public(pk, | 1292 | GNUNET_assert (NULL != pk); |
1280 | &GSF_my_id.public_key); | 1293 | GNUNET_CRYPTO_eddsa_key_get_public (pk, |
1281 | 1294 | &GSF_my_id.public_key); | |
1282 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1295 | |
1283 | "I am peer %s\n", | 1296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1284 | GNUNET_i2s(&GSF_my_id)); | 1297 | "I am peer %s\n", |
1298 | GNUNET_i2s (&GSF_my_id)); | ||
1285 | GSF_core | 1299 | GSF_core |
1286 | = GNUNET_CORE_connect(GSF_cfg, | 1300 | = GNUNET_CORE_connect (GSF_cfg, |
1287 | NULL, | 1301 | NULL, |
1288 | &peer_init_handler, | 1302 | &peer_init_handler, |
1289 | &GSF_peer_connect_handler, | 1303 | &GSF_peer_connect_handler, |
1290 | &GSF_peer_disconnect_handler, | 1304 | &GSF_peer_disconnect_handler, |
1291 | (GNUNET_YES == anon_p2p_off) | 1305 | (GNUNET_YES == anon_p2p_off) |
1292 | ? no_p2p_handlers | 1306 | ? no_p2p_handlers |
1293 | : p2p_handlers); | 1307 | : p2p_handlers); |
1294 | if (NULL == GSF_core) | 1308 | if (NULL == GSF_core) |
1295 | { | 1309 | { |
1296 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 1310 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1297 | _("Failed to connect to `%s' service.\n"), | 1311 | _ ("Failed to connect to `%s' service.\n"), |
1298 | "core"); | 1312 | "core"); |
1299 | return GNUNET_SYSERR; | 1313 | return GNUNET_SYSERR; |
1300 | } | 1314 | } |
1301 | cover_age_task = | 1315 | cover_age_task = |
1302 | GNUNET_SCHEDULER_add_delayed(COVER_AGE_FREQUENCY, | 1316 | GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, |
1303 | &age_cover_counters, | 1317 | &age_cover_counters, |
1318 | NULL); | ||
1319 | datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); | ||
1320 | GSF_cadet_start_server (); | ||
1321 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | ||
1304 | NULL); | 1322 | NULL); |
1305 | datastore_get_load = GNUNET_LOAD_value_init(DATASTORE_LOAD_AUTODECLINE); | ||
1306 | GSF_cadet_start_server(); | ||
1307 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, | ||
1308 | NULL); | ||
1309 | return GNUNET_OK; | 1323 | return GNUNET_OK; |
1310 | } | 1324 | } |
1311 | 1325 | ||
@@ -1318,55 +1332,55 @@ main_init(const struct GNUNET_CONFIGURATION_Handle *c) | |||
1318 | * @param service the initialized service | 1332 | * @param service the initialized service |
1319 | */ | 1333 | */ |
1320 | static void | 1334 | static void |
1321 | run(void *cls, | 1335 | run (void *cls, |
1322 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1336 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1323 | struct GNUNET_SERVICE_Handle *service) | 1337 | struct GNUNET_SERVICE_Handle *service) |
1324 | { | 1338 | { |
1325 | unsigned long long dqs; | 1339 | unsigned long long dqs; |
1326 | 1340 | ||
1327 | GSF_cfg = cfg; | 1341 | GSF_cfg = cfg; |
1328 | if (GNUNET_OK != | 1342 | if (GNUNET_OK != |
1329 | GNUNET_CONFIGURATION_get_value_size(GSF_cfg, | 1343 | GNUNET_CONFIGURATION_get_value_size (GSF_cfg, |
1330 | "fs", | 1344 | "fs", |
1331 | "DATASTORE_QUEUE_SIZE", | 1345 | "DATASTORE_QUEUE_SIZE", |
1332 | &dqs)) | 1346 | &dqs)) |
1333 | { | 1347 | { |
1334 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_INFO, | 1348 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_INFO, |
1335 | "fs", | 1349 | "fs", |
1336 | "DATASTORE_QUEUE_SIZE"); | 1350 | "DATASTORE_QUEUE_SIZE"); |
1337 | dqs = 32; | 1351 | dqs = 32; |
1338 | } | 1352 | } |
1339 | GSF_datastore_queue_size = (unsigned int)dqs; | 1353 | GSF_datastore_queue_size = (unsigned int) dqs; |
1340 | GSF_enable_randomized_delays = | 1354 | GSF_enable_randomized_delays = |
1341 | GNUNET_CONFIGURATION_get_value_yesno(cfg, "fs", "DELAY"); | 1355 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "fs", "DELAY"); |
1342 | GSF_dsh = GNUNET_DATASTORE_connect(cfg); | 1356 | GSF_dsh = GNUNET_DATASTORE_connect (cfg); |
1343 | if (NULL == GSF_dsh) | 1357 | if (NULL == GSF_dsh) |
1344 | { | 1358 | { |
1345 | GNUNET_SCHEDULER_shutdown(); | 1359 | GNUNET_SCHEDULER_shutdown (); |
1346 | return; | 1360 | return; |
1347 | } | 1361 | } |
1348 | GSF_rt_entry_lifetime = GNUNET_LOAD_value_init(GNUNET_TIME_UNIT_FOREVER_REL); | 1362 | GSF_rt_entry_lifetime = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_FOREVER_REL); |
1349 | GSF_stats = GNUNET_STATISTICS_create("fs", cfg); | 1363 | GSF_stats = GNUNET_STATISTICS_create ("fs", cfg); |
1350 | block_cfg = GNUNET_CONFIGURATION_create(); | 1364 | block_cfg = GNUNET_CONFIGURATION_create (); |
1351 | GSF_block_ctx = GNUNET_BLOCK_context_create(block_cfg); | 1365 | GSF_block_ctx = GNUNET_BLOCK_context_create (block_cfg); |
1352 | GNUNET_assert(NULL != GSF_block_ctx); | 1366 | GNUNET_assert (NULL != GSF_block_ctx); |
1353 | GSF_dht = GNUNET_DHT_connect(cfg, FS_DHT_HT_SIZE); | 1367 | GSF_dht = GNUNET_DHT_connect (cfg, FS_DHT_HT_SIZE); |
1354 | GSF_plan_init(); | 1368 | GSF_plan_init (); |
1355 | GSF_pending_request_init_(); | 1369 | GSF_pending_request_init_ (); |
1356 | GSF_connected_peer_init_(); | 1370 | GSF_connected_peer_init_ (); |
1357 | GSF_ats = GNUNET_ATS_performance_init(GSF_cfg, | 1371 | GSF_ats = GNUNET_ATS_performance_init (GSF_cfg, |
1358 | &update_latencies, | 1372 | &update_latencies, |
1359 | NULL); | 1373 | NULL); |
1360 | GSF_push_init_(); | 1374 | GSF_push_init_ (); |
1361 | GSF_put_init_(); | 1375 | GSF_put_init_ (); |
1362 | if ((GNUNET_OK != GNUNET_FS_indexing_init(cfg, | 1376 | if ((GNUNET_OK != GNUNET_FS_indexing_init (cfg, |
1363 | GSF_dsh)) || | 1377 | GSF_dsh)) || |
1364 | (GNUNET_OK != main_init(cfg))) | 1378 | (GNUNET_OK != main_init (cfg))) |
1365 | { | 1379 | { |
1366 | GNUNET_SCHEDULER_shutdown(); | 1380 | GNUNET_SCHEDULER_shutdown (); |
1367 | shutdown_task(NULL); | 1381 | shutdown_task (NULL); |
1368 | return; | 1382 | return; |
1369 | } | 1383 | } |
1370 | } | 1384 | } |
1371 | 1385 | ||
1372 | 1386 | ||
@@ -1380,27 +1394,27 @@ GNUNET_SERVICE_MAIN | |||
1380 | &client_connect_cb, | 1394 | &client_connect_cb, |
1381 | &client_disconnect_cb, | 1395 | &client_disconnect_cb, |
1382 | NULL, | 1396 | NULL, |
1383 | GNUNET_MQ_hd_var_size(client_index_start, | 1397 | GNUNET_MQ_hd_var_size (client_index_start, |
1384 | GNUNET_MESSAGE_TYPE_FS_INDEX_START, | 1398 | GNUNET_MESSAGE_TYPE_FS_INDEX_START, |
1385 | struct IndexStartMessage, | 1399 | struct IndexStartMessage, |
1386 | NULL), | 1400 | NULL), |
1387 | GNUNET_MQ_hd_fixed_size(client_index_list_get, | 1401 | GNUNET_MQ_hd_fixed_size (client_index_list_get, |
1388 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET, | 1402 | GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET, |
1389 | struct GNUNET_MessageHeader, | 1403 | struct GNUNET_MessageHeader, |
1390 | NULL), | 1404 | NULL), |
1391 | GNUNET_MQ_hd_fixed_size(client_unindex, | 1405 | GNUNET_MQ_hd_fixed_size (client_unindex, |
1392 | GNUNET_MESSAGE_TYPE_FS_UNINDEX, | 1406 | GNUNET_MESSAGE_TYPE_FS_UNINDEX, |
1393 | struct UnindexMessage, | 1407 | struct UnindexMessage, |
1394 | NULL), | 1408 | NULL), |
1395 | GNUNET_MQ_hd_var_size(client_start_search, | 1409 | GNUNET_MQ_hd_var_size (client_start_search, |
1396 | GNUNET_MESSAGE_TYPE_FS_START_SEARCH, | 1410 | GNUNET_MESSAGE_TYPE_FS_START_SEARCH, |
1397 | struct SearchMessage, | 1411 | struct SearchMessage, |
1398 | NULL), | 1412 | NULL), |
1399 | GNUNET_MQ_hd_fixed_size(client_loc_sign, | 1413 | GNUNET_MQ_hd_fixed_size (client_loc_sign, |
1400 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN, | 1414 | GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN, |
1401 | struct RequestLocSignatureMessage, | 1415 | struct RequestLocSignatureMessage, |
1402 | NULL), | 1416 | NULL), |
1403 | GNUNET_MQ_handler_end()); | 1417 | GNUNET_MQ_handler_end ()); |
1404 | 1418 | ||
1405 | 1419 | ||
1406 | /* end of gnunet-service-fs.c */ | 1420 | /* end of gnunet-service-fs.c */ |