gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit e885868546bafeba87461678102bc4644065a1ba
parent 8d689d0293e48b14377db1dc4e237980183a0b28
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 17 Jul 2013 10:33:29 +0000

-identity API bugfixes

Diffstat:
Msrc/identity/gnunet-service-identity.c | 14+++++++++-----
Msrc/identity/identity_api.c | 44+++++++++++++++++++++++++++++++++++++++++++-
Msrc/identity/test_identity.c | 3++-
3 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c @@ -191,7 +191,11 @@ send_result_code (struct GNUNET_SERVER_Client *client, rcm->header.size = htons (sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) + elen); rcm->result_code = htonl (result_code); memcpy (&rcm[1], emsg, elen); - GNUNET_SERVER_notification_context_unicast (nc, client, &rcm->header, GNUNET_YES); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Sending result %d (%s) to client\n", + (int) result_code, + emsg); + GNUNET_SERVER_notification_context_unicast (nc, client, &rcm->header, GNUNET_NO); GNUNET_free (rcm); } @@ -284,14 +288,14 @@ handle_start_message (void *cls, struct GNUNET_SERVER_Client *client, for (ego = ego_head; NULL != ego; ego = ego->next) { um = create_update_message (ego); - GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_YES); + GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_NO); GNUNET_free (um); } ume.header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage)); ume.pk_len = htons (0); ume.name_len = htons (0); - GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_YES); + GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO); GNUNET_SERVER_receive_done (client, GNUNET_OK); } @@ -353,7 +357,7 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client, { sdm = create_set_default_message (ego, name); - GNUNET_SERVER_notification_context_broadcast (nc, &sdm->header, GNUNET_YES); + GNUNET_SERVER_notification_context_broadcast (nc, &sdm->header, GNUNET_NO); GNUNET_free (sdm); GNUNET_SERVER_receive_done (client, GNUNET_OK); return; @@ -470,7 +474,7 @@ notify_listeners (struct Ego *ego) struct GNUNET_IDENTITY_UpdateMessage *um; um = create_update_message (ego); - GNUNET_SERVER_notification_context_broadcast (nc, &um->header, GNUNET_YES); + GNUNET_SERVER_notification_context_broadcast (nc, &um->header, GNUNET_NO); GNUNET_free (um); } diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c @@ -247,6 +247,9 @@ message_handler (void *cls, reschedule_connect (h); return; } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Received message of type %d from identity service\n", + ntohs (msg->type)); size = ntohs (msg->size); switch (ntohs (msg->type)) { @@ -305,7 +308,7 @@ message_handler (void *cls, /* end of initial list of data */ if (NULL != h->cb) h->cb (h->cb_cls, NULL, NULL, NULL); - return; + break; } priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); if (NULL == priv) @@ -470,6 +473,9 @@ send_next_message (void *cls, reschedule_connect (h); return 0; } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Sending message of type %d to identity service\n", + ntohs (op->msg->type)); memcpy (buf, op->msg, ret); if ( (NULL == op->cont) && (NULL == op->cb) ) @@ -568,6 +574,7 @@ GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, h->cfg = cfg; h->cb = cb; h->cb_cls = cb_cls; + h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES); h->reconnect_delay = GNUNET_TIME_UNIT_ZERO; h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h); return h; @@ -902,6 +909,33 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) /** + * Free ego from hash map. + * + * @param cls identity service handle + * @param key unused + * @param value ego to free + * @return GNUNET_OK (continue to iterate) + */ +static int +free_ego (void *cls, + const struct GNUNET_HashCode *key, + void *value) +{ + struct GNUNET_IDENTITY_Handle *h = cls; + struct GNUNET_IDENTITY_Ego *ego = value; + + h->cb (h->cb_cls, + ego, + &ego->ctx, + NULL); + GNUNET_CRYPTO_ecc_key_free (ego->pk); + GNUNET_free (ego->identifier); + GNUNET_free (ego); + return GNUNET_OK; +} + + +/** * Disconnect from identity service * * @param h handle to destroy @@ -921,6 +955,14 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h) GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); h->th = NULL; } + if (NULL != h->egos) + { + GNUNET_CONTAINER_multihashmap_iterate (h->egos, + &free_ego, + h); + GNUNET_CONTAINER_multihashmap_destroy (h->egos); + h->egos = NULL; + } if (NULL != h->client) { GNUNET_CLIENT_disconnect (h->client); diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c @@ -134,6 +134,7 @@ notification_cb (void *cls, void **ctx, const char *identifier) { + // fprintf (stderr, "Notification: %s\n", identifier); } @@ -155,7 +156,7 @@ create_cb (void *cls, const char *identifier) { op = NULL; - fprintf (stderr, "HERE!\n"); + // fprintf (stderr, "HERE!\n"); end (); /* yepee */ }