From: Christian Grothoff Date: Mon, 25 Jun 2012 22:36:56 +0000 (+0000) Subject: trying to fix #2458, largely works X-Git-Tag: initial-import-from-subversion-38251~12818 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ee0de607e52152c03a865559422dad4faacad53d;p=oweals%2Fgnunet.git trying to fix #2458, largely works --- diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index f8a830dd7..00c8ba26b 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h @@ -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); /** diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index aa3af1a73..a79178aba 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c @@ -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) diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 257892bf9..740ab6e87 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -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)); diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in index d93aea6cc..ca6156fa3 100644 --- a/src/namestore/namestore.conf.in +++ b/src/namestore/namestore.conf.in @@ -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 diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 0f47750b3..6ea375942 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c @@ -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); diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c index 1daf0c7c1..0df6aa413 100644 --- a/src/namestore/plugin_namestore_postgres.c +++ b/src/namestore/plugin_namestore_postgres.c @@ -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); diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c index 7fb52a2da..23c87d4f0 100644 --- a/src/namestore/test_namestore_api.c +++ b/src/namestore/test_namestore_api.c @@ -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; diff --git a/src/namestore/test_namestore_api.conf b/src/namestore/test_namestore_api.conf index 33e07a45c..697c9ef51 100644 --- a/src/namestore/test_namestore_api.conf +++ b/src/namestore/test_namestore_api.conf @@ -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 diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c index a9956c53e..9c794b235 100644 --- a/src/namestore/test_namestore_api_create.c +++ b/src/namestore/test_namestore_api_create.c @@ -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; } diff --git a/src/namestore/test_namestore_api_create_update.c b/src/namestore/test_namestore_api_create_update.c index f3cc3917f..c7d79418a 100644 --- a/src/namestore/test_namestore_api_create_update.c +++ b/src/namestore/test_namestore_api_create_update.c @@ -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; } diff --git a/src/namestore/test_namestore_api_lookup.c b/src/namestore/test_namestore_api_lookup.c index 84dc414c6..702fb2db1 100644 --- a/src/namestore/test_namestore_api_lookup.c +++ b/src/namestore/test_namestore_api_lookup.c @@ -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; } diff --git a/src/namestore/test_namestore_api_lookup_specific_type.c b/src/namestore/test_namestore_api_lookup_specific_type.c index 45507fcc5..26f037b00 100644 --- a/src/namestore/test_namestore_api_lookup_specific_type.c +++ b/src/namestore/test_namestore_api_lookup_specific_type.c @@ -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; } diff --git a/src/namestore/test_namestore_api_put.c b/src/namestore/test_namestore_api_put.c index 135b4a3e8..162026b2f 100644 --- a/src/namestore/test_namestore_api_put.c +++ b/src/namestore/test_namestore_api_put.c @@ -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; } } diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c index f91085315..0ee4e44f7 100644 --- a/src/namestore/test_namestore_api_remove.c +++ b/src/namestore/test_namestore_api_remove.c @@ -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; } diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c index a18e342e1..9ca7afae7 100644 --- a/src/namestore/test_namestore_api_remove_not_existing_record.c +++ b/src/namestore/test_namestore_api_remove_not_existing_record.c @@ -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; } diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c index d018b74c5..5a8b12778 100644 --- a/src/namestore/test_namestore_api_zone_iteration.c +++ b/src/namestore/test_namestore_api_zone_iteration.c @@ -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; } diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c index 9ed3fde28..429636e4b 100644 --- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c +++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c @@ -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; } diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c index 732550acd..4974875d1 100644 --- a/src/namestore/test_namestore_api_zone_iteration_stop.c +++ b/src/namestore/test_namestore_api_zone_iteration_stop.c @@ -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; diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c index 9c2aebc36..0e29b8b33 100644 --- a/src/namestore/test_namestore_api_zone_to_name.c +++ b/src/namestore/test_namestore_api_zone_to_name.c @@ -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; } diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c index 0ff98b43b..45cce861f 100644 --- a/src/namestore/test_plugin_namestore.c +++ b/src/namestore/test_plugin_namestore.c @@ -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)); diff --git a/src/namestore/test_plugin_namestore_postgres.conf b/src/namestore/test_plugin_namestore_postgres.conf index e2641eac2..6d91cddd7 100644 --- a/src/namestore/test_plugin_namestore_postgres.conf +++ b/src/namestore/test_plugin_namestore_postgres.conf @@ -1,2 +1,3 @@ [datacache-postgres] CONFIG = connect_timeout=10; dbname=gnunetcheck +TEMPORARY_TABLE = YES