fix build system

This commit is contained in:
Christian Grothoff 2020-01-17 03:08:30 +01:00
parent da0a2f39d0
commit d4fded4b66
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
7 changed files with 60 additions and 5 deletions

View File

@ -1,3 +1,6 @@
[auditordb-postgres] [auditordb-postgres]
# Argument for Postgres for how to connect to the database. # Argument for Postgres for how to connect to the database.
CONFIG = "postgres:///taler" CONFIG = "postgres:///taler"
# Where are the SQL files to setup our tables?
SQL_DIR = $DATADIR/sql/auditor/

View File

@ -79,6 +79,11 @@ struct PostgresClosure
*/ */
pthread_key_t db_conn_threadlocal; pthread_key_t db_conn_threadlocal;
/**
* Directory with SQL statements to run to create tables.
*/
char *sql_dir;
/** /**
* Database connection string, as read from * Database connection string, as read from
* the configuration. * the configuration.
@ -408,8 +413,8 @@ postgres_create_tables (void *cls)
struct GNUNET_PQ_Context *conn; struct GNUNET_PQ_Context *conn;
conn = GNUNET_PQ_connect (pc->connection_cfg_str, conn = GNUNET_PQ_connect (pc->connection_cfg_str,
pc->sql_dir,
NULL, NULL,
es,
NULL); NULL);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -3446,10 +3451,23 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
const char *ec; const char *ec;
pg = GNUNET_new (struct PostgresClosure); pg = GNUNET_new (struct PostgresClosure);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
"auditordb-postgres",
"SQL_DIR",
&pg->sql_dir))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditordb-postgres",
"SQL_DIR");
GNUNET_free (pg);
return NULL;
}
if (0 != pthread_key_create (&pg->db_conn_threadlocal, if (0 != pthread_key_create (&pg->db_conn_threadlocal,
&db_conn_destroy)) &db_conn_destroy))
{ {
TALER_LOG_ERROR ("Cannnot create pthread key.\n"); TALER_LOG_ERROR ("Cannnot create pthread key.\n");
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -3469,6 +3487,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditordb-postgres", "auditordb-postgres",
"CONFIG"); "CONFIG");
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -3483,6 +3502,7 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
"taler", "taler",
"CURRENCY"); "CURRENCY");
GNUNET_free (pg->connection_cfg_str); GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -3589,6 +3609,7 @@ libtaler_plugin_auditordb_postgres_done (void *cls)
struct PostgresClosure *pg = plugin->cls; struct PostgresClosure *pg = plugin->cls;
GNUNET_free (pg->connection_cfg_str); GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg->currency); GNUNET_free (pg->currency);
GNUNET_free (pg); GNUNET_free (pg);
GNUNET_free (plugin); GNUNET_free (plugin);

View File

@ -6,6 +6,8 @@ DB = postgres
# Argument for Postgres for how to connect to the database. # Argument for Postgres for how to connect to the database.
CONFIG = "postgres:///talercheck" CONFIG = "postgres:///talercheck"
# Where are the SQL files to setup our tables?
SQL_DIR = $DATADIR/sql/exchange/
[taler] [taler]
CURRENCY = "EUR" CURRENCY = "EUR"

View File

@ -22,7 +22,7 @@ EXTRA_DIST = \
exchangedb.conf \ exchangedb.conf \
exchangedb-postgres.conf \ exchangedb-postgres.conf \
plugin_exchangedb_common.c \ plugin_exchangedb_common.c \
test-exchange-db-postgres.conf test-exchange-db-postgres.conf \
$(sql_DATA) $(sql_DATA)
plugindir = $(libdir)/taler plugindir = $(libdir)/taler

View File

@ -1,2 +1,5 @@
[exchangedb-postgres] [exchangedb-postgres]
CONFIG = "postgres:///taler" CONFIG = "postgres:///taler"
# Where are the SQL files to setup our tables?
SQL_DIR = $DATADIR/sql/exchange/

View File

@ -114,6 +114,11 @@ struct PostgresClosure
*/ */
char *connection_cfg_str; char *connection_cfg_str;
/**
* Directory with SQL statements to run to create tables.
*/
char *sql_dir;
/** /**
* After how long should idle reserves be closed? * After how long should idle reserves be closed?
*/ */
@ -503,8 +508,8 @@ postgres_create_tables (void *cls)
struct GNUNET_PQ_Context *conn; struct GNUNET_PQ_Context *conn;
conn = GNUNET_PQ_connect (pc->connection_cfg_str, conn = GNUNET_PQ_connect (pc->connection_cfg_str,
pc->sql_dir,
NULL, NULL,
es,
NULL); NULL);
if (NULL == conn) if (NULL == conn)
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -7489,11 +7494,23 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
const char *ec; const char *ec;
pg = GNUNET_new (struct PostgresClosure); pg = GNUNET_new (struct PostgresClosure);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
"exchangedb-postgres",
"SQL_DIR",
&pg->sql_dir))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb-postgres",
"CONFIG");
GNUNET_free (pg);
return NULL;
}
if (0 != pthread_key_create (&pg->db_conn_threadlocal, if (0 != pthread_key_create (&pg->db_conn_threadlocal,
&db_conn_destroy)) &db_conn_destroy))
{ {
TALER_LOG_ERROR ("Cannnot create pthread key.\n"); TALER_LOG_ERROR ("Cannnot create pthread key.\n");
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -7513,6 +7530,7 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb-postgres", "exchangedb-postgres",
"CONFIG"); "CONFIG");
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -7533,6 +7551,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchangedb", "exchangedb",
"LEGAL/IDLE_RESERVE_EXPIRATION_TIME"); "LEGAL/IDLE_RESERVE_EXPIRATION_TIME");
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -7545,6 +7565,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"taler", "taler",
"CURRENCY"); "CURRENCY");
GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg); GNUNET_free (pg);
return NULL; return NULL;
} }
@ -7656,6 +7678,7 @@ libtaler_plugin_exchangedb_postgres_done (void *cls)
struct PostgresClosure *pg = plugin->cls; struct PostgresClosure *pg = plugin->cls;
GNUNET_free (pg->connection_cfg_str); GNUNET_free (pg->connection_cfg_str);
GNUNET_free (pg->sql_dir);
GNUNET_free (pg->currency); GNUNET_free (pg->currency);
GNUNET_free (pg); GNUNET_free (pg);
GNUNET_free (plugin); GNUNET_free (plugin);

View File

@ -7,6 +7,9 @@ DB = postgres
#The connection string the plugin has to use for connecting to the database #The connection string the plugin has to use for connecting to the database
CONFIG = postgres:///talercheck CONFIG = postgres:///talercheck
# Where are the SQL files to setup our tables?
SQL_DIR = $DATADIR/sql/exchange/
[taler] [taler]
CURRENCY = EUR CURRENCY = EUR