diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-04-22 14:43:26 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-04-22 14:43:26 +0200 |
commit | c3fc8c5e558d4bcba0492c8d0e2d563ce7fb0519 (patch) | |
tree | 298dd03ad10b6f2580a364db14dc328c034d57b7 /src/exchange/taler-exchange-wirewatch.c | |
parent | 76b934b219b6ec82f58a7e95cbc6fff4f4ed0ebf (diff) | |
download | exchange-c3fc8c5e558d4bcba0492c8d0e2d563ce7fb0519.tar.gz exchange-c3fc8c5e558d4bcba0492c8d0e2d563ce7fb0519.tar.bz2 exchange-c3fc8c5e558d4bcba0492c8d0e2d563ce7fb0519.zip |
fix fakebank long polling
Diffstat (limited to 'src/exchange/taler-exchange-wirewatch.c')
-rw-r--r-- | src/exchange/taler-exchange-wirewatch.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index 2bffc3b85..235c0153f 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -58,6 +58,12 @@ static struct TALER_BANK_CreditHistoryHandle *hh; static bool hh_returned_data; /** + * Set to true if the request for history did not + * succeed because the account was unknown. + */ +static bool hh_account_404; + +/** * When did we start the last @e hh request? */ static struct GNUNET_TIME_Absolute hh_start_time; @@ -472,9 +478,9 @@ transaction_completed (void) GNUNET_SCHEDULER_shutdown (); return; } - if (! hh_returned_data) + if (! (hh_returned_data || hh_account_404) ) { - /* Enforce long polling delay even if the server ignored it + /* Enforce long-polling delay even if the server ignored it and returned earlier */ struct GNUNET_TIME_Relative latency; struct GNUNET_TIME_Relative left; @@ -482,12 +488,17 @@ transaction_completed (void) latency = GNUNET_TIME_absolute_get_duration (hh_start_time); left = GNUNET_TIME_relative_subtract (longpoll_timeout, latency); -#if 1 - left = GNUNET_TIME_relative_min (left, - GNUNET_TIME_UNIT_SECONDS); -#endif + if (! (test_mode || + GNUNET_TIME_relative_is_zero (left)) ) + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, // WARNING, + "Server did not respect long-polling, enforcing client-side by sleeping for %s\n", + GNUNET_TIME_relative2s (left, + true)); delayed_until = GNUNET_TIME_relative_to_absolute (left); } + if (hh_account_404) + delayed_until = GNUNET_TIME_relative_to_absolute ( + GNUNET_TIME_UNIT_MILLISECONDS); if (test_mode) delayed_until = GNUNET_TIME_UNIT_ZERO_ABS; GNUNET_assert (NULL == task); @@ -713,7 +724,7 @@ history_cb (void *cls, } GNUNET_assert (NULL == task); hh = NULL; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "History request returned with HTTP status %u\n", reply->http_status); switch (reply->http_status) @@ -727,6 +738,7 @@ history_cb (void *cls, transaction_completed (); return; case MHD_HTTP_NOT_FOUND: + hh_account_404 = true; if (ignore_account_404) { transaction_completed (); @@ -765,6 +777,7 @@ continue_with_shard (void *cls) (unsigned long long) latest_row_off); hh_start_time = GNUNET_TIME_absolute_get (); hh_returned_data = false; + hh_account_404 = false; hh = TALER_BANK_credit_history (ctx, ai->auth, latest_row_off, @@ -862,6 +875,13 @@ lock_shard (void *cls) GNUNET_STRINGS_relative_time_to_string (rdelay, true)); #if 1 + if (GNUNET_TIME_relative_cmp (rdelay, + >, + GNUNET_TIME_UNIT_SECONDS)) + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Delay would have been for %s\n", + GNUNET_TIME_relative2s (rdelay, + true)); rdelay = GNUNET_TIME_relative_min (rdelay, GNUNET_TIME_UNIT_SECONDS); #endif |