trying to fix #2458, largely works
authorChristian Grothoff <christian@grothoff.org>
Mon, 25 Jun 2012 22:36:56 +0000 (22:36 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 25 Jun 2012 22:36:56 +0000 (22:36 +0000)
21 files changed:
src/include/gnunet_namestore_service.h
src/namestore/gnunet-namestore.c
src/namestore/gnunet-service-namestore.c
src/namestore/namestore.conf.in
src/namestore/namestore_api.c
src/namestore/plugin_namestore_postgres.c
src/namestore/test_namestore_api.c
src/namestore/test_namestore_api.conf
src/namestore/test_namestore_api_create.c
src/namestore/test_namestore_api_create_update.c
src/namestore/test_namestore_api_lookup.c
src/namestore/test_namestore_api_lookup_specific_type.c
src/namestore/test_namestore_api_put.c
src/namestore/test_namestore_api_remove.c
src/namestore/test_namestore_api_remove_not_existing_record.c
src/namestore/test_namestore_api_zone_iteration.c
src/namestore/test_namestore_api_zone_iteration_specific_zone.c
src/namestore/test_namestore_api_zone_iteration_stop.c
src/namestore/test_namestore_api_zone_to_name.c
src/namestore/test_plugin_namestore.c
src/namestore/test_plugin_namestore_postgres.conf

index f8a830dd7eee67dd7b4385c5328a24538961cad3..00c8ba26be7d683d5a579afe10dd7dcab9dbe475 100644 (file)
@@ -108,10 +108,9 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
  * resources).
  *
  * @param h handle to the namestore
- * @param drop set to GNUNET_YES to delete all data in namestore (!)
  */
 void
-GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop);
+GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h);
 
 
 /**
index aa3af1a73124452e5cdf859abd789893c7df4dc3..a79178abab261bc137645b6a130ae9b90c1f614d 100644 (file)
@@ -126,7 +126,7 @@ do_shutdown (void *cls,
 {
   if (NULL != ns)
   {
-    GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO);
+    GNUNET_NAMESTORE_disconnect (ns);
     ns = NULL;
   }
   if (NULL != zone_pkey)
index 257892bf9893612b8de15d8caf3688eb19633e7a..740ab6e87f07700cc8ffec1a75c9444c1e9c67f5 100644 (file)
@@ -1949,7 +1949,12 @@ find_next_zone_iteration_result (struct ZoneIterationProcResult *proc)
 
   do
   {
-    GSN_database->iterate_records (GSN_database->cls, zone , NULL, proc->zi->offset, &zone_iteraterate_proc, proc);
+    if (GNUNET_SYSERR ==
+       GSN_database->iterate_records (GSN_database->cls, zone, NULL, proc->zi->offset, &zone_iteraterate_proc, proc))
+    {
+      GNUNET_break (0);
+      break;
+    }
     proc->zi->offset++;
   }
   while ((0 == proc->records_included) && (GNUNET_NO == proc->res_iteration_finished));
index d93aea6ccb701e492104064ccb739f4ee09166c4..ca6156fa33dfccb3cf78eda0041e29a162fea9c0 100644 (file)
@@ -18,14 +18,5 @@ FILENAME = $SERVICEHOME/namestore/sqlite.db
 
 [namestore-postgres]
 CONFIG = connect_timeout=10; dbname=gnunet
-
-[namestore-mysql]
-DATABASE = gnunet
-CONFIG = ~/.my.cnf
-# USER = gnunet
-# PASSWORD = 
-# HOST = localhost
-# PORT = 3306
-
-
+TEMPORARY_TABLE = NO
 
index 0f47750b31167574c967e2085e0532b348f577b3..6ea3759428c9a0046381d0e1d8fd2bdd2ef9c17d 100644 (file)
@@ -1000,10 +1000,11 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
 static void
 clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  struct GNUNET_NAMESTORE_Handle *h = cls;
   struct PendingMessage *p;
   struct GNUNET_NAMESTORE_QueueEntry *q;
   struct GNUNET_NAMESTORE_ZoneIterator *z;
-  struct GNUNET_NAMESTORE_Handle *h = cls;
+
   GNUNET_assert (h != NULL);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
   while (NULL != (p = h->pending_head))
@@ -1011,19 +1012,16 @@ clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, p);
     GNUNET_free (p);
   }
-
   while (NULL != (q = h->op_head))
   {
     GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
     GNUNET_free (q);
   }
-
   while (NULL != (z = h->z_head))
   {
     GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
     GNUNET_free (z);
   }
-
   if (NULL != h->client)
   {
     GNUNET_CLIENT_disconnect (h->client);
@@ -1044,10 +1042,9 @@ clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * resources).
  *
  * @param h handle to the namestore
- * @param drop set to GNUNET_YES to delete all data in namestore (!)
  */
 void
-GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop)
+GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from namestore service\n");
   GNUNET_SCHEDULER_add_now (&clean_up_task, h);
index 1daf0c7c1bfe57d54f83fcba0472f98857c1ad93..0df6aa413d4e8cf8959a139b5c3d2985e04df1c5 100644 (file)
@@ -113,7 +113,28 @@ database_setup (struct Plugin *plugin)
                                         "namestore-postgres");
   if (NULL == plugin->dbh)
     return GNUNET_SYSERR;
-  res =
+  if (GNUNET_YES == 
+      GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg,
+                                           "namestore-postgres",
+                                           "TEMPORARY_TABLE"))
+  {
+    res =
+      PQexec (plugin->dbh,
+              "CREATE TEMPORARY TABLE ns091records ("
+             " zone_key BYTEA NOT NULL DEFAULT ''," 
+             " zone_delegation BYTEA NOT NULL DEFAULT ''," 
+             " zone_hash BYTEA NOT NULL DEFAULT ''," 
+             " record_count INTEGER NOT NULL DEFAULT 0,"
+             " record_data BYTEA NOT NULL DEFAULT '',"
+             " block_expiration_time BIGINT NOT NULL DEFAULT 0," 
+             " signature BYTEA NOT NULL DEFAULT '',"
+             " record_name TEXT NOT NULL DEFAULT ''," 
+             " record_name_hash BYTEA NOT NULL DEFAULT ''," 
+             " rvalue BIGINT NOT NULL DEFAULT 0"
+             ")" "WITH OIDS");
+  }
+  else
+    res =
       PQexec (plugin->dbh,
               "CREATE TABLE ns091records ("
              " zone_key BYTEA NOT NULL DEFAULT ''," 
@@ -127,6 +148,7 @@ database_setup (struct Plugin *plugin)
              " record_name_hash BYTEA NOT NULL DEFAULT ''," 
              " rvalue BIGINT NOT NULL DEFAULT 0"
              ")" "WITH OIDS");
