gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r19960 - gnunet/src/namestore
Date: Wed, 22 Feb 2012 23:52:06 +0100

Author: grothoff
Date: 2012-02-22 23:52:06 +0100 (Wed, 22 Feb 2012)
New Revision: 19960

Modified:
   gnunet/src/namestore/plugin_namestore_sqlite.c
   gnunet/src/namestore/test_plugin_namestore.c
Log:
-more bugfixes, more testing

Modified: gnunet/src/namestore/plugin_namestore_sqlite.c
===================================================================
--- gnunet/src/namestore/plugin_namestore_sqlite.c      2012-02-22 22:34:13 UTC 
(rev 19959)
+++ gnunet/src/namestore/plugin_namestore_sqlite.c      2012-02-22 22:52:06 UTC 
(rev 19960)
@@ -655,7 +655,10 @@
   }
   if (SQLITE_DONE != sret)
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
-  sqlite3_finalize (plugin->iterate_records);
+  if (SQLITE_OK != sqlite3_reset (plugin->iterate_records))
+    LOG_SQLITE (plugin,
+               GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+               "sqlite3_reset");
   return ret;
 }
 
@@ -727,7 +730,10 @@
   }
   else if (SQLITE_DONE != ret)
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
-  sqlite3_finalize (plugin->get_node);
+  if (SQLITE_OK != sqlite3_reset (plugin->get_node))
+    LOG_SQLITE (plugin,
+               GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+               "sqlite3_reset");
   return ret;
 }
 
@@ -748,6 +754,7 @@
 {
   struct Plugin *plugin = cls;
   int ret;
+  int sret;
   const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key;
   struct GNUNET_NAMESTORE_SignatureLocation top_loc;
   const struct GNUNET_CRYPTO_RsaSignature *zone_sig;
@@ -766,7 +773,7 @@
     return GNUNET_SYSERR;
   }
   ret = GNUNET_NO;
-  if (SQLITE_ROW == (ret = sqlite3_step (plugin->get_signature)))    
+  if (SQLITE_ROW == (sret = sqlite3_step (plugin->get_signature)))    
   {
     top_loc.offset = 0;
     top_loc.revision = sqlite3_column_int (plugin->get_signature, 0);
@@ -794,9 +801,12 @@
          top_hash);
     }
   }
-  if (SQLITE_DONE != ret)
+  else if (SQLITE_DONE != sret)
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR, "sqlite_step");
-  sqlite3_finalize (plugin->get_signature);
+  if (SQLITE_OK != sqlite3_reset (plugin->get_signature))
+    LOG_SQLITE (plugin,
+               GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+               "sqlite3_reset");
   return ret;
 }
 
@@ -816,24 +826,24 @@
 {
   int n;
 
-  if (SQLITE_OK != sqlite3_bind_blob (plugin->delete_zone_records, 1, zone, 
sizeof (GNUNET_HashCode), SQLITE_STATIC))
+  if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, zone, sizeof (GNUNET_HashCode), 
SQLITE_STATIC))
   {
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind_XXXX");
-    if (SQLITE_OK != sqlite3_reset (plugin->delete_zone_records))
+    if (SQLITE_OK != sqlite3_reset (stmt))
       LOG_SQLITE (plugin,
                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                   "sqlite3_reset");
     return;
   }
-  n = sqlite3_step (plugin->put_signature);
-  if (SQLITE_OK != sqlite3_reset (plugin->delete_zone_records))
+  n = sqlite3_step (stmt);
+  if (SQLITE_OK != sqlite3_reset (stmt))
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                "sqlite3_reset");
   switch (n)
   {
   case SQLITE_DONE:
-    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Zone records 
deleted\n");
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "sqlite", "Values deleted\n");
     break;
   case SQLITE_BUSY:
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
@@ -948,6 +958,7 @@
   GNUNET_HashCode zone;
   struct DeleteContext dc;
 
+  GNUNET_break (0 == loc->offset); /* little sanity check */
   GNUNET_CRYPTO_hash (zone_key,
                      sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
                      &zone);
@@ -975,7 +986,6 @@
                   GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                   "sqlite3_reset");
     return GNUNET_SYSERR;
-
   }
   n = sqlite3_step (plugin->put_signature);
   if (SQLITE_OK != sqlite3_reset (plugin->put_signature))

Modified: gnunet/src/namestore/test_plugin_namestore.c
===================================================================
--- gnunet/src/namestore/test_plugin_namestore.c        2012-02-22 22:34:13 UTC 
(rev 19959)
+++ gnunet/src/namestore/test_plugin_namestore.c        2012-02-22 22:52:06 UTC 
(rev 19960)
@@ -243,7 +243,7 @@
 
   memset (&tzone_key, 13, sizeof (tzone_key));
   tloc.depth = (id % 10);
-  tloc.offset = (id % 3);
+  tloc.offset = 0;
   tloc.revision = id % 1024;
   memset (&ttop_sig, 24, sizeof (ttop_sig));
   memset (&troot_hash, 42, sizeof (troot_hash));
@@ -258,12 +258,14 @@
 static void
 get_signature (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
 {
-  GNUNET_HashCode root_hash;
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
+  GNUNET_HashCode zone;
 
-  memset (&root_hash, 42, sizeof (root_hash));
+  memset (&zone_key, 13, sizeof (zone_key));
+  GNUNET_CRYPTO_hash (&zone_key, sizeof (zone_key), &zone);
   GNUNET_assert (GNUNET_OK ==
                 nsp->get_signature (nsp->cls,
-                                    &root_hash,
+                                    &zone,
                                     test_signature,
                                     &id));
 }
@@ -347,7 +349,7 @@
 
   memset (&zone_key, 13, sizeof (zone_key));
   loc.depth = (id % 10);
-  loc.offset = (id % 3);
+  loc.offset = 0;
   loc.revision = id % 1024;
   memset (&top_sig, 24, sizeof (top_sig));
   memset (&root_hash, 42, sizeof (root_hash));
@@ -368,6 +370,7 @@
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_NAMESTORE_PluginFunctions *nsp;  
+  GNUNET_HashCode zone;
   
   ok = 0;
   nsp = load_plugin (cfg);
@@ -384,7 +387,9 @@
   get_node (nsp, 1);
   put_signature (nsp, 1);
   get_signature (nsp, 1);
-  
+
+  memset (&zone, 42, sizeof (zone));  
+  nsp->delete_zone (nsp->cls, &zone);
   unload_plugin (nsp);
 }
 
@@ -408,6 +413,7 @@
     GNUNET_GETOPT_OPTION_END
   };
 
+  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-plugin-namestore-sqlite");
   GNUNET_log_setup ("test-plugin-namestore",
 #if VERBOSE
                     "DEBUG",
@@ -432,6 +438,7 @@
                       "test-plugin-namestore", "nohelp", options, &run, NULL);
   if (ok != 0)
     FPRINTF (stderr, "Missed some testcases: %d\n", ok);
+  GNUNET_DISK_directory_remove ("/tmp/gnunet-test-plugin-namestore-sqlite");
   return ok;
 }
 




reply via email to

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