From: Christophe Genevey Metat Date: Tue, 12 Jul 2016 09:58:04 +0000 (+0000) Subject: fix Makefile X-Git-Tag: initial-import-from-subversion-38251~538 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=97d142230b783a3d667cdfedb7fc0397ce831c66;p=oweals%2Fgnunet.git fix Makefile --- diff --git a/src/psycstore/Makefile.am b/src/psycstore/Makefile.am index ee61b8c78..4da0a89d8 100644 --- a/src/psycstore/Makefile.am +++ b/src/psycstore/Makefile.am @@ -20,6 +20,13 @@ if USE_COVERAGE XLIB = -lgcov endif +if HAVE_MYSQL +MYSQL_PLUGIN = libgnunet_plugin_psycstore_mysql.la +if HAVE_TESTING +MYSQL_TESTS = test_plugin_psycstore_mysql +endif +endif + if HAVE_SQLITE SQLITE_PLUGIN = libgnunet_plugin_psycstore_sqlite.la if HAVE_TESTING @@ -53,7 +60,8 @@ gnunet_service_psycstore_LDADD = \ $(GN_LIBINTL) plugin_LTLIBRARIES = \ - $(SQLITE_PLUGIN) + $(SQLITE_PLUGIN) \ + $(MYSQL_PLUGIN) libgnunet_plugin_psycstore_mysql_la_SOURCES = \ plugin_psycstore_mysql.c @@ -83,6 +91,7 @@ if HAVE_SQLITE if HAVE_TESTING check_PROGRAMS = \ $(SQLITE_TESTS) \ + $(MYSQL_TESTS) \ test_psycstore endif endif @@ -108,3 +117,10 @@ test_plugin_psycstore_sqlite_SOURCES = \ test_plugin_psycstore_sqlite_LDADD = \ $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la + +test_plugin_psycstore_mysql_SOURCES = \ + test_plugin_psycstore.c +test_plugin_psycstore_mysql_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting.la \ + $(top_builddir)/src/util/libgnunetutil.la + diff --git a/src/psycstore/plugin_psycstore_mysql.c b/src/psycstore/plugin_psycstore_mysql.c index abb8ecfb9..1057fea92 100644 --- a/src/psycstore/plugin_psycstore_mysql.c +++ b/src/psycstore/plugin_psycstore_mysql.c @@ -20,17 +20,12 @@ /** * @file psycstore/plugin_psycstore_mysql.c - * @brief sqlite-based psycstore backend + * @brief mysql-based psycstore backend * @author Gabor X Toth * @author Christian Grothoff * @author Christophe Genevey */ -/* - * FIXME: SQLite3 only supports signed 64-bit integers natively, - * thus it can only store 63 bits of the uint64_t's. - */ - #include "platform.h" #include "gnunet_psycstore_plugin.h" #include "gnunet_psycstore_service.h" @@ -309,7 +304,7 @@ database_setup (struct Plugin *plugin) "FILENAME", &filename)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "psycstore-sqlite", "FILENAME"); + "psycstore-mysql", "FILENAME"); return GNUNET_SYSERR; } if (GNUNET_OK != GNUNET_DISK_file_test (filename)) @@ -330,7 +325,7 @@ database_setup (struct Plugin *plugin) if (NULL == plugin->mc) { LOG(GNUNET_ERROR_TYPE_ERROR, - _("Unable to initialize Mysql: .\n")); + _("Unable to initialize Mysql.\n")); return GNUNET_SYSERR; } @@ -356,12 +351,15 @@ database_setup (struct Plugin *plugin) GNUNET_MYSQL_statement_run (plugin->mc, "CREATE TABLE IF NOT EXISTS channels (\n" - " id INT PRIMARY KEY,\n" - " pub_key BLOB UNIQUE,\n" - " max_state_message_id INT,\n" // last applied state message ID - " state_hash_message_id INT\n" // last message ID with a state hash + " id INT,\n" + " pub_key BLOB,\n" + " max_state_message_id INT,\n" + " state_hash_message_id INT,\n" + " PRIMARY KEY(id),\n" + " UNIQUE KEY(pub_key(10))\n" ");"); - + +/** ERROR **/ GNUNET_MYSQL_statement_run (plugin->mc, "CREATE TABLE IF NOT EXISTS slaves (\n" " id INT PRIMARY KEY,\n" @@ -636,7 +634,7 @@ database_setup (struct Plugin *plugin) static void database_shutdown (struct Plugin *plugin) { - GNUNET_MYSQL_statements_invalidate (plugin->mc); + GNUNET_MYSQL_context_destroy (plugin->mc); GNUNET_free_non_null (plugin->fn); } @@ -908,7 +906,7 @@ slave_key_store (struct Plugin *plugin, * @return #GNUNET_OK on success, else #GNUNET_SYSERR */ static int -sqlite_membership_store (void *cls, +mysql_membership_store (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, int did_join, @@ -926,6 +924,7 @@ sqlite_membership_store (void *cls, struct GNUNET_MYSQL_StatementHandle *stmt = plugin->insert_membership; MYSQL_STMT *statement = NULL; +/**** FAIL HERE ****/ statement = GNUNET_MYSQL_statement_get_stmt (stmt); GNUNET_assert (TRANSACTION_NONE == plugin->transaction); @@ -2206,7 +2205,7 @@ libgnunet_plugin_psycstore_mysql_init (void *cls) } api = GNUNET_new (struct GNUNET_PSYCSTORE_PluginFunctions); api->cls = &plugin; - api->membership_store = &sqlite_membership_store; + api->membership_store = &mysql_membership_store; api->membership_test = &membership_test; api->fragment_store = &fragment_store; api->message_add_flags = &message_add_flags; @@ -2229,7 +2228,7 @@ libgnunet_plugin_psycstore_mysql_init (void *cls) api->state_get_prefix = &state_get_prefix; api->state_get_signed = &state_get_signed; - LOG (GNUNET_ERROR_TYPE_INFO, _("SQLite database running\n")); + LOG (GNUNET_ERROR_TYPE_INFO, _("Mysql database running\n")); return api; } @@ -2249,7 +2248,7 @@ libgnunet_plugin_psycstore_mysql_done (void *cls) database_shutdown (plugin); plugin->cfg = NULL; GNUNET_free (api); - LOG (GNUNET_ERROR_TYPE_DEBUG, "SQLite plugin is finished\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Mysql plugin is finished\n"); return NULL; }