[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-challenger] branch master updated: ensure we do not start if the
From: |
gnunet |
Subject: |
[taler-challenger] branch master updated: ensure we do not start if the database version is outdated (#9203) |
Date: |
Sun, 10 Nov 2024 17:22:10 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository challenger.
The following commit(s) were added to refs/heads/master by this push:
new 69fd977 ensure we do not start if the database version is outdated
(#9203)
69fd977 is described below
commit 69fd977733bc07909553f6710a06b515f1e65674
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Nov 10 17:22:00 2024 +0100
ensure we do not start if the database version is outdated (#9203)
---
src/challenger/challenger-admin.c | 3 ++-
src/challenger/challenger-httpd.c | 3 ++-
src/challengerdb/challenger-dbinit.c | 3 ++-
src/challengerdb/challenger_db_plugin.c | 12 +++++++++++-
src/challengerdb/plugin_challengerdb_postgres.c | 18 ++++++------------
src/challengerdb/test_challenger_db.c | 16 +++++++++-------
src/include/challenger_database_lib.h | 10 ++++++++--
7 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/src/challenger/challenger-admin.c
b/src/challenger/challenger-admin.c
index 82f91b4..422aacd 100644
--- a/src/challenger/challenger-admin.c
+++ b/src/challenger/challenger-admin.c
@@ -95,7 +95,8 @@ run (void *cls,
return;
}
if (NULL ==
- (plugin = CHALLENGER_DB_plugin_load (cfg)))
+ (plugin = CHALLENGER_DB_plugin_load (cfg,
+ false)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to initialize database plugin.\n");
diff --git a/src/challenger/challenger-httpd.c
b/src/challenger/challenger-httpd.c
index 550564f..9122ed3 100644
--- a/src/challenger/challenger-httpd.c
+++ b/src/challenger/challenger-httpd.c
@@ -662,7 +662,8 @@ run (void *cls,
&rc);
rc = GNUNET_CURL_gnunet_rc_create (CH_ctx);
if (NULL ==
- (CH_db = CHALLENGER_DB_plugin_load (config)))
+ (CH_db = CHALLENGER_DB_plugin_load (config,
+ false)))
{
global_ret = EXIT_NOTINSTALLED;
GNUNET_SCHEDULER_shutdown ();
diff --git a/src/challengerdb/challenger-dbinit.c
b/src/challengerdb/challenger-dbinit.c
index 2963c40..a29dbb8 100644
--- a/src/challengerdb/challenger-dbinit.c
+++ b/src/challengerdb/challenger-dbinit.c
@@ -60,7 +60,8 @@ run (void *cls,
(void) args;
(void) cfgfile;
if (NULL ==
- (plugin = CHALLENGER_DB_plugin_load (cfg)))
+ (plugin = CHALLENGER_DB_plugin_load (cfg,
+ true)))
{
fprintf (stderr,
"Failed to initialize database plugin.\n");
diff --git a/src/challengerdb/challenger_db_plugin.c
b/src/challengerdb/challenger_db_plugin.c
index a3f7217..f46a9f1 100644
--- a/src/challengerdb/challenger_db_plugin.c
+++ b/src/challengerdb/challenger_db_plugin.c
@@ -25,7 +25,8 @@
struct CHALLENGER_DatabasePlugin *
-CHALLENGER_DB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
+CHALLENGER_DB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ bool skip_preflight)
{
char *plugin_name;
char *lib_name;
@@ -52,6 +53,15 @@ CHALLENGER_DB_plugin_load (const struct
GNUNET_CONFIGURATION_Handle *cfg)
plugin->library_name = lib_name;
else
GNUNET_free (lib_name);
+ if ( (! skip_preflight) &&
+ (GNUNET_OK !=
+ plugin->preflight (plugin->cls)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Database not ready. Try running challenger-dbinit!\n");
+ CHALLENGER_DB_plugin_unload (plugin);
+ return NULL;
+ }
return plugin;
}
diff --git a/src/challengerdb/plugin_challengerdb_postgres.c
b/src/challengerdb/plugin_challengerdb_postgres.c
index 7732529..37f1f7f 100644
--- a/src/challengerdb/plugin_challengerdb_postgres.c
+++ b/src/challengerdb/plugin_challengerdb_postgres.c
@@ -130,11 +130,12 @@ internal_setup (struct PostgresClosure *pg)
#endif
struct GNUNET_PQ_Context *db_conn;
- db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
- "challengerdb-postgres",
- NULL,
- es,
- NULL);
+ db_conn = GNUNET_PQ_connect_with_cfg2 (pg->cfg,
+ "challengerdb-postgres",
+ "challenger-",
+ es,
+ NULL,
+ GNUNET_PQ_FLAG_CHECK_CURRENT);
if (NULL == db_conn)
return GNUNET_SYSERR;
pg->conn = db_conn;
@@ -371,13 +372,6 @@ libchallenger_plugin_db_postgres_init (void *cls)
GNUNET_free (pg);
return NULL;
}
- if (GNUNET_OK !=
- internal_setup (pg))
- {
- GNUNET_free (pg->sql_dir);
- GNUNET_free (pg);
- return NULL;
- }
plugin = GNUNET_new (struct CHALLENGER_DatabasePlugin);
plugin->cls = pg;
plugin->create_tables
diff --git a/src/challengerdb/test_challenger_db.c
b/src/challengerdb/test_challenger_db.c
index 2947e38..f1e29f2 100644
--- a/src/challengerdb/test_challenger_db.c
+++ b/src/challengerdb/test_challenger_db.c
@@ -27,14 +27,15 @@
#define FAILIF(cond) \
- do { \
- if (! (cond)) { break;} \
- GNUNET_break (0); \
- goto drop; \
- } while (0)
+ do { \
+ if (! (cond)) { break;} \
+ GNUNET_break (0); \
+ goto drop; \
+ } while (0)
#define RND_BLK(ptr) \
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*
\
+
ptr))
/**
* Global return value for the test. Initially -1, set to 0 upon
@@ -58,7 +59,8 @@ run (void *cls)
{
struct GNUNET_CONFIGURATION_Handle *cfg = cls;
- if (NULL == (plugin = CHALLENGER_DB_plugin_load (cfg)))
+ if (NULL == (plugin = CHALLENGER_DB_plugin_load (cfg,
+ true)))
{
result = 77;
return;
diff --git a/src/include/challenger_database_lib.h
b/src/include/challenger_database_lib.h
index 6a64574..26a64a5 100644
--- a/src/include/challenger_database_lib.h
+++ b/src/include/challenger_database_lib.h
@@ -14,7 +14,9 @@
Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- *
+ * @file include/challenger_database_lib.h
+ * @brief database helper functions for postgres used by challenger
+ * @author Christian Grothoff
*/
#ifndef CHALLENGER_DB_LIB_H
#define CHALLENGER_DB_LIB_H
@@ -26,10 +28,14 @@
* Initialize the plugin.
*
* @param cfg configuration to use
+ * @param skip_preflight true if we should skip the usual
+ * preflight check which assures us that the DB is actually
+ * operational; only challenger-dbinit should use true here.
* @return NULL on failure
*/
struct CHALLENGER_DatabasePlugin *
-CHALLENGER_DB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg);
+CHALLENGER_DB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ bool skip_preflight);
/**
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-challenger] branch master updated: ensure we do not start if the database version is outdated (#9203),
gnunet <=