gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28108 - gnunet/src/identity


From: gnunet
Subject: [GNUnet-SVN] r28108 - gnunet/src/identity
Date: Wed, 17 Jul 2013 12:33:30 +0200

Author: grothoff
Date: 2013-07-17 12:33:29 +0200 (Wed, 17 Jul 2013)
New Revision: 28108

Modified:
   gnunet/src/identity/gnunet-service-identity.c
   gnunet/src/identity/identity_api.c
   gnunet/src/identity/test_identity.c
Log:
-identity API bugfixes

Modified: gnunet/src/identity/gnunet-service-identity.c
===================================================================
--- gnunet/src/identity/gnunet-service-identity.c       2013-07-17 10:27:46 UTC 
(rev 28107)
+++ gnunet/src/identity/gnunet-service-identity.c       2013-07-17 10:33:29 UTC 
(rev 28108)
@@ -191,7 +191,11 @@
   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 @@
   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 @@
     {
       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 @@
   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);
 }
 

Modified: gnunet/src/identity/identity_api.c
===================================================================
--- gnunet/src/identity/identity_api.c  2013-07-17 10:27:46 UTC (rev 28107)
+++ gnunet/src/identity/identity_api.c  2013-07-17 10:33:29 UTC (rev 28108)
@@ -247,6 +247,9 @@
     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 @@
       /* 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 @@
     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 @@
   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 @@
 
 
 /**
+ * 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_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);

Modified: gnunet/src/identity/test_identity.c
===================================================================
--- gnunet/src/identity/test_identity.c 2013-07-17 10:27:46 UTC (rev 28107)
+++ gnunet/src/identity/test_identity.c 2013-07-17 10:33:29 UTC (rev 28108)
@@ -134,6 +134,7 @@
                 void **ctx,
                 const char *identifier)
 {
+  // fprintf (stderr, "Notification: %s\n", identifier);
 }
 
 
@@ -155,7 +156,7 @@
           const char *identifier)
 {
   op = NULL;
-  fprintf (stderr, "HERE!\n");
+  // fprintf (stderr, "HERE!\n");
   end (); /* yepee */
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]