From: Christian Grothoff Date: Wed, 11 Apr 2018 10:19:55 +0000 (+0200) Subject: support async commit X-Git-Tag: v0.11.0pre66~110 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=38c918ff27e5a90c1a17f3989a78c7fca564c47a;p=oweals%2Fgnunet.git support async commit --- diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c index 493569bca..9041431d1 100644 --- a/src/namestore/gnunet-zoneimport.c +++ b/src/namestore/gnunet-zoneimport.c @@ -1254,13 +1254,18 @@ run (void *cls, "libgnunet_plugin_namestore_%s", database); ns = GNUNET_PLUGIN_load (db_lib_name, - (void *) cfg); + (void *) cfg); GNUNET_free (database); + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, + NULL); + if (NULL == ns) + { + GNUNET_SCHEDULER_shutdown (); + return; + } id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); - GNUNET_SCHEDULER_add_shutdown (&do_shutdown, - NULL); } diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in index 0ebd2586b..f19ac5643 100644 --- a/src/namestore/namestore.conf.in +++ b/src/namestore/namestore.conf.in @@ -19,8 +19,12 @@ FILENAME = $GNUNET_DATA_HOME/namestore/flat.db [namestore-postgres] +# How to connect to the database CONFIG = postgres:///gnunet +# Use temporary tables TEMPORARY_TABLE = NO +# Use asynchronous commit (SET synchronous_commit TO OFF). +ASYNC_COMMIT = NO [uri] gns = gnunet-namestore diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c index 872bf75cb..4828cb190 100644 --- a/src/namestore/plugin_namestore_postgres.c +++ b/src/namestore/plugin_namestore_postgres.c @@ -90,6 +90,25 @@ database_setup (struct Plugin *plugin) "namestore-postgres"); if (NULL == plugin->dbh) return GNUNET_SYSERR; + if (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg, + "namestore-postgres", + "ASYNC_COMMIT")) + { + struct GNUNET_PQ_ExecuteStatement es[] = { + GNUNET_PQ_make_try_execute ("SET synchronous_commit TO off"), + GNUNET_PQ_EXECUTE_STATEMENT_END + }; + + if (GNUNET_OK != + GNUNET_PQ_exec_statements (plugin->dbh, + es)) + { + PQfinish (plugin->dbh); + plugin->dbh = NULL; + return GNUNET_SYSERR; + } + } if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (plugin->cfg, "namestore-postgres",