-fix crash in wirewatch if badly configured

This commit is contained in:
Christian Grothoff 2023-01-06 15:26:10 +01:00
parent 62a6142a8d
commit ade221f974
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 21 additions and 18 deletions

View File

@ -225,13 +225,16 @@ shutdown_task (void *cls)
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
started_transaction = false; started_transaction = false;
} }
qs = db_plugin->abort_shard (db_plugin->cls, if (shard_open)
job_name, {
shard_start, qs = db_plugin->abort_shard (db_plugin->cls,
shard_end); job_name,
if (qs <= 0) shard_start,
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, shard_end);
"Failed to abort work shard on shutdown\n"); if (qs <= 0)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to abort work shard on shutdown\n");
}
GNUNET_free (job_name); GNUNET_free (job_name);
if (NULL != ctx) if (NULL != ctx)
{ {
@ -327,8 +330,6 @@ exchange_serve_process_config (void)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No wire accounts configured for credit!\n"); "No wire accounts configured for credit!\n");
TALER_EXCHANGEDB_plugin_unload (db_plugin);
db_plugin = NULL;
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
TALER_EXCHANGEDB_find_accounts (&add_account_cb, TALER_EXCHANGEDB_find_accounts (&add_account_cb,
@ -339,8 +340,6 @@ exchange_serve_process_config (void)
"No accounts enabled for credit!\n"); "No accounts enabled for credit!\n");
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT; global_ret = EXIT_INVALIDARGUMENT;
TALER_EXCHANGEDB_plugin_unload (db_plugin);
db_plugin = NULL;
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
return GNUNET_OK; 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 static void
lock_shard (void *cls) lock_shard (void *cls)
{ {

View File

@ -28,9 +28,9 @@
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
TEH_PG_abort_shard (void *cls, TEH_PG_abort_shard (void *cls,
const char *job_name, const char *job_name,
uint64_t start_row, uint64_t start_row,
uint64_t end_row) uint64_t end_row)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
@ -40,14 +40,13 @@ TEH_PG_abort_shard (void *cls,
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
PREPARE (pg, PREPARE (pg,
"abort_shard", "abort_shard",
"UPDATE work_shards" "UPDATE work_shards"
" SET last_attempt=0" " SET last_attempt=0"
" WHERE job_name = $1 " " WHERE job_name=$1"
" AND start_row = $2 " " AND start_row=$2"
" AND end_row = $3;"); " AND end_row=$3;");
return GNUNET_PQ_eval_prepared_non_select (pg->conn, return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"abort_shard", "abort_shard",
params); params);