diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-01-28 18:16:38 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-01-28 18:16:38 +0100 |
commit | b4ee41f8e0bbfe26e189764fb1773131beb3a9eb (patch) | |
tree | 3b6f358b880391decdbf3892e3fd73b52e7f9e2e | |
parent | d5398b862f7c80bc02c8b10ab61500dd48ae1925 (diff) |
-refine back-off logic for taler-merchant-wirewatch
-rw-r--r-- | src/backend/taler-merchant-wirewatch.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c index ab49d8f5..350d8560 100644 --- a/src/backend/taler-merchant-wirewatch.c +++ b/src/backend/taler-merchant-wirewatch.c @@ -81,6 +81,11 @@ struct Watch struct GNUNET_TIME_Relative delay; /** + * How long should long-polling take at least? + */ + struct GNUNET_TIME_Absolute long_poll_timeout; + + /** * Login data for the bank. */ struct TALER_MERCHANT_BANK_AuthenticationData ad; @@ -365,6 +370,8 @@ credit_cb ( GNUNET_SCHEDULER_shutdown (); return GNUNET_SYSERR; } + /* Success => reset back-off timer! */ + w->delay = GNUNET_TIME_UNIT_ZERO; { struct GNUNET_DB_EventHeaderP es = { .size = htons (sizeof (es)), @@ -381,9 +388,20 @@ credit_cb ( return GNUNET_OK; case MHD_HTTP_NO_CONTENT: save (w); - w->delay = GNUNET_TIME_UNIT_ZERO; + /* Delay artificially if server returned before long-poll timeout */ + w->delay = GNUNET_TIME_absolute_get_remaining (w->long_poll_timeout); + break; + case MHD_HTTP_NOT_FOUND: + /* configuration likely wrong, wait at least 1 minute, backoff up to 15 minutes! */ + w->delay = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MINUTES, + GNUNET_TIME_STD_BACKOFF (w->delay)); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Unexpected HTTP status code %u(%d) from bank\n", + http_status, + ec); break; default: + /* Something went wrong, try again, but with back-off */ w->delay = GNUNET_TIME_STD_BACKOFF (w->delay); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unexpected HTTP status code %u(%d) from bank\n", @@ -415,6 +433,8 @@ do_work (void *cls) w->task = NULL; w->found = false; + w->long_poll_timeout + = GNUNET_TIME_relative_to_absolute (BANK_TIMEOUT); w->hh = TALER_MERCHANT_BANK_credit_history (ctx, &w->ad, w->start_row, |