diff options
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 251 |
1 files changed, 0 insertions, 251 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 49c165732..b3c077141 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -341,37 +341,6 @@ struct NickCache | |||
341 | }; | 341 | }; |
342 | 342 | ||
343 | /** | 343 | /** |
344 | * The default namestore ego | ||
345 | */ | ||
346 | struct EgoEntry | ||
347 | { | ||
348 | /** | ||
349 | * DLL | ||
350 | */ | ||
351 | struct EgoEntry *next; | ||
352 | |||
353 | /** | ||
354 | * DLL | ||
355 | */ | ||
356 | struct EgoEntry *prev; | ||
357 | |||
358 | /** | ||
359 | * Ego Identifier | ||
360 | */ | ||
361 | char *identifier; | ||
362 | |||
363 | /** | ||
364 | * Public key string | ||
365 | */ | ||
366 | char *keystring; | ||
367 | |||
368 | /** | ||
369 | * The Ego | ||
370 | */ | ||
371 | struct GNUNET_IDENTITY_Ego *ego; | ||
372 | }; | ||
373 | |||
374 | /** | ||
375 | * We cache nick records to reduce DB load. | 344 | * We cache nick records to reduce DB load. |
376 | */ | 345 | */ |
377 | static struct NickCache nick_cache[NC_SIZE]; | 346 | static struct NickCache nick_cache[NC_SIZE]; |
@@ -392,27 +361,6 @@ static const struct GNUNET_CONFIGURATION_Handle *GSN_cfg; | |||
392 | static struct GNUNET_STATISTICS_Handle *statistics; | 361 | static struct GNUNET_STATISTICS_Handle *statistics; |
393 | 362 | ||
394 | /** | 363 | /** |
395 | * Handle to the identity service | ||
396 | */ | ||
397 | static struct GNUNET_IDENTITY_Handle *identity_handle; | ||
398 | |||
399 | /** | ||
400 | * Indicator if we already have passed the first iteration if egos | ||
401 | */ | ||
402 | static int egos_collected = GNUNET_NO; | ||
403 | |||
404 | /** | ||
405 | * Ego list | ||
406 | */ | ||
407 | static struct EgoEntry *ego_head; | ||
408 | |||
409 | /** | ||
410 | * Ego list | ||
411 | */ | ||
412 | static struct EgoEntry *ego_tail; | ||
413 | |||
414 | |||
415 | /** | ||
416 | * Name of the database plugin | 364 | * Name of the database plugin |
417 | */ | 365 | */ |
418 | static char *db_lib_name; | 366 | static char *db_lib_name; |
@@ -461,9 +409,6 @@ static int return_orphaned; | |||
461 | static void | 409 | static void |
462 | cleanup_task (void *cls) | 410 | cleanup_task (void *cls) |
463 | { | 411 | { |
464 | struct EgoEntry *ego_entry; | ||
465 | struct EgoEntry *ego_tmp; | ||
466 | |||
467 | (void) cls; | 412 | (void) cls; |
468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n"); | 413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n"); |
469 | if (NULL != monitor_nc) | 414 | if (NULL != monitor_nc) |
@@ -476,20 +421,6 @@ cleanup_task (void *cls) | |||
476 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); | 421 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); |
477 | statistics = NULL; | 422 | statistics = NULL; |
478 | } | 423 | } |
479 | if (NULL != identity_handle) | ||
480 | { | ||
481 | GNUNET_IDENTITY_disconnect (identity_handle); | ||
482 | identity_handle = NULL; | ||
483 | // FIXME cleanup EgoEntries | ||
484 | } | ||
485 | for (ego_entry = ego_head; NULL != ego_entry;) | ||
486 | { | ||
487 | ego_tmp = ego_entry; | ||
488 | ego_entry = ego_entry->next; | ||
489 | GNUNET_free (ego_tmp->identifier); | ||
490 | GNUNET_free (ego_tmp->keystring); | ||
491 | GNUNET_free (ego_tmp); | ||
492 | } | ||
493 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, GSN_database)); | 424 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, GSN_database)); |
494 | GNUNET_free (db_lib_name); | 425 | GNUNET_free (db_lib_name); |
495 | db_lib_name = NULL; | 426 | db_lib_name = NULL; |
@@ -508,51 +439,6 @@ free_store_activity (struct StoreActivity *sa) | |||
508 | GNUNET_free (sa); | 439 | GNUNET_free (sa); |
509 | } | 440 | } |
510 | 441 | ||
511 | static enum GNUNET_GenericReturnValue | ||
512 | is_orphaned (const struct GNUNET_IDENTITY_PrivateKey *zone) | ||
513 | { | ||
514 | struct EgoEntry *ego_entry; | ||
515 | struct GNUNET_IDENTITY_PublicKey pk; | ||
516 | char *keystring; | ||
517 | |||
518 | GNUNET_IDENTITY_key_get_public (zone, &pk); | ||
519 | keystring = GNUNET_IDENTITY_public_key_to_string (&pk); | ||
520 | |||
521 | if (GNUNET_YES == return_orphaned) | ||
522 | return GNUNET_NO; | ||
523 | for (ego_entry = ego_head; NULL != ego_entry; | ||
524 | ego_entry = ego_entry->next) | ||
525 | { | ||
526 | if (0 == strcmp (ego_entry->keystring, keystring)) | ||
527 | break; | ||
528 | } | ||
529 | if (NULL != ego_entry) | ||
530 | { | ||
531 | GNUNET_free (keystring); | ||
532 | return GNUNET_NO; | ||
533 | } | ||
534 | /*if (purge_orphans) | ||
535 | { | ||
536 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
537 | "Removing orphaned zone data for ego %s\n", | ||
538 | ego_entry->keystring); | ||
539 | res = GSN_database->delete_records (GSN_database->cls, | ||
540 | zone, | ||
541 | &emsg); | ||
542 | if (GNUNET_SYSERR == res) | ||
543 | { | ||
544 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
545 | "Error removing orphaned zone data: %s\n", emsg); | ||
546 | } | ||
547 | }*/ | ||
548 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
549 | "Found orphaned zone data for zone key %s\n", | ||
550 | keystring); | ||
551 | GNUNET_free (keystring); | ||
552 | return GNUNET_YES; | ||
553 | } | ||
554 | |||
555 | |||
556 | /** | 442 | /** |
557 | * Function called with the records for the #GNUNET_GNS_EMPTY_LABEL_AT | 443 | * Function called with the records for the #GNUNET_GNS_EMPTY_LABEL_AT |
558 | * label in the zone. Used to locate the #GNUNET_GNSRECORD_TYPE_NICK | 444 | * label in the zone. Used to locate the #GNUNET_GNSRECORD_TYPE_NICK |
@@ -917,31 +803,6 @@ send_lookup_response_with_filter (struct NamestoreClient *nc, | |||
917 | } | 803 | } |
918 | 804 | ||
919 | /** | 805 | /** |
920 | * Generate a `struct LookupNameResponseMessage` and send it to the | ||
921 | * given client using the given notification context. | ||
922 | * | ||
923 | * @param nc client to unicast to | ||
924 | * @param request_id request ID to use | ||
925 | * @param zone_key zone key of the zone | ||
926 | * @param name name | ||
927 | * @param rd_count number of records in @a rd | ||
928 | * @param rd array of records | ||
929 | */ | ||
930 | static int | ||
931 | send_lookup_response (struct NamestoreClient *nc, | ||
932 | uint32_t request_id, | ||
933 | const struct | ||
934 | GNUNET_IDENTITY_PrivateKey *zone_key, | ||
935 | const char *name, | ||
936 | unsigned int rd_count, | ||
937 | const struct GNUNET_GNSRECORD_Data *rd) | ||
938 | { | ||
939 | return send_lookup_response_with_filter (nc, request_id, zone_key, name, | ||
940 | rd_count, rd, | ||
941 | GNUNET_GNSRECORD_FILTER_NONE); | ||
942 | } | ||
943 | |||
944 | /** | ||
945 | * Send response to the store request to the client. | 806 | * Send response to the store request to the client. |
946 | * | 807 | * |
947 | * @param nc client to talk to | 808 | * @param nc client to talk to |
@@ -2201,13 +2062,6 @@ zone_iterate_proc (void *cls, | |||
2201 | return; | 2062 | return; |
2202 | } | 2063 | } |
2203 | proc->zi->seq = seq; | 2064 | proc->zi->seq = seq; |
2204 | if (GNUNET_YES == is_orphaned (zone_key)) | ||
2205 | { | ||
2206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2207 | "Skipping orphaned zone data\n"); | ||
2208 | proc->run_again = GNUNET_YES; | ||
2209 | return; | ||
2210 | } | ||
2211 | if (0 < send_lookup_response_with_filter (proc->zi->nc, | 2065 | if (0 < send_lookup_response_with_filter (proc->zi->nc, |
2212 | proc->zi->request_id, | 2066 | proc->zi->request_id, |
2213 | zone_key, | 2067 | zone_key, |
@@ -2471,13 +2325,6 @@ monitor_iterate_cb (void *cls, | |||
2471 | "Monitor notifications sent", | 2325 | "Monitor notifications sent", |
2472 | 1, | 2326 | 1, |
2473 | GNUNET_NO); | 2327 | GNUNET_NO); |
2474 | if (GNUNET_YES == is_orphaned (zone_key)) | ||
2475 | { | ||
2476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2477 | "Skipping orphaned zone data\n"); | ||
2478 | zm->run_again = GNUNET_YES; | ||
2479 | return; | ||
2480 | } | ||
2481 | if (0 < send_lookup_response_with_filter (zm->nc, 0, zone_key, name, | 2328 | if (0 < send_lookup_response_with_filter (zm->nc, 0, zone_key, name, |
2482 | rd_count, rd, zm->filter)) | 2329 | rd_count, rd, zm->filter)) |
2483 | { | 2330 | { |
@@ -2635,100 +2482,6 @@ handle_monitor_next (void *cls, const struct ZoneMonitorNextMessage *nm) | |||
2635 | } | 2482 | } |
2636 | } | 2483 | } |
2637 | 2484 | ||
2638 | static void | ||
2639 | ego_callback (void *cls, | ||
2640 | struct GNUNET_IDENTITY_Ego *ego, | ||
2641 | void **ctx, | ||
2642 | const char *identifier) | ||
2643 | { | ||
2644 | struct EgoEntry *ego_entry; | ||
2645 | struct GNUNET_SERVICE_Handle *service = cls; | ||
2646 | struct GNUNET_IDENTITY_PublicKey pk; | ||
2647 | |||
2648 | if ((NULL == ego) && (GNUNET_NO == egos_collected)) | ||
2649 | { | ||
2650 | egos_collected = GNUNET_YES; | ||
2651 | GNUNET_SERVICE_resume (service); | ||
2652 | return; | ||
2653 | } | ||
2654 | if (NULL == ego) | ||
2655 | { | ||
2656 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2657 | "Called with NULL ego\n"); | ||
2658 | return; | ||
2659 | } | ||
2660 | if ((GNUNET_NO == egos_collected) && | ||
2661 | (NULL != identifier)) | ||
2662 | { | ||
2663 | ego_entry = GNUNET_new (struct EgoEntry); | ||
2664 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
2665 | ego_entry->keystring = GNUNET_IDENTITY_public_key_to_string (&pk); | ||
2666 | ego_entry->ego = ego; | ||
2667 | ego_entry->identifier = GNUNET_strdup (identifier); | ||
2668 | GNUNET_CONTAINER_DLL_insert_tail (ego_head, | ||
2669 | ego_tail, | ||
2670 | ego_entry); | ||
2671 | return; | ||
2672 | } | ||
2673 | /* Ego renamed or added */ | ||
2674 | if (identifier != NULL) | ||
2675 | { | ||
2676 | for (ego_entry = ego_head; NULL != ego_entry; | ||
2677 | ego_entry = ego_entry->next) | ||
2678 | { | ||
2679 | if (ego_entry->ego == ego) | ||
2680 | { | ||
2681 | /* Rename */ | ||
2682 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2683 | "Renaming ego %s->%s\n", ego_entry->identifier, | ||
2684 | identifier); | ||
2685 | GNUNET_free (ego_entry->identifier); | ||
2686 | ego_entry->identifier = GNUNET_strdup (identifier); | ||
2687 | break; | ||
2688 | } | ||
2689 | } | ||
2690 | if (NULL == ego_entry) | ||
2691 | { | ||
2692 | /* Add */ | ||
2693 | ego_entry = GNUNET_new (struct EgoEntry); | ||
2694 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | ||
2695 | ego_entry->keystring = GNUNET_IDENTITY_public_key_to_string (&pk); | ||
2696 | ego_entry->ego = ego; | ||
2697 | ego_entry->identifier = GNUNET_strdup (identifier); | ||
2698 | GNUNET_CONTAINER_DLL_insert_tail (ego_head, | ||
2699 | ego_tail, | ||
2700 | ego_entry); | ||
2701 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2702 | "Added ego %s\n", ego_entry->identifier); | ||
2703 | } | ||
2704 | } | ||
2705 | else | ||
2706 | { | ||
2707 | /* Delete */ | ||
2708 | for (ego_entry = ego_head; NULL != ego_entry; | ||
2709 | ego_entry = ego_entry->next) | ||
2710 | { | ||
2711 | if (ego_entry->ego == ego) | ||
2712 | break; | ||
2713 | } | ||
2714 | if (NULL == ego_entry) | ||
2715 | return; /* Not found */ | ||
2716 | |||
2717 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2718 | "Removing ego %s\n", ego_entry->identifier); | ||
2719 | GNUNET_CONTAINER_DLL_remove (ego_head, | ||
2720 | ego_tail, | ||
2721 | ego_entry); | ||
2722 | GNUNET_free (ego_entry->identifier); | ||
2723 | GNUNET_free (ego_entry->keystring); | ||
2724 | GNUNET_free (ego_entry); | ||
2725 | return; | ||
2726 | } | ||
2727 | |||
2728 | } | ||
2729 | |||
2730 | |||
2731 | |||
2732 | /** | 2485 | /** |
2733 | * Process namestore requests. | 2486 | * Process namestore requests. |
2734 | * | 2487 | * |
@@ -2773,10 +2526,6 @@ run (void *cls, | |||
2773 | GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); | 2526 | GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); |
2774 | return; | 2527 | return; |
2775 | } | 2528 | } |
2776 | egos_collected = GNUNET_NO; | ||
2777 | /** Suspend until we have all egos */ | ||
2778 | GNUNET_SERVICE_suspend (service); | ||
2779 | identity_handle = GNUNET_IDENTITY_connect (cfg, &ego_callback, service); | ||
2780 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); | 2529 | GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); |
2781 | } | 2530 | } |
2782 | 2531 | ||