aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-01-06 15:26:10 +0100
committerChristian Grothoff <christian@grothoff.org>2023-01-06 15:26:10 +0100
commitade221f9741aba5c8b3efdf022fd95b9f363b1d8 (patch)
tree23d65dfc7dd8cb7a05b80150e316a8b96a821284
parent62a6142a8d69984cf852af3e0ef402d23c07ac85 (diff)
-fix crash in wirewatch if badly configured
-rw-r--r--src/exchange/taler-exchange-wirewatch.c26
-rw-r--r--src/exchangedb/pg_abort_shard.c13
2 files changed, 21 insertions, 18 deletions
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c
index ff7b93b5e..337b11ca3 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -225,13 +225,16 @@ shutdown_task (void *cls)
db_plugin->rollback (db_plugin->cls);
started_transaction = false;
}
- qs = db_plugin->abort_shard (db_plugin->cls,
- job_name,
- shard_start,
- shard_end);
- if (qs <= 0)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Failed to abort work shard on shutdown\n");
+ if (shard_open)
+ {
+ qs = db_plugin->abort_shard (db_plugin->cls,
+ job_name,
+ shard_start,
+ shard_end);
+ if (qs <= 0)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to abort work shard on shutdown\n");
+ }
GNUNET_free (job_name);
if (NULL != ctx)
{
@@ -327,8 +330,6 @@ exchange_serve_process_config (void)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No wire accounts configured for credit!\n");
- TALER_EXCHANGEDB_plugin_unload (db_plugin);
- db_plugin = NULL;
return GNUNET_SYSERR;
}
TALER_EXCHANGEDB_find_accounts (&add_account_cb,
@@ -339,8 +340,6 @@ exchange_serve_process_config (void)
"No accounts enabled for credit!\n");
GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
- TALER_EXCHANGEDB_plugin_unload (db_plugin);
- db_plugin = NULL;
return GNUNET_SYSERR;
}
return GNUNET_OK;
@@ -1142,6 +1141,11 @@ continue_with_shard (void *cls)
}
+/**
+ * Reserve a shard for us to work on.
+ *
+ * @param cls NULL
+ */
static void
lock_shard (void *cls)
{
diff --git a/src/exchangedb/pg_abort_shard.c b/src/exchangedb/pg_abort_shard.c
index de10f7d3f..d04680a81 100644
--- a/src/exchangedb/pg_abort_shard.c
+++ b/src/exchangedb/pg_abort_shard.c
@@ -28,9 +28,9 @@
enum GNUNET_DB_QueryStatus
TEH_PG_abort_shard (void *cls,
- const char *job_name,
- uint64_t start_row,
- uint64_t end_row)
+ const char *job_name,
+ uint64_t start_row,
+ uint64_t end_row)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
@@ -40,14 +40,13 @@ TEH_PG_abort_shard (void *cls,
GNUNET_PQ_query_param_end
};
-
PREPARE (pg,
"abort_shard",
"UPDATE work_shards"
" SET last_attempt=0"
- " WHERE job_name = $1 "
- " AND start_row = $2 "
- " AND end_row = $3;");
+ " WHERE job_name=$1"
+ " AND start_row=$2"
+ " AND end_row=$3;");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"abort_shard",
params);