+
   if ((NULL == res) || ((PQresultStatus (res) != PGRES_COMMAND_OK) && (0 != strcmp ("42P07",    /* duplicate table */
                                                                                     PQresultErrorField
                                                                                     (res,
@@ -380,6 +402,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
     LOG (GNUNET_ERROR_TYPE_DEBUG, 
         "Ending iteration (no more results)\n");
     PQclear (res);
+    iter (iter_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL);
     return GNUNET_NO;
   }
   GNUNET_assert (1 == cnt);
index 7fb52a2da75ff1c9b1ed2dd0f194438ad47fadeb..23c87d4f0daf0129cfcbb2dec386bd72317f7065 100644 (file)
@@ -58,7 +58,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 
   if (privkey != NULL)
@@ -84,7 +84,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   if (nsh != NULL)
   {
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
     nsh = NULL;
   }
   res = 0;
index 33e07a45c44c955ed01c618721465465a75b7fb0..697c9ef5112af30021700226694d527c1481364b 100644 (file)
@@ -16,20 +16,13 @@ CONFIG = $DEFAULTCONFIG
 BINARY = gnunet-service-namestore
 ACCEPT_FROM = 127.0.0.1;
 ACCEPT_FROM6 = ::1;
-DATABASE = sqlite
+DATABASE = postgres
 ZONEFILE_DIRECTORY = zonefiles
 
 [namestore-sqlite]
 FILENAME = $SERVICEHOME/namestore/sqlite_test.db
 
 [namestore-postgres]
-CONFIG = connect_timeout=10; dbname=gnunet
-
-[namestore-mysql]
-DATABASE = gnunet
-CONFIG = ~/.my.cnf
-# USER = gnunet
-# PASSWORD = 
-# HOST = localhost
-# PORT = 3306
+CONFIG = connect_timeout=10; dbname=gnunetcheck
+TEMPORARY_TABLE = YES
 
index a9956c53edaaec1d37c3426a0c07218b8660d832..9c794b23524ec8029e1fff8fa2f36e65245f56c0 100644 (file)
@@ -79,7 +79,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
@@ -103,7 +103,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index f3cc3917f27ecea1fc2645504851be8e4bcb6ed5..c7d79418a5ab75346ef90f30aadf7715682af07b 100644 (file)
@@ -77,7 +77,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
@@ -101,7 +101,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index 84dc414c6b83511f1c9f6f78e0275cf63109cea3..702fb2db11181a3c11dd6361fadff62a501641fa 100644 (file)
@@ -70,7 +70,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
@@ -96,7 +96,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index 45507fcc5fc2f74cce4c256fea772c542de363f1..26f037b00864e4df62ce2805ff564dec61947bbe 100644 (file)
@@ -73,7 +73,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
@@ -102,7 +102,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index 135b4a3e87493479e305e62bb5c0956d30b48904..162026b2f17502a21066e79de58bdcfe0ec77bfd 100644 (file)
@@ -61,7 +61,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 
   if (privkey != NULL)
@@ -90,7 +90,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
   if (nsh != NULL)
   {
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
     nsh = NULL;
   }
 }
index f91085315d280d35840af2d376d5f0f056245bd4..0ee4e44f793f4f4b99c30e32d55383cf69ee996f 100644 (file)
@@ -74,7 +74,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
@@ -100,7 +100,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index a18e342e1af4100c530897a39162b0f733777bb0..9ca7afae7ea44ca3c30a35bdc7e6ebaf3283642c 100644 (file)
@@ -74,7 +74,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
@@ -101,7 +101,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index d018b74c5e124a007a97f37a2c034bd700e19c74..5a8b12778599ecc2eb8c0a86e99bf3495ebec2b7 100644 (file)
@@ -90,7 +90,7 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
 
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 
   GNUNET_free_non_null(sig_1);
@@ -172,7 +172,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_free (s_rd_3);
   }
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index 9ed3fde285ed52093c12c9fc77c4bc307e56d76b..429636e4b7a587b6b6c4d8741290b3d6a5fe0dc6 100644 (file)
@@ -90,7 +90,7 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
 
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   GNUNET_free_non_null(sig_1);
   GNUNET_free_non_null(sig_2);
@@ -167,7 +167,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_free (s_rd_3);
   }
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index 732550acdc7de43ea3473e20dbc00e309f60097e..4974875d12b7f324ceea4763eda433fe3523d6d1 100644 (file)
@@ -88,7 +88,7 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     stopiteration_task = GNUNET_SCHEDULER_NO_TASK;
   }
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   GNUNET_free_non_null(sig_1);
   GNUNET_free_non_null(sig_2);
@@ -165,7 +165,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_free (s_rd_3);
   }
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (returned_records == 1)
     res = 0;
index 9c2aebc36c05098ec73abb672c0b2721d6ea07c5..0e29b8b330a8ddf1b1fd9c0e569dc09d10909e91 100644 (file)
@@ -70,7 +70,7 @@ static void
 endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
   if (privkey != NULL)
     GNUNET_CRYPTO_rsa_key_free (privkey);
@@ -91,7 +91,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_CRYPTO_rsa_key_free (privkey);
   privkey = NULL;
   if (nsh != NULL)
-    GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+    GNUNET_NAMESTORE_disconnect (nsh);
   nsh = NULL;
 }
 
index 0ff98b43b36c1a0308a46c580f786ca7be6776c8..45cce861fc7cca0abb9943d3aa74a2f2fdacb468 100644 (file)
@@ -187,9 +187,7 @@ run (void *cls, char *const *args, const char *cfgfile,
             "Failed to initialize namestore.  Database likely not setup, skipping test.\n");
     return;
   }
-
   put_record (nsp, 1);
-
   get_record (nsp, 1);
 
   memset (&zone_key, 1, sizeof (zone_key));
index e2641eac2928c73bf9bf8c8f38474de59b8037f3..6d91cddd7cbef6b672521b32d627236d34a720d6 100644 (file)
@@ -1,2 +1,3 @@
 [datacache-postgres]
 CONFIG = connect_timeout=10; dbname=gnunetcheck
+TEMPORARY_TABLE = YES