From 8f0a4b6095fd05e101fc5389cc46ec211083979a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 15 Jul 2020 21:22:44 +0200 Subject: fix #6133: enable nice shutdown of auditor helpers with CTRL-C --- src/auditor/taler-helper-auditor-aggregation.c | 4 +++ src/auditor/taler-helper-auditor-coins.c | 41 ++++++++++++++++++++++++-- src/auditor/taler-helper-auditor-deposits.c | 12 ++++++-- src/auditor/taler-helper-auditor-reserves.c | 14 ++++++++- src/auditor/taler-helper-auditor-wire.c | 12 ++++++++ 5 files changed, 76 insertions(+), 7 deletions(-) (limited to 'src/auditor') 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; } -- cgit v1.2.3