diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bank-lib/bank_api_credit.c | 6 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 20 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_csr.c | 26 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_keys.c | 4 | ||||
-rw-r--r-- | src/exchange/taler-exchange-wirewatch.c | 2 | ||||
-rw-r--r-- | src/lib/exchange_api_reserves_get.c | 5 |
6 files changed, 38 insertions, 25 deletions
diff --git a/src/bank-lib/bank_api_credit.c b/src/bank-lib/bank_api_credit.c index 9835a8c9d..4842de969 100644 --- a/src/bank-lib/bank_api_credit.c +++ b/src/bank-lib/bank_api_credit.c @@ -248,12 +248,15 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx, { if ( (0 < num_results) && (! GNUNET_TIME_relative_is_zero (timeout)) ) + /* 0 == start_row is implied, go with timeout into future */ GNUNET_snprintf (url, sizeof (url), "history/incoming?delta=%lld&long_poll_ms=%llu", (long long) num_results, tms); else + /* Going back from current transaction or have no timeout; + hence timeout makes no sense */ GNUNET_snprintf (url, sizeof (url), "history/incoming?delta=%lld", @@ -263,6 +266,7 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx, { if ( (0 < num_results) && (! GNUNET_TIME_relative_is_zero (timeout)) ) + /* going forward from num_result */ GNUNET_snprintf (url, sizeof (url), "history/incoming?delta=%lld&start=%llu&long_poll_ms=%llu", @@ -270,6 +274,8 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx, (unsigned long long) start_row, tms); else + /* going backwards or have no timeout; + hence timeout makes no sense */ GNUNET_snprintf (url, sizeof (url), "history/incoming?delta=%lld&start=%llu", diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index c88ddd7c8..d247d981b 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -81,6 +81,11 @@ #define UNIX_BACKLOG 50 /** + * How often will we try to connect to the database before giving up? + */ +#define MAX_DB_RETRIES 5 + +/** * Above what request latency do we start to log? */ #define WARN_LATENCY GNUNET_TIME_relative_multiply ( \ @@ -1965,11 +1970,20 @@ exchange_serve_process_config (void) GNUNET_free (attr_enc_key_str); } - if (NULL == - (TEH_plugin = TALER_EXCHANGEDB_plugin_load (TEH_cfg))) + for (unsigned int i = 0; i<MAX_DB_RETRIES; i++) + { + TEH_plugin = TALER_EXCHANGEDB_plugin_load (TEH_cfg); + if (NULL != TEH_plugin) + break; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Failed to connect to DB, will try again %u times\n", + MAX_DB_RETRIES - i); + sleep (1); + } + if (NULL == TEH_plugin) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize DB subsystem\n"); + "Failed to initialize DB subsystem. Giving up.\n"); return GNUNET_SYSERR; } return GNUNET_OK; diff --git a/src/exchange/taler-exchange-httpd_csr.c b/src/exchange/taler-exchange-httpd_csr.c index a22fdfff5..29f83c2c9 100644 --- a/src/exchange/taler-exchange-httpd_csr.c +++ b/src/exchange/taler-exchange-httpd_csr.c @@ -234,12 +234,10 @@ TEH_handler_csr_withdraw (struct TEH_RequestContext *rc, .cipher = TALER_DENOMINATION_CS }; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed ("nonce", - &nonce, - sizeof (struct TALER_CsNonce)), - GNUNET_JSON_spec_fixed ("denom_pub_hash", - &denom_pub_hash, - sizeof (struct TALER_DenominationHashP)), + GNUNET_JSON_spec_fixed_auto ("nonce", + &nonce), + GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", + &denom_pub_hash), GNUNET_JSON_spec_end () }; struct TEH_DenominationKey *dk; @@ -333,17 +331,11 @@ TEH_handler_csr_withdraw (struct TEH_RequestContext *rc, } } - { - json_t *csr_obj; - - csr_obj = GNUNET_JSON_PACK ( - TALER_JSON_pack_exchange_withdraw_values ("ewv", - &ewv)); - GNUNET_assert (NULL != csr_obj); - return TALER_MHD_reply_json_steal (rc->connection, - csr_obj, - MHD_HTTP_OK); - } + return TALER_MHD_REPLY_JSON_PACK ( + rc->connection, + MHD_HTTP_OK, + TALER_JSON_pack_exchange_withdraw_values ("ewv", + &ewv)); } diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index 8b72d7803..d73283509 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c @@ -738,7 +738,7 @@ free_denom_cb (void *cls, * @param value the `struct HelperSignkey` to release * @return #GNUNET_OK (continue to iterate) */ -static int +static enum GNUNET_GenericReturnValue free_esign_cb (void *cls, const struct GNUNET_PeerIdentity *pid, void *value) @@ -3616,6 +3616,7 @@ TEH_keys_management_get_keys_handler (const struct TEH_RequestHandler *rh, if ( (GNUNET_is_zero (&denom_rsa_sm_pub)) && (GNUNET_is_zero (&denom_cs_sm_pub)) ) { + /* Either IPC failed, or neither helper had any denominations configured. */ return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_GATEWAY, TALER_EC_EXCHANGE_DENOMINATION_HELPER_UNAVAILABLE, @@ -3628,7 +3629,6 @@ TEH_keys_management_get_keys_handler (const struct TEH_RequestHandler *rh, TALER_EC_EXCHANGE_SIGNKEY_HELPER_UNAVAILABLE, NULL); } - // then a secmod helper is not yet running and we should return an MHD_HTTP_BAD_GATEWAY! GNUNET_assert (NULL != fbc.denoms); GNUNET_assert (NULL != fbc.signkeys); GNUNET_CONTAINER_multihashmap_iterate (ksh->helpers->denom_keys, diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index a7a6b004f..168e7b9b7 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -757,7 +757,7 @@ continue_with_shard (void *cls) shard_end - latest_row_off); GNUNET_assert (NULL == hh); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Requesting credit history staring from %llu\n", + "Requesting credit history starting from %llu\n", (unsigned long long) latest_row_off); hh_start_time = GNUNET_TIME_absolute_get (); hh_returned_data = false; diff --git a/src/lib/exchange_api_reserves_get.c b/src/lib/exchange_api_reserves_get.c index d829b4593..1c2c2b027 100644 --- a/src/lib/exchange_api_reserves_get.c +++ b/src/lib/exchange_api_reserves_get.c @@ -168,9 +168,10 @@ handle_reserves_get_finished (void *cls, rs.hr.ec = TALER_JSON_get_error_code (j); rs.hr.hint = TALER_JSON_get_error_hint (j); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unexpected response code %u/%d for reserves get\n", + "Unexpected response code %u/%d for GET %s\n", (unsigned int) response_code, - (int) rs.hr.ec); + (int) rs.hr.ec, + rgh->url); break; } if (NULL != rgh->cb) |