aboutsummaryrefslogtreecommitdiff
path: root/src/identity/identity_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-07-17 10:33:29 +0000
committerChristian Grothoff <christian@grothoff.org>2013-07-17 10:33:29 +0000
commite885868546bafeba87461678102bc4644065a1ba (patch)
tree85fa4d655955987129101515049a7a48fb3d99dc /src/identity/identity_api.c
parent8d689d0293e48b14377db1dc4e237980183a0b28 (diff)
downloadgnunet-e885868546bafeba87461678102bc4644065a1ba.tar.gz
gnunet-e885868546bafeba87461678102bc4644065a1ba.zip
-identity API bugfixes
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r--src/identity/identity_api.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 15a454e60..e5c871bbe 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -247,6 +247,9 @@ message_handler (void *cls,
247 reschedule_connect (h); 247 reschedule_connect (h);
248 return; 248 return;
249 } 249 }
250 LOG (GNUNET_ERROR_TYPE_DEBUG,
251 "Received message of type %d from identity service\n",
252 ntohs (msg->type));
250 size = ntohs (msg->size); 253 size = ntohs (msg->size);
251 switch (ntohs (msg->type)) 254 switch (ntohs (msg->type))
252 { 255 {
@@ -305,7 +308,7 @@ message_handler (void *cls,
305 /* end of initial list of data */ 308 /* end of initial list of data */
306 if (NULL != h->cb) 309 if (NULL != h->cb)
307 h->cb (h->cb_cls, NULL, NULL, NULL); 310 h->cb (h->cb_cls, NULL, NULL, NULL);
308 return; 311 break;
309 } 312 }
310 priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); 313 priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES);
311 if (NULL == priv) 314 if (NULL == priv)
@@ -470,6 +473,9 @@ send_next_message (void *cls,
470 reschedule_connect (h); 473 reschedule_connect (h);
471 return 0; 474 return 0;
472 } 475 }
476 LOG (GNUNET_ERROR_TYPE_DEBUG,
477 "Sending message of type %d to identity service\n",
478 ntohs (op->msg->type));
473 memcpy (buf, op->msg, ret); 479 memcpy (buf, op->msg, ret);
474 if ( (NULL == op->cont) && 480 if ( (NULL == op->cont) &&
475 (NULL == op->cb) ) 481 (NULL == op->cb) )
@@ -568,6 +574,7 @@ GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
568 h->cfg = cfg; 574 h->cfg = cfg;
569 h->cb = cb; 575 h->cb = cb;
570 h->cb_cls = cb_cls; 576 h->cb_cls = cb_cls;
577 h->egos = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
571 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO; 578 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
572 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h); 579 h->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, h);
573 return h; 580 return h;
@@ -902,6 +909,33 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op)
902 909
903 910
904/** 911/**
912 * Free ego from hash map.
913 *
914 * @param cls identity service handle
915 * @param key unused
916 * @param value ego to free
917 * @return GNUNET_OK (continue to iterate)
918 */
919static int
920free_ego (void *cls,
921 const struct GNUNET_HashCode *key,
922 void *value)
923{
924 struct GNUNET_IDENTITY_Handle *h = cls;
925 struct GNUNET_IDENTITY_Ego *ego = value;
926
927 h->cb (h->cb_cls,
928 ego,
929 &ego->ctx,
930 NULL);
931 GNUNET_CRYPTO_ecc_key_free (ego->pk);
932 GNUNET_free (ego->identifier);
933 GNUNET_free (ego);
934 return GNUNET_OK;
935}
936
937
938/**
905 * Disconnect from identity service 939 * Disconnect from identity service
906 * 940 *
907 * @param h handle to destroy 941 * @param h handle to destroy
@@ -921,6 +955,14 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h)
921 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th); 955 GNUNET_CLIENT_notify_transmit_ready_cancel (h->th);
922 h->th = NULL; 956 h->th = NULL;
923 } 957 }
958 if (NULL != h->egos)
959 {
960 GNUNET_CONTAINER_multihashmap_iterate (h->egos,
961 &free_ego,
962 h);
963 GNUNET_CONTAINER_multihashmap_destroy (h->egos);
964 h->egos = NULL;
965 }
924 if (NULL != h->client) 966 if (NULL != h->client)
925 { 967 {
926 GNUNET_CLIENT_disconnect (h->client); 968 GNUNET_CLIENT_disconnect (h->client);