diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-24 16:12:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-24 16:12:57 +0000 |
commit | f91123615aafcc5fb7452d6a67945f979941cdc4 (patch) | |
tree | 9fb492eded731fd4f0f2c4a20b4a5b60bfc6acdc /src/namestore/gnunet-namestore.c | |
parent | 6811cb762f1edb84fc312ad955e2fb05c047c24d (diff) | |
download | gnunet-f91123615aafcc5fb7452d6a67945f979941cdc4.tar.gz gnunet-f91123615aafcc5fb7452d6a67945f979941cdc4.zip |
-use new ego lookup function to simplify logic
Diffstat (limited to 'src/namestore/gnunet-namestore.c')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 58 |
1 files changed, 25 insertions, 33 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 0a8db7eed..b4e5d714c 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -1,3 +1,4 @@ | |||
1 | |||
1 | /* | 2 | /* |
2 | This file is part of GNUnet. | 3 | This file is part of GNUnet. |
3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) | 4 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) |
@@ -45,9 +46,9 @@ static struct GNUNET_NAMESTORE_Handle *ns; | |||
45 | static struct GNUNET_CRYPTO_EccPrivateKey zone_pkey; | 46 | static struct GNUNET_CRYPTO_EccPrivateKey zone_pkey; |
46 | 47 | ||
47 | /** | 48 | /** |
48 | * Handle to identity service. | 49 | * Handle to identity lookup. |
49 | */ | 50 | */ |
50 | static struct GNUNET_IDENTITY_Handle *identity; | 51 | static struct GNUNET_IDENTITY_EgoLookup *el; |
51 | 52 | ||
52 | /** | 53 | /** |
53 | * Name of the ego controlling the zone. | 54 | * Name of the ego controlling the zone. |
@@ -185,6 +186,11 @@ static void | |||
185 | do_shutdown (void *cls, | 186 | do_shutdown (void *cls, |
186 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 187 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
187 | { | 188 | { |
189 | if (NULL != el) | ||
190 | { | ||
191 | GNUNET_IDENTITY_ego_lookup_cancel (el); | ||
192 | el = NULL; | ||
193 | } | ||
188 | if (NULL != list_it) | 194 | if (NULL != list_it) |
189 | { | 195 | { |
190 | GNUNET_NAMESTORE_zone_iteration_stop (list_it); | 196 | GNUNET_NAMESTORE_zone_iteration_stop (list_it); |
@@ -448,8 +454,6 @@ testservice_task (void *cls, | |||
448 | _("Failed to connect to namestore\n")); | 454 | _("Failed to connect to namestore\n")); |
449 | return; | 455 | return; |
450 | } | 456 | } |
451 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | ||
452 | &do_shutdown, NULL); | ||
453 | if (add) | 457 | if (add) |
454 | { | 458 | { |
455 | if (NULL == name) | 459 | if (NULL == name) |
@@ -621,47 +625,32 @@ testservice_task (void *cls, | |||
621 | 625 | ||
622 | /** | 626 | /** |
623 | * Callback invoked from identity service with ego information. | 627 | * Callback invoked from identity service with ego information. |
624 | * An @a ego of NULL and a @a name of NULL indicate the end of | 628 | * An @a ego of NULL means the ego was not found. |
625 | * the initial iteration over known egos. | ||
626 | * | 629 | * |
627 | * @param cls closure with the configuration | 630 | * @param cls closure with the configuration |
628 | * @param ego an ego known to identity service, or NULL | 631 | * @param ego an ego known to identity service, or NULL |
629 | * @param ctx per-ego user context (unused) | ||
630 | * @param name name of the ego, or NULL | ||
631 | */ | 632 | */ |
632 | static void | 633 | static void |
633 | identity_cb (void *cls, | 634 | identity_cb (void *cls, |
634 | struct GNUNET_IDENTITY_Ego *ego, | 635 | const struct GNUNET_IDENTITY_Ego *ego) |
635 | void **ctx, | ||
636 | const char *name) | ||
637 | { | 636 | { |
638 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 637 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
639 | 638 | ||
640 | if ( (NULL != ego_name) && | 639 | el = NULL; |
641 | (0 == strcmp (name, | 640 | if (NULL == ego) |
642 | ego_name)) ) | ||
643 | { | ||
644 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); | ||
645 | GNUNET_free (ego_name); | ||
646 | ego_name = NULL; | ||
647 | GNUNET_CLIENT_service_test ("namestore", cfg, | ||
648 | GNUNET_TIME_UNIT_SECONDS, | ||
649 | &testservice_task, | ||
650 | (void *) cfg); | ||
651 | GNUNET_IDENTITY_disconnect (identity); | ||
652 | identity = NULL; | ||
653 | } | ||
654 | if ( (NULL != ego_name) && | ||
655 | (NULL == name) && | ||
656 | (NULL == ego) ) | ||
657 | { | 641 | { |
658 | fprintf (stderr, | 642 | fprintf (stderr, |
659 | _("Ego `%s' not known to identity service\n"), | 643 | _("Ego `%s' not known to identity service\n"), |
660 | ego_name); | 644 | ego_name); |
661 | GNUNET_IDENTITY_disconnect (identity); | ||
662 | identity = NULL; | ||
663 | return; | 645 | return; |
664 | } | 646 | } |
647 | zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego); | ||
648 | GNUNET_free (ego_name); | ||
649 | ego_name = NULL; | ||
650 | GNUNET_CLIENT_service_test ("namestore", cfg, | ||
651 | GNUNET_TIME_UNIT_SECONDS, | ||
652 | &testservice_task, | ||
653 | (void *) cfg); | ||
665 | } | 654 | } |
666 | 655 | ||
667 | 656 | ||
@@ -685,9 +674,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
685 | } | 674 | } |
686 | if ( (NULL != args[0]) && (NULL == uri) ) | 675 | if ( (NULL != args[0]) && (NULL == uri) ) |
687 | uri = GNUNET_strdup (args[0]); | 676 | uri = GNUNET_strdup (args[0]); |
688 | identity = GNUNET_IDENTITY_connect (cfg, | 677 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
689 | &identity_cb, | 678 | &do_shutdown, NULL); |
690 | (void *) cfg); | 679 | el = GNUNET_IDENTITY_ego_lookup (cfg, |
680 | ego_name, | ||
681 | &identity_cb, | ||
682 | (void *) cfg); | ||
691 | } | 683 | } |
692 | 684 | ||
693 | 685 | ||