From 9f03df3be26e78853cc0d2288d2260b9032126cb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 1 Jun 2019 00:58:06 +0200 Subject: [PATCH] improve performance of identity_api_lookup.c logic to not be O(n) --- src/identity/identity_api.c | 2 ++ src/identity/test_identity_defaults.c | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index fa7c8b023..c463da641 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c @@ -596,6 +596,7 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, if (NULL == h->mq) return NULL; + GNUNET_assert (NULL != h->cb); slen = strlen (service_name) + 1; if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage)) { @@ -641,6 +642,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, if (NULL == h->mq) return NULL; + GNUNET_assert (NULL != h->cb); slen = strlen (service_name) + 1; if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage)) { diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c index ecda31c4c..71e70e7ba 100644 --- a/src/identity/test_identity_defaults.c +++ b/src/identity/test_identity_defaults.c @@ -148,6 +148,30 @@ get_cb (void *cls, } +/** + * Called with events about egos. + * + * @param cls NULL + * @param ego ego handle + * @param ego_ctx context for application to store data for this ego + * (during the lifetime of this process, initially NULL) + * @param identifier identifier assigned by the user for this ego, + * NULL if the user just deleted the ego and it + * must thus no longer be used + */ +static void +dummy_cb (void *cls, + struct GNUNET_IDENTITY_Ego *ego, + void **ctx, + const char *identifier) +{ + (void) cls; + (void) ego; + (void) ctx; + (void) identifier; +} + + /** * Main function of the test, run from scheduler. * @@ -162,7 +186,7 @@ run_get (void *cls, { endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); - h = GNUNET_IDENTITY_connect (cfg, NULL, NULL); + h = GNUNET_IDENTITY_connect (cfg, &dummy_cb, NULL); CHECK (NULL != h); op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL); } -- 2.25.1