aboutsummaryrefslogtreecommitdiff
path: root/src/identity
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
parent8d689d0293e48b14377db1dc4e237980183a0b28 (diff)
downloadgnunet-e885868546bafeba87461678102bc4644065a1ba.tar.gz
gnunet-e885868546bafeba87461678102bc4644065a1ba.zip
-identity API bugfixes
Diffstat (limited to 'src/identity')
-rw-r--r--src/identity/gnunet-service-identity.c14
-rw-r--r--src/identity/identity_api.c44
-rw-r--r--src/identity/test_identity.c3
3 files changed, 54 insertions, 7 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index ec874fa6f..fe6c3efa7 100644
--- 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,
191 rcm->header.size = htons (sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) + elen); 191 rcm->header.size = htons (sizeof (struct GNUNET_IDENTITY_ResultCodeMessage) + elen);
192 rcm->result_code = htonl (result_code); 192 rcm->result_code = htonl (result_code);
193 memcpy (&rcm[1], emsg, elen); 193 memcpy (&rcm[1], emsg, elen);
194 GNUNET_SERVER_notification_context_unicast (nc, client, &rcm->header, GNUNET_YES); 194 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
195 "Sending result %d (%s) to client\n",
196 (int) result_code,
197 emsg);
198 GNUNET_SERVER_notification_context_unicast (nc, client, &rcm->header, GNUNET_NO);
195 GNUNET_free (rcm); 199 GNUNET_free (rcm);
196} 200}
197 201
@@ -284,14 +288,14 @@ handle_start_message (void *cls, struct GNUNET_SERVER_Client *client,
284 for (ego = ego_head; NULL != ego; ego = ego->next) 288 for (ego = ego_head; NULL != ego; ego = ego->next)
285 { 289 {
286 um = create_update_message (ego); 290 um = create_update_message (ego);
287 GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_YES); 291 GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_NO);
288 GNUNET_free (um); 292 GNUNET_free (um);
289 } 293 }
290 ume.header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 294 ume.header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
291 ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage)); 295 ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage));
292 ume.pk_len = htons (0); 296 ume.pk_len = htons (0);
293 ume.name_len = htons (0); 297 ume.name_len = htons (0);
294 GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_YES); 298 GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO);
295 GNUNET_SERVER_receive_done (client, GNUNET_OK); 299 GNUNET_SERVER_receive_done (client, GNUNET_OK);
296} 300}
297 301
@@ -353,7 +357,7 @@ handle_get_default_message (void *cls, struct GNUNET_SERVER_Client *client,
353 { 357 {
354 sdm = create_set_default_message (ego, 358 sdm = create_set_default_message (ego,
355 name); 359 name);
356 GNUNET_SERVER_notification_context_broadcast (nc, &sdm->header, GNUNET_YES); 360 GNUNET_SERVER_notification_context_broadcast (nc, &sdm->header, GNUNET_NO);
357 GNUNET_free (sdm); 361 GNUNET_free (sdm);
358 GNUNET_SERVER_receive_done (client, GNUNET_OK); 362 GNUNET_SERVER_receive_done (client, GNUNET_OK);
359 return; 363 return;
@@ -470,7 +474,7 @@ notify_listeners (struct Ego *ego)
470 struct GNUNET_IDENTITY_UpdateMessage *um; 474 struct GNUNET_IDENTITY_UpdateMessage *um;
471 475
472 um = create_update_message (ego); 476 um = create_update_message (ego);
473 GNUNET_SERVER_notification_context_broadcast (nc, &um->header, GNUNET_YES); 477 GNUNET_SERVER_notification_context_broadcast (nc, &um->header, GNUNET_NO);
474 GNUNET_free (um); 478 GNUNET_free (um);
475} 479}
476 480
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);
diff --git a/src/identity/test_identity.c b/src/identity/test_identity.c
index 02bf341e8..7c429770b 100644
--- a/src/identity/test_identity.c
+++ b/src/identity/test_identity.c
@@ -134,6 +134,7 @@ notification_cb (void *cls,
134 void **ctx, 134 void **ctx,
135 const char *identifier) 135 const char *identifier)
136{ 136{
137 // fprintf (stderr, "Notification: %s\n", identifier);
137} 138}
138 139
139 140
@@ -155,7 +156,7 @@ create_cb (void *cls,
155 const char *identifier) 156 const char *identifier)
156{ 157{
157 op = NULL; 158 op = NULL;
158 fprintf (stderr, "HERE!\n"); 159 // fprintf (stderr, "HERE!\n");
159 end (); /* yepee */ 160 end (); /* yepee */
160} 161}
161 162