gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20377 - gnunet/src/namestore


From: gnunet
Subject: [GNUnet-SVN] r20377 - gnunet/src/namestore
Date: Thu, 8 Mar 2012 18:58:05 +0100

Author: wachs
Date: 2012-03-08 18:58:05 +0100 (Thu, 08 Mar 2012)
New Revision: 20377

Modified:
   gnunet/src/namestore/Makefile.am
   gnunet/src/namestore/gnunet-service-namestore.c
Log:
- extradist and hashmap


Modified: gnunet/src/namestore/Makefile.am
===================================================================
--- gnunet/src/namestore/Makefile.am    2012-03-08 17:28:59 UTC (rev 20376)
+++ gnunet/src/namestore/Makefile.am    2012-03-08 17:58:05 UTC (rev 20377)
@@ -193,8 +193,8 @@
 EXTRA_DIST = \
   test_namestore_api.conf \
   test_plugin_namestore_sqlite.conf\
-  hostkey \
-  hostkey2
+  
zonefiles/4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.zone
 \
+  
zonefiles/KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zone
 
 
 test_plugin_namestore_sqlite_SOURCES = \

Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c     2012-03-08 17:28:59 UTC 
(rev 20376)
+++ gnunet/src/namestore/gnunet-service-namestore.c     2012-03-08 17:58:05 UTC 
(rev 20377)
@@ -71,9 +71,6 @@
 
 struct GNUNET_NAMESTORE_CryptoContainer
 {
-  struct GNUNET_NAMESTORE_CryptoContainer *next;
-  struct GNUNET_NAMESTORE_CryptoContainer *prev;
-
   char * filename;
 
   GNUNET_HashCode zone;
@@ -108,8 +105,7 @@
 static struct GNUNET_NAMESTORE_Client *client_head;
 static struct GNUNET_NAMESTORE_Client *client_tail;
 
-struct GNUNET_NAMESTORE_CryptoContainer *c_head;
-struct GNUNET_NAMESTORE_CryptoContainer *c_tail;
+struct GNUNET_CONTAINER_MultiHashMap *zonekeys;
 
 
 /**
@@ -192,7 +188,30 @@
   return GNUNET_OK;
 }
 
+int zone_to_disk_it (void *cls,
+                     const GNUNET_HashCode * key,
+                     void *value)
+{
+  struct GNUNET_NAMESTORE_CryptoContainer * c = value;
 
+  if (c->filename != NULL)
+    write_key_to_file(c->filename, c);
+  else
+  {
+    GNUNET_asprintf(&c->filename, "%s/%s.zone", zonefile_directory, 
GNUNET_h2s_full (&c->zone));
+    write_key_to_file(c->filename, c);
+  }
+
+  GNUNET_CONTAINER_multihashmap_remove (zonekeys, key, value);;
+  GNUNET_CRYPTO_rsa_key_free(c->privkey);
+  GNUNET_free (c->pubkey);
+  GNUNET_free(c->filename);
+  GNUNET_free (c);
+
+  return GNUNET_OK;
+}
+
+
 /**
  * Task run during shutdown.
  *
@@ -207,28 +226,12 @@
   struct GNUNET_NAMESTORE_ZoneIteration * tmp;
   struct GNUNET_NAMESTORE_Client * nc;
   struct GNUNET_NAMESTORE_Client * next;
-  struct GNUNET_NAMESTORE_CryptoContainer *c;
 
   GNUNET_SERVER_notification_context_destroy (snc);
   snc = NULL;
 
-  for (c = c_head; c != NULL; c = c_head)
-  {
-    if (c->filename != NULL)
-      write_key_to_file(c->filename, c);
-    else
-    {
-      GNUNET_asprintf(&c->filename, "%s/%s.zone", zonefile_directory, 
GNUNET_h2s_full (&c->zone));
-      write_key_to_file(c->filename, c);
-    }
+  GNUNET_CONTAINER_multihashmap_iterate(zonekeys, &zone_to_disk_it, NULL);
 
-    GNUNET_CONTAINER_DLL_remove(c_head, c_tail, c);
-    GNUNET_CRYPTO_rsa_key_free(c->privkey);
-    GNUNET_free (c->pubkey);
-    GNUNET_free(c->filename);
-    GNUNET_free (c);
-  }
-
   for (nc = client_head; nc != NULL; nc = next)
   {
     next = nc->next;
@@ -1544,7 +1547,7 @@
 
      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found zonefile for zone `%s'\n", 
GNUNET_h2s (&c->zone));
 
-     GNUNET_CONTAINER_DLL_insert(c_head, c_tail, c);
+     GNUNET_CONTAINER_multihashmap_put(zonekeys, &c->zone, c, 
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
      (*counter) ++;
    }
    return GNUNET_OK;
@@ -1612,6 +1615,7 @@
   }
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scanning directory `%s' for zone 
files\n", zonefile_directory);
+  zonekeys = GNUNET_CONTAINER_multihashmap_create (10);
   GNUNET_DISK_directory_scan (zonefile_directory, zonekey_file_it, &counter);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u zone files\n", counter);
 




reply via email to

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