aboutsummaryrefslogtreecommitdiff
path: root/src/identity
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-15 23:46:00 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-15 23:46:00 +0200
commita99752d30c73cd5040c9da3c05da3bbc2dc1b67e (patch)
tree4319210d4664aa3354404e67911ebe771b1e43f3 /src/identity
parentb3ddc93861a6a171eee7c855f83c7a1314f6eaf9 (diff)
downloadgnunet-a99752d30c73cd5040c9da3c05da3bbc2dc1b67e.tar.gz
gnunet-a99752d30c73cd5040c9da3c05da3bbc2dc1b67e.zip
fix gnunet-gns performance issue for many egos
Diffstat (limited to 'src/identity')
-rw-r--r--src/identity/Makefile.am1
-rw-r--r--src/identity/gnunet-service-identity.c71
-rw-r--r--src/identity/identity.h3
3 files changed, 74 insertions, 1 deletions
diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am
index 6e587dc86..476d981bb 100644
--- a/src/identity/Makefile.am
+++ b/src/identity/Makefile.am
@@ -43,6 +43,7 @@ libgnunet_plugin_rest_identity_la_LDFLAGS = \
43libgnunetidentity_la_SOURCES = \ 43libgnunetidentity_la_SOURCES = \
44 identity_api.c \ 44 identity_api.c \
45 identity_api_lookup.c \ 45 identity_api_lookup.c \
46 identity_api_suffix_lookup.c \
46 identity.h 47 identity.h
47libgnunetidentity_la_LIBADD = \ 48libgnunetidentity_la_LIBADD = \
48 $(top_builddir)/src/util/libgnunetutil.la \ 49 $(top_builddir)/src/util/libgnunetutil.la \
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index a675a01f0..3e92a04cd 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -378,6 +378,73 @@ handle_lookup_message (void *cls,
378 378
379 379
380/** 380/**
381 * Handler for LOOKUP message from client, sends information
382 * about ONE identity to the client immediately.
383 *
384 * @param cls unused
385 * @param message the message received
386 * @return #GNUNET_SYSERR if message was ill-formed
387 */
388static int
389check_lookup_by_suffix_message (void *cls,
390 const struct LookupMessage *message)
391{
392 GNUNET_MQ_check_zero_termination (message);
393 return GNUNET_OK;
394}
395
396
397/**
398 * Handler for LOOKUP_BY_SUFFIX message from client, sends information
399 * about ONE identity to the client immediately.
400 *
401 * @param cls a `struct GNUNET_SERVICE_Client *`
402 * @param message the message received
403 */
404static void
405handle_lookup_by_suffix_message (void *cls,
406 const struct LookupMessage *message)
407{
408 struct GNUNET_SERVICE_Client *client = cls;
409 const char *name;
410 struct GNUNET_MQ_Envelope *env;
411 struct Ego *lprefix;
412
413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
414 "Received LOOKUP_BY_SUFFIX message from client\n");
415 name = (const char *) &message[1];
416 lprefix = NULL;
417 for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next)
418 {
419
420 if ((strlen (ego->identifier) <= strlen (name)) &&
421 (0 == strcmp (ego->identifier,
422 &name[strlen (name) - strlen (ego->identifier)])) &&
423 ((strlen (name) == strlen (ego->identifier)) ||
424 ('.' == name[strlen (name) -
425 strlen (ego->identifier) - 1])) &&
426 ((NULL == lprefix) ||
427 (strlen (ego->identifier) > strlen (lprefix->identifier))))
428 {
429 /* found better match, update! */
430 lprefix = ego;
431 }
432 }
433 if (NULL != lprefix)
434 {
435 env = create_update_message (lprefix);
436 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
437 GNUNET_SERVICE_client_continue (client);
438 return;
439 }
440 send_result_code (client,
441 0,
442 "ego not found");
443 GNUNET_SERVICE_client_continue (client);
444}
445
446
447/**
381 * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message 448 * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message
382 * 449 *
383 * @param cls client sending the message 450 * @param cls client sending the message
@@ -1118,6 +1185,10 @@ GNUNET_SERVICE_MAIN
1118 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, 1185 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP,
1119 struct LookupMessage, 1186 struct LookupMessage,
1120 NULL), 1187 NULL),
1188 GNUNET_MQ_hd_var_size (lookup_by_suffix_message,
1189 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX,
1190 struct LookupMessage,
1191 NULL),
1121 GNUNET_MQ_hd_var_size (get_default_message, 1192 GNUNET_MQ_hd_var_size (get_default_message,
1122 GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, 1193 GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT,
1123 struct GetDefaultMessage, 1194 struct GetDefaultMessage,
diff --git a/src/identity/identity.h b/src/identity/identity.h
index 96550bdf2..6ef16e39d 100644
--- a/src/identity/identity.h
+++ b/src/identity/identity.h
@@ -62,7 +62,8 @@ struct ResultCodeMessage
62struct LookupMessage 62struct LookupMessage
63{ 63{
64 /** 64 /**
65 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP 65 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP or
66 * #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX
66 */ 67 */
67 struct GNUNET_MessageHeader header; 68 struct GNUNET_MessageHeader header;
68 69