summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-15 21:22:44 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-15 21:22:44 +0200
commit8f0a4b6095fd05e101fc5389cc46ec211083979a (patch)
treec6aa6ef9f8bb7d7d9b573fe313de6b0b3f7be6df
parent6cabb25d8d780949459382661fb318c32d76f992 (diff)
downloadexchange-8f0a4b6095fd05e101fc5389cc46ec211083979a.tar.gz
exchange-8f0a4b6095fd05e101fc5389cc46ec211083979a.tar.bz2
exchange-8f0a4b6095fd05e101fc5389cc46ec211083979a.zip
fix #6133: enable nice shutdown of auditor helpers with CTRL-C
-rw-r--r--src/auditor/taler-helper-auditor-aggregation.c4
-rw-r--r--src/auditor/taler-helper-auditor-coins.c41
-rw-r--r--src/auditor/taler-helper-auditor-deposits.c12
-rw-r--r--src/auditor/taler-helper-auditor-reserves.c14
-rw-r--r--src/auditor/taler-helper-auditor-wire.c12
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c8
-rw-r--r--src/include/taler_auditordb_plugin.h3
7 files changed, 83 insertions, 11 deletions
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c
index 2a56971d8..e3e840e8e 100644
--- a/src/auditor/taler-helper-auditor-aggregation.c
+++ b/src/auditor/taler-helper-auditor-aggregation.c
@@ -1176,11 +1176,15 @@ check_wire_out_cb (void *cls,
TALER_JSON_from_amount (&final_amount),
"claimed",
TALER_JSON_from_amount (amount)));
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Aggregation unit %s is OK\n",
TALER_B2S (wtid));
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c
index 8b163fd05..067d6703a 100644
--- a/src/auditor/taler-helper-auditor-coins.c
+++ b/src/auditor/taler-helper-auditor-coins.c
@@ -991,6 +991,8 @@ withdraw_cb (void *cls,
report_row_inconsistency ("withdraw",
rowid,
"denomination key not found");
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
@@ -1032,6 +1034,8 @@ withdraw_cb (void *cls,
TALER_ARL_amount_add (&ds->denom_risk,
&ds->denom_risk,
&value);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1252,6 +1256,8 @@ refresh_session_cb (void *cls,
report_row_inconsistency ("melt",
rowid,
"denomination key not found");
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
@@ -1346,6 +1352,8 @@ refresh_session_cb (void *cls,
TALER_ARL_amount_add (&total_refresh_hanging,
&total_refresh_hanging,
amount_with_fee);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
if (GNUNET_SYSERR == reveal_ctx.err)
@@ -1354,7 +1362,11 @@ refresh_session_cb (void *cls,
if (GNUNET_OK != reveal_ctx.err)
{
GNUNET_free (reveal_ctx.new_issues);
- return (GNUNET_SYSERR == reveal_ctx.err) ? GNUNET_SYSERR : GNUNET_OK;
+ if (GNUNET_SYSERR == reveal_ctx.err)
+ return GNUNET_SYSERR;
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
+ return GNUNET_OK;
}
/* Check that the resulting amounts are consistent with the value being
@@ -1527,6 +1539,8 @@ refresh_session_cb (void *cls,
&total_melt_fee_income,
&rfee);
}
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1586,6 +1600,8 @@ deposit_cb (void *cls,
report_row_inconsistency ("deposits",
rowid,
"denomination key not found");
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
if (refund_deadline.abs_value_us >
@@ -1645,6 +1661,8 @@ deposit_cb (void *cls,
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
amount_with_fee);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
TALER_amount_hton (&dr.amount_with_fee,
@@ -1669,6 +1687,8 @@ deposit_cb (void *cls,
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
amount_with_fee);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
}
@@ -1746,7 +1766,8 @@ deposit_cb (void *cls,
&total_deposit_fee_income,
&dfee);
}
-
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1797,7 +1818,9 @@ refund_cb (void *cls,
report_row_inconsistency ("refunds",
rowid,
"denomination key not found");
- return GNUNET_SYSERR;
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
+ return GNUNET_OK;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{
@@ -1835,6 +1858,8 @@ refund_cb (void *cls,
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
amount_with_fee);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
}
@@ -1851,6 +1876,8 @@ refund_cb (void *cls,
&amount_without_fee,
&refund_fee,
-1);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1893,6 +1920,8 @@ refund_cb (void *cls,
TALER_ARL_amount_add (&total_refund_fee_income,
&total_refund_fee_income,
&refund_fee);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1947,6 +1976,8 @@ check_recoup (struct CoinContext *cc,
report_row_inconsistency (operation,
rowid,
"denomination key not found");
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
@@ -1994,6 +2025,8 @@ check_recoup (struct CoinContext *cc,
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
amount);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
}
@@ -2032,6 +2065,8 @@ check_recoup (struct CoinContext *cc,
&total_recoup_loss,
amount);
}
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c
index ed23c6a52..41cf406cb 100644
--- a/src/auditor/taler-helper-auditor-deposits.c
+++ b/src/auditor/taler-helper-auditor-deposits.c
@@ -96,8 +96,9 @@ struct DepositConfirmationContext
* @param cls our `struct DepositConfirmationContext`
* @param serial_id row of the @a dc in the database
* @param dc the deposit confirmation we know
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERROR to stop iterating
*/
-static void
+static int
test_dc (void *cls,
uint64_t serial_id,
const struct TALER_AUDITORDB_DepositConfirmation *dc)
@@ -128,13 +129,15 @@ test_dc (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found deposit %s in exchange database\n",
GNUNET_h2s (&dc->h_contract_terms));
- return; /* found, all good */
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
+ return GNUNET_OK; /* found, all good */
}
if (qs < 0)
{
GNUNET_break (0); /* DB error, complain */
dcc->qs = qs;
- return;
+ return GNUNET_SYSERR;
}
}
/* deposit confirmation missing! report! */
@@ -155,6 +158,9 @@ test_dc (void *cls,
TALER_ARL_amount_add (&dcc->missed_amount,
&dcc->missed_amount,
&dc->amount_without_fee);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
+ return GNUNET_OK;
}
diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c
index 0b140e740..d596863e0 100644
--- a/src/auditor/taler-helper-auditor-reserves.c
+++ b/src/auditor/taler-helper-auditor-reserves.c
@@ -456,6 +456,8 @@ handle_reserve_in (void *cls,
idle_reserve_expiration_time);
rs->a_expiration_date = GNUNET_TIME_absolute_max (rs->a_expiration_date,
expiry);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -524,6 +526,8 @@ handle_reserve_out (void *cls,
report_row_inconsistency ("withdraw",
rowid,
"denomination key not found");
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -569,7 +573,9 @@ handle_reserve_out (void *cls,
TALER_ARL_amount_add (&total_bad_sig_loss,
&total_bad_sig_loss,
amount_with_fee);
- return GNUNET_OK; /* exit here, we cannot add this to the legitimate withdrawals */
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
+ return GNUNET_OK; /* exit function here, we cannot add this to the legitimate withdrawals */
}
GNUNET_CRYPTO_hash (reserve_pub,
@@ -620,6 +626,8 @@ handle_reserve_out (void *cls,
TALER_ARL_amount_add (&rs->total_fee,
&rs->total_fee,
&withdraw_fee);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -813,6 +821,8 @@ handle_recoup_by_reserve (
idle_reserve_expiration_time);
rs->a_expiration_date = GNUNET_TIME_absolute_max (rs->a_expiration_date,
expiry);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -980,6 +990,8 @@ handle_reserve_closed (
"Additional closing operation for reserve `%s' of %s\n",
TALER_B2S (reserve_pub),
TALER_amount2s (amount_with_fee));
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c
index 247a75725..7eb3a0473 100644
--- a/src/auditor/taler-helper-auditor-wire.c
+++ b/src/auditor/taler-helper-auditor-wire.c
@@ -1002,6 +1002,8 @@ wire_out_cb (void *cls,
TALER_ARL_amount_add (&total_bad_amount_out_minus,
&total_bad_amount_out_minus,
amount);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
{
@@ -1102,6 +1104,8 @@ cleanup:
&key,
roi));
wa->pp.last_wire_out_serial_id = rowid + 1;
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1491,9 +1495,13 @@ reserve_in_cb (void *cls,
&rii->row_off_hash),
"diagnostic", "duplicate wire offset"));
GNUNET_free (rii);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
wa->pp.last_reserve_in_serial_id = rowid + 1;
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -1866,6 +1874,8 @@ reserve_closed_cb (void *cls,
"diagnostic",
"closing fee above total amount"));
GNUNET_free (rc);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
pp.last_reserve_close_uuid
@@ -1882,6 +1892,8 @@ reserve_closed_cb (void *cls,
&key,
rc,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ if (TALER_ARL_do_abort ())
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index 4f9101fdc..e10df29d4 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -1236,9 +1236,11 @@ deposit_confirmation_cb (void *cls,
return;
}
dcc->qs = i + 1;
- dcc->cb (dcc->cb_cls,
- serial_id,
- &dc);
+ if (GNUNET_OK !=
+ dcc->cb (dcc->cb_cls,
+ serial_id,
+ &dc))
+ break;
}
}
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h
index 7c58e654e..33e1adecb 100644
--- a/src/include/taler_auditordb_plugin.h
+++ b/src/include/taler_auditordb_plugin.h
@@ -364,8 +364,9 @@ struct TALER_AUDITORDB_DepositConfirmation
* @param cls closure
* @param serial_id location of the @a dc in the database
* @param dc the deposit confirmation itself
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERROR to stop iterating
*/
-typedef void
+typedef int
(*TALER_AUDITORDB_DepositConfirmationCallback)(
void *cls,
uint64_t serial_id,