From 3cd50b42f77908fb0e428dcfdbfd617731dcc3ae Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 1 Nov 2021 16:43:49 +0100 Subject: stasis: fix some DB issues * do not always create a new DB connection * use the correct config section --- src/stasis/plugin_anastasis_postgres.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/stasis') diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c index b0b8f96..729c76d 100644 --- a/src/stasis/plugin_anastasis_postgres.c +++ b/src/stasis/plugin_anastasis_postgres.c @@ -134,7 +134,7 @@ postgres_create_tables (void *cls) * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ static enum GNUNET_GenericReturnValue -postgres_connect (void *cls) +prepare_statements (void *cls) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_PreparedStatement ps[] = { @@ -502,14 +502,16 @@ postgres_connect (void *cls) GNUNET_PQ_PREPARED_STATEMENT_END }; - pg->conn = GNUNET_PQ_connect_with_cfg (pg->cfg, - "stasis-postgres", - NULL, - NULL, - ps); - if (NULL == pg->conn) - return GNUNET_SYSERR; - return GNUNET_OK; + { + enum GNUNET_GenericReturnValue ret; + + ret = GNUNET_PQ_prepare_statements (pg->conn, + ps); + if (GNUNET_OK != ret) + return ret; + pg->init = true; + return GNUNET_OK; + } } @@ -562,7 +564,7 @@ internal_setup (struct PostgresClosure *pg, struct GNUNET_PQ_Context *db_conn; db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg, - "exchangedb-postgres", + "stasis-postgres", NULL, es, NULL); @@ -576,7 +578,7 @@ internal_setup (struct PostgresClosure *pg, return GNUNET_OK; if (skip_prepare) return GNUNET_OK; - return postgres_connect (pg); + return prepare_statements (pg); } @@ -2784,7 +2786,8 @@ libanastasis_plugin_db_postgres_init (void *cls) } plugin = GNUNET_new (struct ANASTASIS_DatabasePlugin); plugin->cls = pg; - plugin->connect = &postgres_connect; + /* FIXME: Should this be the same? */ + plugin->connect = &postgres_preflight; plugin->create_tables = &postgres_create_tables; plugin->drop_tables = &postgres_drop_tables; plugin->gc = &postgres_gc; -- cgit v1.2.3