From 190a1fadafd65d8716f9bcf0704e2bd68c9eeedd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 19 Aug 2018 17:19:27 +0200 Subject: re-init logging so we can tell by PID who it is --- src/auditor/taler-auditor.c | 1 + src/benchmark/taler-exchange-benchmark.c | 6 +++ src/exchange/taler-exchange-httpd_deposit.c | 3 +- src/exchange/taler-exchange-httpd_payback.c | 1 + src/exchange/taler-exchange-httpd_refresh_melt.c | 1 + src/exchange/taler-exchange-httpd_refund.c | 1 + src/exchangedb/perf_taler_exchangedb_interpreter.c | 1 + src/exchangedb/plugin_exchangedb_postgres.c | 56 +++++++++++++++------- src/exchangedb/test_exchangedb.c | 2 + src/include/taler_exchangedb_plugin.h | 2 + 10 files changed, 56 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index f5d185cf0..c32f46184 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -2120,6 +2120,7 @@ wire_transfer_information_cb (void *cls, qs = edb->get_coin_transactions (edb->cls, esession, coin_pub, + GNUNET_YES, &tl); if ( (qs < 0) || (NULL == tl) ) diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 4a664da52..26163d12a 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -571,6 +571,9 @@ parallel_benchmark (TALER_TESTING_Main main_cb, fakebank = fork (); if (0 == fakebank) { + GNUNET_log_setup ("benchmark-fakebank", + NULL == loglev ? "INFO" : loglev, + logfile); GNUNET_SCHEDULER_run (&launch_fakebank, exchange_bank_account.bank_base_url); exit (0); @@ -686,6 +689,9 @@ parallel_benchmark (TALER_TESTING_Main main_cb, if (0 == (cpids[i] = fork ())) { /* I am the child, do the work! */ + GNUNET_log_setup ("benchmark-worker", + NULL == loglev ? "INFO" : loglev, + logfile); result = TALER_TESTING_setup (run, NULL, diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 53fe4222a..107456cad 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -153,7 +153,7 @@ deposit_transaction (void *cls, } return qs; } - if (1 == qs) + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { struct TALER_Amount amount_without_fee; @@ -182,6 +182,7 @@ deposit_transaction (void *cls, qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, session, &deposit->coin.coin_pub, + GNUNET_NO, &tl); if (0 > qs) return qs; diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c index aebbe2b82..877a3ce26 100644 --- a/src/exchange/taler-exchange-httpd_payback.c +++ b/src/exchange/taler-exchange-httpd_payback.c @@ -209,6 +209,7 @@ payback_transaction (void *cls, qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, session, &pc->coin->coin_pub, + GNUNET_YES, &tl); if (0 > qs) { diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c b/src/exchange/taler-exchange-httpd_refresh_melt.c index 83bf197e2..a844d3a4b 100644 --- a/src/exchange/taler-exchange-httpd_refresh_melt.c +++ b/src/exchange/taler-exchange-httpd_refresh_melt.c @@ -172,6 +172,7 @@ refresh_check_melt (struct MHD_Connection *connection, qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, session, &rmc->refresh_session.coin.coin_pub, + GNUNET_NO, &tl); if (0 > qs) { diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index 8d573e473..869158063 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -164,6 +164,7 @@ refund_transaction (void *cls, qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, session, &refund->coin.coin_pub, + GNUNET_NO, &tl); if (0 > qs) { diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 2d0ec396c..6c0460321 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -1410,6 +1410,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state) qs = state->plugin->get_coin_transactions (state->plugin->cls, state->session, &coin->public_info.coin_pub, + GNUNET_YES, &transactions); GNUNET_assert (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs); GNUNET_assert (transactions != NULL); diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index d3efb9314..f24b8f713 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1579,7 +1579,7 @@ postgres_prepare (PGconn *db_conn) ",denoms.denom_pub" ",coins.denom_sig" " FROM payback" - " JOIN known_coins coins" + " JOIN kown_coins coins" " USING (coin_pub)" " JOIN denominations denoms" " USING (denom_pub_hash)" @@ -4276,6 +4276,23 @@ add_coin_payback (void *cls, } +/** + * Work we need to do. + */ +struct Work +{ + /** + * SQL prepared statement name. + */ + const char *statement; + + /** + * Function to call to handle the result(s). + */ + GNUNET_PQ_PostgresResultHandler cb; +}; + + /** * Compile a list of all (historic) transactions performed * with the given coin (/refresh/melt, /deposit and /refund operations). @@ -4290,25 +4307,22 @@ static enum GNUNET_DB_QueryStatus postgres_get_coin_transactions (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_CoinSpendPublicKeyP *coin_pub, + int include_payback, struct TALER_EXCHANGEDB_TransactionList **tlp) { - struct CoinHistoryContext chc; - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (coin_pub), - GNUNET_PQ_query_param_end + static const struct Work work_op[] = { + /** #TALER_EXCHANGEDB_TT_DEPOSIT */ + { "get_deposit_with_coin_pub", + &add_coin_deposit }, + /** #TALER_EXCHANGEDB_TT_REFRESH_MELT */ + { "get_refresh_session_by_coin", + &add_coin_melt }, + /** #TALER_EXCHANGEDB_TT_REFUND */ + { "get_refunds_by_coin", + &add_coin_refund }, + { NULL, NULL } }; - enum GNUNET_DB_QueryStatus qs; - struct { - /** - * SQL prepared statement name. - */ - const char *statement; - - /** - * Function to call to handle the result(s). - */ - GNUNET_PQ_PostgresResultHandler cb; - } work[] = { + static const struct Work work_wp[] = { /** #TALER_EXCHANGEDB_TT_DEPOSIT */ { "get_deposit_with_coin_pub", &add_coin_deposit }, @@ -4323,7 +4337,15 @@ postgres_get_coin_transactions (void *cls, &add_coin_payback }, { NULL, NULL } }; + struct CoinHistoryContext chc; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (coin_pub), + GNUNET_PQ_query_param_end + }; + enum GNUNET_DB_QueryStatus qs; + const struct Work * work; + work = (GNUNET_YES == include_payback) ? work_wp : work_op; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting transactions for coin %s\n", TALER_B2S (coin_pub)); diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 8666f1a5d..f69127ece 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -718,6 +718,7 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) qs = plugin->get_coin_transactions (plugin->cls, session, &refresh_session.coin.coin_pub, + GNUNET_YES, &tl); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs); plugin->free_coin_transaction_list (plugin->cls, @@ -2132,6 +2133,7 @@ run (void *cls) qs = plugin->get_coin_transactions (plugin->cls, session, &refund.coin.coin_pub, + GNUNET_YES, &tl); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs); GNUNET_assert (NULL != tl); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index b06bc7409..580a628c6 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -1680,6 +1680,7 @@ struct TALER_EXCHANGEDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session database connection * @param coin_pub coin to investigate + * @param include_payback include payback transactions of the coin? * @param[out] tlp set to list of transactions, NULL if coin is fresh * @return database transaction status */ @@ -1687,6 +1688,7 @@ struct TALER_EXCHANGEDB_Plugin (*get_coin_transactions) (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_CoinSpendPublicKeyP *coin_pub, + int include_payback, struct TALER_EXCHANGEDB_TransactionList **tlp); -- cgit v1.2.3