summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-07-29 23:56:46 +0200
committerChristian Grothoff <christian@grothoff.org>2021-07-29 23:56:46 +0200
commit0ef7c0a0b716785e7d1b0233e622d2e7267a0280 (patch)
treeff4b46d1182acd71fa5c6e29b9aaa786dbcf2b22 /src/exchange
parent1b419adab48fc0fd915835e0d57c5923e515280c (diff)
downloadexchange-0ef7c0a0b716785e7d1b0233e622d2e7267a0280.tar.gz
exchange-0ef7c0a0b716785e7d1b0233e622d2e7267a0280.tar.bz2
exchange-0ef7c0a0b716785e7d1b0233e622d2e7267a0280.zip
fix #6960
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-aggregator.c42
-rw-r--r--src/exchange/taler-exchange-closer.c39
-rw-r--r--src/exchange/taler-exchange-httpd.c18
-rw-r--r--src/exchange/taler-exchange-transfer.c44
-rw-r--r--src/exchange/taler-exchange-wirewatch.c28
5 files changed, 59 insertions, 112 deletions
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index 786183ad..75de467d 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -153,21 +153,7 @@ static struct GNUNET_TIME_Relative aggregator_idle_sleep_interval;
/**
* Value to return from main(). 0 on success, non-zero on errors.
*/
-static enum
-{
- GR_SUCCESS = 0,
- GR_DATABASE_SESSION_FAIL = 1,
- GR_DATABASE_TRANSACTION_BEGIN_FAIL = 2,
- GR_DATABASE_READY_DEPOSIT_HARD_FAIL = 3,
- GR_DATABASE_ITERATE_DEPOSIT_HARD_FAIL = 4,
- GR_DATABASE_TINY_MARK_HARD_FAIL = 5,
- GR_DATABASE_PREPARE_HARD_FAIL = 6,
- GR_DATABASE_PREPARE_COMMIT_HARD_FAIL = 7,
- GR_INVARIANT_FAILURE = 8,
- GR_CONFIGURATION_INVALID = 9,
- GR_CMD_LINE_UTF8_ERROR = 9,
- GR_CMD_LINE_OPTIONS_WRONG = 10,
-} global_ret;
+static int global_ret;
/**
* #GNUNET_YES if we are in test mode and should exit when idle.
@@ -676,7 +662,7 @@ run_aggregation (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to obtain database session!\n");
- global_ret = GR_DATABASE_SESSION_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -686,7 +672,7 @@ run_aggregation (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to start database transaction!\n");
- global_ret = GR_DATABASE_TRANSACTION_BEGIN_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -707,7 +693,7 @@ run_aggregation (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to execute deposit iteration!\n");
- global_ret = GR_DATABASE_READY_DEPOSIT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -756,7 +742,7 @@ run_aggregation (void *cls)
cleanup_au (&au_active);
db_plugin->rollback (db_plugin->cls,
session);
- global_ret = GR_DATABASE_ITERATE_DEPOSIT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -805,7 +791,7 @@ run_aggregation (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to start database transaction!\n");
- global_ret = GR_DATABASE_TRANSACTION_BEGIN_FAIL;
+ global_ret = EXIT_FAILURE;
cleanup_au (&au_active);
GNUNET_SCHEDULER_shutdown ();
return;
@@ -843,7 +829,7 @@ run_aggregation (void *cls)
db_plugin->rollback (db_plugin->cls,
session);
cleanup_au (&au_active);
- global_ret = GR_DATABASE_TINY_MARK_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -926,7 +912,7 @@ run_aggregation (void *cls)
db_plugin->rollback (db_plugin->cls,
session);
/* die hard */
- global_ret = GR_DATABASE_PREPARE_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -948,7 +934,7 @@ run_aggregation (void *cls)
return;
case GNUNET_DB_STATUS_HARD_ERROR:
GNUNET_break (0);
- global_ret = GR_DATABASE_PREPARE_COMMIT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
@@ -960,7 +946,7 @@ run_aggregation (void *cls)
return;
default:
GNUNET_break (0);
- global_ret = GR_INVARIANT_FAILURE;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -989,7 +975,7 @@ run (void *cls,
if (GNUNET_OK != parse_wirewatch_config ())
{
cfg = NULL;
- global_ret = GR_CONFIGURATION_INVALID;
+ global_ret = EXIT_NOTCONFIGURED;
return;
}
GNUNET_assert (NULL == task);
@@ -1025,7 +1011,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
- return GR_CMD_LINE_UTF8_ERROR;
+ return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc, argv,
"taler-exchange-aggregator",
@@ -1035,9 +1021,9 @@ main (int argc,
&run, NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
- return GR_CMD_LINE_OPTIONS_WRONG;
+ return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
- return 0;
+ return EXIT_SUCCESS;
return global_ret;
}
diff --git a/src/exchange/taler-exchange-closer.c b/src/exchange/taler-exchange-closer.c
index 0fd5e1d5..0cd288b4 100644
--- a/src/exchange/taler-exchange-closer.c
+++ b/src/exchange/taler-exchange-closer.c
@@ -66,22 +66,7 @@ static struct GNUNET_TIME_Relative aggregator_idle_sleep_interval;
* Value to return from main(). 0 on success, non-zero
* on serious errors.
*/
-static enum
-{
- GR_SUCCESS = 0,
- GR_WIRE_ACCOUNT_NOT_CONFIGURED = 1,
- GR_WIRE_TRANSFER_FEES_NOT_CONFIGURED = 2,
- GR_FAILURE_TO_ROUND_AMOUNT = 3,
- GR_DATABASE_INSERT_HARD_FAIL = 4,
- GR_DATABASE_SELECT_HARD_FAIL = 5,
- GR_DATABASE_COMMIT_HARD_FAIL = 6,
- GR_DATABASE_SESSION_START_FAIL = 7,
- GR_DATABASE_TRANSACTION_BEGIN_FAIL = 8,
- GR_CONFIGURATION_INVALID = 9,
- GR_CMD_LINE_UTF8_ERROR = 10,
- GR_CMD_LINE_OPTIONS_WRONG = 11,
- GR_INVALID_PAYTO_ENCOUNTERED = 12,
-} global_ret;
+static int global_ret;
/**
* #GNUNET_YES if we are in test mode and should exit when idle.
@@ -268,7 +253,7 @@ expired_reserve_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No wire account configured to deal with target URI `%s'\n",
account_payto_uri);
- global_ret = GR_WIRE_ACCOUNT_NOT_CONFIGURED;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -321,7 +306,7 @@ expired_reserve_cb (void *cls,
&currency_round_unit))
{
GNUNET_break (0);
- global_ret = GR_FAILURE_TO_ROUND_AMOUNT;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -360,7 +345,7 @@ expired_reserve_cb (void *cls,
(GNUNET_DB_STATUS_HARD_ERROR == qs) )
{
GNUNET_break (0);
- global_ret = GR_DATABASE_INSERT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -396,7 +381,7 @@ expired_reserve_cb (void *cls,
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{
GNUNET_break (0);
- global_ret = GR_DATABASE_INSERT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -429,7 +414,7 @@ run_reserve_closures (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to obtain database session!\n");
- global_ret = GR_DATABASE_SESSION_START_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -441,7 +426,7 @@ run_reserve_closures (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to start database transaction!\n");
- global_ret = GR_DATABASE_TRANSACTION_BEGIN_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -463,7 +448,7 @@ run_reserve_closures (void *cls)
GNUNET_break (0);
db_plugin->rollback (db_plugin->cls,
session);
- global_ret = GR_DATABASE_SELECT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
case GNUNET_DB_STATUS_SOFT_ERROR:
@@ -524,7 +509,7 @@ run (void *cls,
if (GNUNET_OK != parse_wirewatch_config ())
{
cfg = NULL;
- global_ret = GR_CONFIGURATION_INVALID;
+ global_ret = EXIT_NOTCONFIGURED;
return;
}
GNUNET_assert (NULL == task);
@@ -560,7 +545,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
- return GR_CMD_LINE_UTF8_ERROR;
+ return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc, argv,
"taler-exchange-closer",
@@ -569,9 +554,9 @@ main (int argc,
&run, NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
- return GR_CMD_LINE_OPTIONS_WRONG;
+ return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
- return 0;
+ return EXIT_SUCCESS;
return global_ret;
}
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 9696ab21..6113152a 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -1635,10 +1635,10 @@ main (int argc,
ret = GNUNET_GETOPT_run ("taler-exchange-httpd",
options,
argc, argv);
- if (ret < 0)
- return 1;
- if (0 == ret)
- return 0;
+ if (GNUNET_SYSERR == ret)
+ return EXIT_INVALIDARGUMENT;
+ if (GNUNET_NO == ret)
+ return EXIT_SUCCESS;
if (0 == num_threads)
{
cpu_set_t mask;
@@ -1669,12 +1669,12 @@ main (int argc,
"Malformed configuration file `%s', exit ...\n",
cfgfile);
GNUNET_free (cfgfile);
- return 1;
+ return EXIT_NOTCONFIGURED;
}
GNUNET_free (cfgfile);
if (GNUNET_OK !=
exchange_serve_process_config ())
- return 1;
+ return EXIT_NOTCONFIGURED;
TEH_load_terms (TEH_cfg);
/* check for systemd-style FD passing */
@@ -1715,10 +1715,10 @@ main (int argc,
/* initialize #internal_key_state with an RC of 1 */
if (GNUNET_OK !=
TEH_WIRE_init ())
- return 42;
+ return EXIT_FAILURE;
if (GNUNET_OK !=
TEH_keys_init ())
- return 43;
+ return EXIT_FAILURE;
ret = TEH_loop_init ();
if (GNUNET_OK == ret)
{
@@ -1737,7 +1737,7 @@ main (int argc,
fh = TALER_MHD_open_unix_path (serve_unixpath,
unixpath_mode);
if (-1 == fh)
- return 1;
+ return EXIT_NOPERMISSION; /* at least most likely */
}
ret = run_main_loop (fh,
argv);
diff --git a/src/exchange/taler-exchange-transfer.c b/src/exchange/taler-exchange-transfer.c
index 370aed6c..a416eb15 100644
--- a/src/exchange/taler-exchange-transfer.c
+++ b/src/exchange/taler-exchange-transfer.c
@@ -99,21 +99,7 @@ static struct GNUNET_TIME_Relative aggregator_idle_sleep_interval;
/**
* Value to return from main(). 0 on success, non-zero on errors.
*/
-static enum
-{
- GR_SUCCESS = 0,
- GR_WIRE_TRANSFER_FAILED = 1,
- GR_DATABASE_COMMIT_HARD_FAIL = 2,
- GR_INVARIANT_FAILURE = 3,
- GR_WIRE_ACCOUNT_NOT_CONFIGURED = 4,
- GR_WIRE_TRANSFER_BEGIN_FAIL = 5,
- GR_DATABASE_TRANSACTION_BEGIN_FAIL = 6,
- GR_DATABASE_SESSION_START_FAIL = 7,
- GR_CONFIGURATION_INVALID = 8,
- GR_CMD_LINE_UTF8_ERROR = 9,
- GR_CMD_LINE_OPTIONS_WRONG = 10,
- GR_DATABASE_FETCH_FAILURE = 11,
-} global_ret;
+static int global_ret;
/**
* #GNUNET_YES if we are in test mode and should exit when idle.
@@ -290,7 +276,7 @@ wire_confirm_cb (void *cls,
ec);
db_plugin->rollback (db_plugin->cls,
session);
- global_ret = GR_WIRE_TRANSFER_FAILED;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
GNUNET_free (wpd);
wpd = NULL;
@@ -310,7 +296,7 @@ wire_confirm_cb (void *cls,
}
else
{
- global_ret = GR_DATABASE_COMMIT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
}
GNUNET_free (wpd);
@@ -329,7 +315,7 @@ wire_confirm_cb (void *cls,
return;
case GNUNET_DB_STATUS_HARD_ERROR:
GNUNET_break (0);
- global_ret = GR_DATABASE_COMMIT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
@@ -343,7 +329,7 @@ wire_confirm_cb (void *cls,
return;
default:
GNUNET_break (0);
- global_ret = GR_INVARIANT_FAILURE;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -376,7 +362,7 @@ wire_prepare_cb (void *cls,
GNUNET_break (0);
db_plugin->rollback (db_plugin->cls,
wpd->session);
- global_ret = GR_DATABASE_FETCH_FAILURE;
+ global_ret = EXIT_FAILURE;
goto cleanup;
}
wpd->row_id = rowid;
@@ -391,7 +377,7 @@ wire_prepare_cb (void *cls,
GNUNET_break (0);
db_plugin->rollback (db_plugin->cls,
wpd->session);
- global_ret = GR_WIRE_ACCOUNT_NOT_CONFIGURED;
+ global_ret = EXIT_NOTCONFIGURED;
goto cleanup;
}
wa = wpd->wa;
@@ -406,7 +392,7 @@ wire_prepare_cb (void *cls,
GNUNET_break (0); /* Irrecoverable */
db_plugin->rollback (db_plugin->cls,
wpd->session);
- global_ret = GR_WIRE_TRANSFER_BEGIN_FAIL;
+ global_ret = EXIT_FAILURE;
goto cleanup;
}
return;
@@ -437,7 +423,7 @@ run_transfers (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to obtain database session!\n");
- global_ret = GR_DATABASE_SESSION_START_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -448,7 +434,7 @@ run_transfers (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to start database transaction!\n");
- global_ret = GR_DATABASE_TRANSACTION_BEGIN_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -468,7 +454,7 @@ run_transfers (void *cls)
{
case GNUNET_DB_STATUS_HARD_ERROR:
GNUNET_break (0);
- global_ret = GR_DATABASE_COMMIT_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
case GNUNET_DB_STATUS_SOFT_ERROR:
@@ -524,7 +510,7 @@ run (void *cls,
if (GNUNET_OK != parse_wirewatch_config ())
{
cfg = NULL;
- global_ret = GR_CONFIGURATION_INVALID;
+ global_ret = EXIT_NOTCONFIGURED;
return;
}
ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
@@ -570,7 +556,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
- return GR_CMD_LINE_UTF8_ERROR;
+ return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc, argv,
"taler-exchange-transfer",
@@ -580,9 +566,9 @@ main (int argc,
&run, NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
- return GR_CMD_LINE_OPTIONS_WRONG;
+ return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
- return 0;
+ return EXIT_SUCCESS;
return global_ret;
}
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c
index 4cdba640..eeb1af48 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -198,17 +198,7 @@ static unsigned int max_workers = 16;
* Value to return from main(). 0 on success, non-zero on
* on serious errors.
*/
-static enum
-{
- GR_SUCCESS = 0,
- GR_DATABASE_SESSION_FAIL = 1,
- GR_DATABASE_TRANSACTION_BEGIN_FAIL = 2,
- GR_DATABASE_SELECT_LATEST_HARD_FAIL = 3,
- GR_BANK_REQUEST_HISTORY_FAIL = 4,
- GR_CONFIGURATION_INVALID = 5,
- GR_CMD_LINE_UTF8_ERROR = 6,
- GR_CMD_LINE_OPTIONS_WRONG = 7,
-} global_ret;
+static int global_ret;
/**
* Are we run in testing mode and should only do one pass?
@@ -616,7 +606,7 @@ find_transfers (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to obtain database session!\n");
- global_ret = GR_DATABASE_SESSION_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -650,7 +640,7 @@ find_transfers (void *cls)
case GNUNET_DB_STATUS_HARD_ERROR:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to obtain starting point for montoring from database!\n");
- global_ret = GR_DATABASE_SELECT_LATEST_HARD_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
case GNUNET_DB_STATUS_SOFT_ERROR:
@@ -683,7 +673,7 @@ find_transfers (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to start database transaction!\n");
- global_ret = GR_DATABASE_TRANSACTION_BEGIN_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -704,7 +694,7 @@ find_transfers (void *cls)
"Failed to start request for account history!\n");
db_plugin->rollback (db_plugin->cls,
session);
- global_ret = GR_BANK_REQUEST_HISTORY_FAIL;
+ global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -733,7 +723,7 @@ run (void *cls,
if (GNUNET_OK !=
exchange_serve_process_config ())
{
- global_ret = GR_CONFIGURATION_INVALID;
+ global_ret = EXIT_NOTCONFIGURED;
return;
}
wa_pos = wa_head;
@@ -789,7 +779,7 @@ main (int argc,
if (GNUNET_OK !=
GNUNET_STRINGS_get_utf8_args (argc, argv,
&argc, &argv))
- return GR_CMD_LINE_UTF8_ERROR;
+ return EXIT_INVALIDARGUMENT;
ret = GNUNET_PROGRAM_run (
argc, argv,
"taler-exchange-wirewatch",
@@ -799,9 +789,9 @@ main (int argc,
&run, NULL);
GNUNET_free_nz ((void *) argv);
if (GNUNET_SYSERR == ret)
- return GR_CMD_LINE_OPTIONS_WRONG;
+ return EXIT_INVALIDARGUMENT;
if (GNUNET_NO == ret)
- return 0;
+ return EXIT_SUCCESS;
return global_ret;
}