diff options
author | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-07-12 09:58:04 +0000 |
---|---|---|
committer | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-07-12 09:58:04 +0000 |
commit | 97d142230b783a3d667cdfedb7fc0397ce831c66 (patch) | |
tree | f08017db62178245d04c8210d598ce16b2b6bfbc /src | |
parent | a00afbdaae8de7fd752aab1ed5028833a85eeea7 (diff) | |
download | gnunet-97d142230b783a3d667cdfedb7fc0397ce831c66.tar.gz gnunet-97d142230b783a3d667cdfedb7fc0397ce831c66.zip |
fix Makefile
Diffstat (limited to 'src')
-rw-r--r-- | src/psycstore/Makefile.am | 18 | ||||
-rw-r--r-- | src/psycstore/plugin_psycstore_mysql.c | 35 |
2 files changed, 34 insertions, 19 deletions
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 | |||
20 | XLIB = -lgcov | 20 | XLIB = -lgcov |
21 | endif | 21 | endif |
22 | 22 | ||
23 | if HAVE_MYSQL | ||
24 | MYSQL_PLUGIN = libgnunet_plugin_psycstore_mysql.la | ||
25 | if HAVE_TESTING | ||
26 | MYSQL_TESTS = test_plugin_psycstore_mysql | ||
27 | endif | ||
28 | endif | ||
29 | |||
23 | if HAVE_SQLITE | 30 | if HAVE_SQLITE |
24 | SQLITE_PLUGIN = libgnunet_plugin_psycstore_sqlite.la | 31 | SQLITE_PLUGIN = libgnunet_plugin_psycstore_sqlite.la |
25 | if HAVE_TESTING | 32 | if HAVE_TESTING |
@@ -53,7 +60,8 @@ gnunet_service_psycstore_LDADD = \ | |||
53 | $(GN_LIBINTL) | 60 | $(GN_LIBINTL) |
54 | 61 | ||
55 | plugin_LTLIBRARIES = \ | 62 | plugin_LTLIBRARIES = \ |
56 | $(SQLITE_PLUGIN) | 63 | $(SQLITE_PLUGIN) \ |
64 | $(MYSQL_PLUGIN) | ||
57 | 65 | ||
58 | libgnunet_plugin_psycstore_mysql_la_SOURCES = \ | 66 | libgnunet_plugin_psycstore_mysql_la_SOURCES = \ |
59 | plugin_psycstore_mysql.c | 67 | plugin_psycstore_mysql.c |
@@ -83,6 +91,7 @@ if HAVE_SQLITE | |||
83 | if HAVE_TESTING | 91 | if HAVE_TESTING |
84 | check_PROGRAMS = \ | 92 | check_PROGRAMS = \ |
85 | $(SQLITE_TESTS) \ | 93 | $(SQLITE_TESTS) \ |
94 | $(MYSQL_TESTS) \ | ||
86 | test_psycstore | 95 | test_psycstore |
87 | endif | 96 | endif |
88 | endif | 97 | endif |
@@ -108,3 +117,10 @@ test_plugin_psycstore_sqlite_SOURCES = \ | |||
108 | test_plugin_psycstore_sqlite_LDADD = \ | 117 | test_plugin_psycstore_sqlite_LDADD = \ |
109 | $(top_builddir)/src/testing/libgnunettesting.la \ | 118 | $(top_builddir)/src/testing/libgnunettesting.la \ |
110 | $(top_builddir)/src/util/libgnunetutil.la | 119 | $(top_builddir)/src/util/libgnunetutil.la |
120 | |||
121 | test_plugin_psycstore_mysql_SOURCES = \ | ||
122 | test_plugin_psycstore.c | ||
123 | test_plugin_psycstore_mysql_LDADD = \ | ||
124 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
125 | $(top_builddir)/src/util/libgnunetutil.la | ||
126 | |||
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 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file psycstore/plugin_psycstore_mysql.c | 22 | * @file psycstore/plugin_psycstore_mysql.c |
23 | * @brief sqlite-based psycstore backend | 23 | * @brief mysql-based psycstore backend |
24 | * @author Gabor X Toth | 24 | * @author Gabor X Toth |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | * @author Christophe Genevey | 26 | * @author Christophe Genevey |
27 | */ | 27 | */ |
28 | 28 | ||
29 | /* | ||
30 | * FIXME: SQLite3 only supports signed 64-bit integers natively, | ||
31 | * thus it can only store 63 bits of the uint64_t's. | ||
32 | */ | ||
33 | |||
34 | #include "platform.h" | 29 | #include "platform.h" |
35 | #include "gnunet_psycstore_plugin.h" | 30 | #include "gnunet_psycstore_plugin.h" |
36 | #include "gnunet_psycstore_service.h" | 31 | #include "gnunet_psycstore_service.h" |
@@ -309,7 +304,7 @@ database_setup (struct Plugin *plugin) | |||
309 | "FILENAME", &filename)) | 304 | "FILENAME", &filename)) |
310 | { | 305 | { |
311 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 306 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
312 | "psycstore-sqlite", "FILENAME"); | 307 | "psycstore-mysql", "FILENAME"); |
313 | return GNUNET_SYSERR; | 308 | return GNUNET_SYSERR; |
314 | } | 309 | } |
315 | if (GNUNET_OK != GNUNET_DISK_file_test (filename)) | 310 | if (GNUNET_OK != GNUNET_DISK_file_test (filename)) |
@@ -330,7 +325,7 @@ database_setup (struct Plugin *plugin) | |||
330 | if (NULL == plugin->mc) | 325 | if (NULL == plugin->mc) |
331 | { | 326 | { |
332 | LOG(GNUNET_ERROR_TYPE_ERROR, | 327 | LOG(GNUNET_ERROR_TYPE_ERROR, |
333 | _("Unable to initialize Mysql: .\n")); | 328 | _("Unable to initialize Mysql.\n")); |
334 | return GNUNET_SYSERR; | 329 | return GNUNET_SYSERR; |
335 | } | 330 | } |
336 | 331 | ||
@@ -356,12 +351,15 @@ database_setup (struct Plugin *plugin) | |||
356 | 351 | ||
357 | GNUNET_MYSQL_statement_run (plugin->mc, | 352 | GNUNET_MYSQL_statement_run (plugin->mc, |
358 | "CREATE TABLE IF NOT EXISTS channels (\n" | 353 | "CREATE TABLE IF NOT EXISTS channels (\n" |
359 | " id INT PRIMARY KEY,\n" | 354 | " id INT,\n" |
360 | " pub_key BLOB UNIQUE,\n" | 355 | " pub_key BLOB,\n" |
361 | " max_state_message_id INT,\n" // last applied state message ID | 356 | " max_state_message_id INT,\n" |
362 | " state_hash_message_id INT\n" // last message ID with a state hash | 357 | " state_hash_message_id INT,\n" |
358 | " PRIMARY KEY(id),\n" | ||
359 | " UNIQUE KEY(pub_key(10))\n" | ||
363 | ");"); | 360 | ");"); |
364 | 361 | ||
362 | /** ERROR **/ | ||
365 | GNUNET_MYSQL_statement_run (plugin->mc, | 363 | GNUNET_MYSQL_statement_run (plugin->mc, |
366 | "CREATE TABLE IF NOT EXISTS slaves (\n" | 364 | "CREATE TABLE IF NOT EXISTS slaves (\n" |
367 | " id INT PRIMARY KEY,\n" | 365 | " id INT PRIMARY KEY,\n" |
@@ -636,7 +634,7 @@ database_setup (struct Plugin *plugin) | |||
636 | static void | 634 | static void |
637 | database_shutdown (struct Plugin *plugin) | 635 | database_shutdown (struct Plugin *plugin) |
638 | { | 636 | { |
639 | GNUNET_MYSQL_statements_invalidate (plugin->mc); | 637 | GNUNET_MYSQL_context_destroy (plugin->mc); |
640 | 638 | ||
641 | GNUNET_free_non_null (plugin->fn); | 639 | GNUNET_free_non_null (plugin->fn); |
642 | } | 640 | } |
@@ -908,7 +906,7 @@ slave_key_store (struct Plugin *plugin, | |||
908 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 906 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
909 | */ | 907 | */ |
910 | static int | 908 | static int |
911 | sqlite_membership_store (void *cls, | 909 | mysql_membership_store (void *cls, |
912 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 910 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
913 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | 911 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
914 | int did_join, | 912 | int did_join, |
@@ -926,6 +924,7 @@ sqlite_membership_store (void *cls, | |||
926 | struct GNUNET_MYSQL_StatementHandle *stmt = plugin->insert_membership; | 924 | struct GNUNET_MYSQL_StatementHandle *stmt = plugin->insert_membership; |
927 | MYSQL_STMT *statement = NULL; | 925 | MYSQL_STMT *statement = NULL; |
928 | 926 | ||
927 | /**** FAIL HERE ****/ | ||
929 | statement = GNUNET_MYSQL_statement_get_stmt (stmt); | 928 | statement = GNUNET_MYSQL_statement_get_stmt (stmt); |
930 | 929 | ||
931 | GNUNET_assert (TRANSACTION_NONE == plugin->transaction); | 930 | GNUNET_assert (TRANSACTION_NONE == plugin->transaction); |
@@ -2206,7 +2205,7 @@ libgnunet_plugin_psycstore_mysql_init (void *cls) | |||
2206 | } | 2205 | } |
2207 | api = GNUNET_new (struct GNUNET_PSYCSTORE_PluginFunctions); | 2206 | api = GNUNET_new (struct GNUNET_PSYCSTORE_PluginFunctions); |
2208 | api->cls = &plugin; | 2207 | api->cls = &plugin; |
2209 | api->membership_store = &sqlite_membership_store; | 2208 | api->membership_store = &mysql_membership_store; |
2210 | api->membership_test = &membership_test; | 2209 | api->membership_test = &membership_test; |
2211 | api->fragment_store = &fragment_store; | 2210 | api->fragment_store = &fragment_store; |
2212 | api->message_add_flags = &message_add_flags; | 2211 | api->message_add_flags = &message_add_flags; |
@@ -2229,7 +2228,7 @@ libgnunet_plugin_psycstore_mysql_init (void *cls) | |||
2229 | api->state_get_prefix = &state_get_prefix; | 2228 | api->state_get_prefix = &state_get_prefix; |
2230 | api->state_get_signed = &state_get_signed; | 2229 | api->state_get_signed = &state_get_signed; |
2231 | 2230 | ||
2232 | LOG (GNUNET_ERROR_TYPE_INFO, _("SQLite database running\n")); | 2231 | LOG (GNUNET_ERROR_TYPE_INFO, _("Mysql database running\n")); |
2233 | return api; | 2232 | return api; |
2234 | } | 2233 | } |
2235 | 2234 | ||
@@ -2249,7 +2248,7 @@ libgnunet_plugin_psycstore_mysql_done (void *cls) | |||
2249 | database_shutdown (plugin); | 2248 | database_shutdown (plugin); |
2250 | plugin->cfg = NULL; | 2249 | plugin->cfg = NULL; |
2251 | GNUNET_free (api); | 2250 | GNUNET_free (api); |
2252 | LOG (GNUNET_ERROR_TYPE_DEBUG, "SQLite plugin is finished\n"); | 2251 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Mysql plugin is finished\n"); |
2253 | return NULL; | 2252 | return NULL; |
2254 | } | 2253 | } |
2255 | 2254 | ||