aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_namestore_service.h3
-rw-r--r--src/namestore/gnunet-namestore.c2
-rw-r--r--src/namestore/gnunet-service-namestore.c7
-rw-r--r--src/namestore/namestore.conf.in11
-rw-r--r--src/namestore/namestore_api.c9
-rw-r--r--src/namestore/plugin_namestore_postgres.c25
-rw-r--r--src/namestore/test_namestore_api.c4
-rw-r--r--src/namestore/test_namestore_api.conf13
-rw-r--r--src/namestore/test_namestore_api_create.c4
-rw-r--r--src/namestore/test_namestore_api_create_update.c4
-rw-r--r--src/namestore/test_namestore_api_lookup.c4
-rw-r--r--src/namestore/test_namestore_api_lookup_specific_type.c4
-rw-r--r--src/namestore/test_namestore_api_put.c4
-rw-r--r--src/namestore/test_namestore_api_remove.c4
-rw-r--r--src/namestore/test_namestore_api_remove_not_existing_record.c4
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c4
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c4
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c4
-rw-r--r--src/namestore/test_namestore_api_zone_to_name.c4
-rw-r--r--src/namestore/test_plugin_namestore.c2
-rw-r--r--src/namestore/test_plugin_namestore_postgres.conf1
21 files changed, 64 insertions, 57 deletions
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index f8a830dd7e..00c8ba26be 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 aa3af1a731..a79178abab 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 257892bf98..740ab6e87f 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 d93aea6ccb..ca6156fa33 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 0f47750b31..6ea3759428 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 1daf0c7c1b..0df6aa413d 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 7fb52a2da7..23c87d4f0d 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 33e07a45c4..697c9ef511 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 a9956c53ed..9c794b2352 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 f3cc3917f2..c7d79418a5 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 84dc414c6b..702fb2db11 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 45507fcc5f..26f037b008 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 135b4a3e87..162026b2f1 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 f91085315d..0ee4e44f79 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 a18e342e1a..9ca7afae7e 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 d018b74c5e..5a8b127785 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 9ed3fde285..429636e4b7 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 732550acdc..4974875d12 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 9c2aebc36c..0e29b8b330 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 0ff98b43b3..45cce861fc 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 e2641eac29..6d91cddd7c 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