summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testing/testing_api_cmd_auditor_deposit_confirmation.c14
-rw-r--r--src/testing/testing_api_cmd_auditor_exchanges.c15
-rw-r--r--src/testing/testing_api_cmd_bank_admin_add_incoming.c15
-rw-r--r--src/testing/testing_api_cmd_bank_transfer.c17
-rw-r--r--src/testing/testing_api_cmd_deposit.c15
-rw-r--r--src/testing/testing_api_cmd_withdraw.c26
6 files changed, 76 insertions, 26 deletions
diff --git a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
index 96d0740e..bcef59c5 100644
--- a/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
+++ b/src/testing/testing_api_cmd_auditor_deposit_confirmation.c
@@ -29,6 +29,11 @@
#include "taler_signatures.h"
#include "backoff.h"
+/**
+ * How often do we retry before giving up?
+ */
+#define NUM_RETRIES 5
+
/**
* State for a "deposit confirmation" CMD.
@@ -83,9 +88,9 @@ struct DepositConfirmationState
unsigned int expected_response_code;
/**
- * Should we retry on (transient) failures?
+ * How often should we retry on (transient) failures?
*/
- int do_retry;
+ unsigned int do_retry;
};
@@ -140,8 +145,9 @@ deposit_confirmation_cb (void *cls,
dcs->dc = NULL;
if (dcs->expected_response_code != http_status)
{
- if (GNUNET_YES == dcs->do_retry)
+ if (0 != dcs->do_retry)
{
+ dcs->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -436,7 +442,7 @@ TALER_TESTING_cmd_deposit_confirmation_with_retry (struct TALER_TESTING_Command
GNUNET_assert (&deposit_confirmation_run == cmd.run);
dcs = cmd.cls;
- dcs->do_retry = GNUNET_YES;
+ dcs->do_retry = NUM_RETRIES;
return cmd;
}
diff --git a/src/testing/testing_api_cmd_auditor_exchanges.c b/src/testing/testing_api_cmd_auditor_exchanges.c
index c7acaab9..b5a1cab0 100644
--- a/src/testing/testing_api_cmd_auditor_exchanges.c
+++ b/src/testing/testing_api_cmd_auditor_exchanges.c
@@ -31,6 +31,12 @@
/**
+ * How often do we retry before giving up?
+ */
+#define NUM_RETRIES 5
+
+
+/**
* State for a "deposit confirmation" CMD.
*/
struct ExchangesState
@@ -72,9 +78,9 @@ struct ExchangesState
const char *exchange_url;
/**
- * Should we retry on (transient) failures?
+ * How often should we retry on (transient) failures?
*/
- int do_retry;
+ unsigned int do_retry;
};
@@ -132,8 +138,9 @@ exchanges_cb (void *cls,
es->leh = NULL;
if (es->expected_response_code != http_status)
{
- if (GNUNET_YES == es->do_retry)
+ if (0 != es->do_retry)
{
+ es->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -353,7 +360,7 @@ TALER_TESTING_cmd_exchanges_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&exchanges_run == cmd.run);
es = cmd.cls;
- es->do_retry = GNUNET_YES;
+ es->do_retry = NUM_RETRIES;
return cmd;
}
diff --git a/src/testing/testing_api_cmd_bank_admin_add_incoming.c b/src/testing/testing_api_cmd_bank_admin_add_incoming.c
index 2398c5be..6e707a2e 100644
--- a/src/testing/testing_api_cmd_bank_admin_add_incoming.c
+++ b/src/testing/testing_api_cmd_bank_admin_add_incoming.c
@@ -33,6 +33,12 @@
/**
+ * How often do we retry before giving up?
+ */
+#define NUM_RETRIES 5
+
+
+/**
* State for a "fakebank transfer" CMD.
*/
struct AdminAddIncomingState
@@ -120,9 +126,9 @@ struct AdminAddIncomingState
/**
* Was this command modified via
* #TALER_TESTING_cmd_admin_add_incoming_with_retry to
- * enable retries?
+ * enable retries? If so, how often should we still retry?
*/
- int do_retry;
+ unsigned int do_retry;
};
@@ -184,8 +190,9 @@ confirmation_cb (void *cls,
fts->aih = NULL;
if (MHD_HTTP_OK != http_status)
{
- if (GNUNET_YES == fts->do_retry)
+ if (0 != fts->do_retry)
{
+ fts->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -588,7 +595,7 @@ TALER_TESTING_cmd_admin_add_incoming_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&admin_add_incoming_run == cmd.run);
fts = cmd.cls;
- fts->do_retry = GNUNET_YES;
+ fts->do_retry = NUM_RETRIES;
return cmd;
}
diff --git a/src/testing/testing_api_cmd_bank_transfer.c b/src/testing/testing_api_cmd_bank_transfer.c
index f8dfc0b8..03bf5973 100644
--- a/src/testing/testing_api_cmd_bank_transfer.c
+++ b/src/testing/testing_api_cmd_bank_transfer.c
@@ -33,6 +33,12 @@
/**
+ * How often do we retry before giving up?
+ */
+#define NUM_RETRIES 5
+
+
+/**
* State for a "transfer" CMD.
*/
struct TransferState
@@ -113,9 +119,9 @@ struct TransferState
/**
* Was this command modified via
* #TALER_TESTING_cmd_admin_add_incoming_with_retry to
- * enable retries?
+ * enable retries? If so, how often should we still retry?
*/
- int do_retry;
+ unsigned int do_retry;
};
@@ -175,8 +181,9 @@ confirmation_cb (void *cls,
fts->weh = NULL;
if (MHD_HTTP_OK != http_status)
{
- if (GNUNET_YES == fts->do_retry)
+ if (0 != fts->do_retry)
{
+ fts->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -397,9 +404,9 @@ TALER_TESTING_cmd_transfer_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&transfer_run == cmd.run);
fts = cmd.cls;
- fts->do_retry = GNUNET_YES;
+ fts->do_retry = NUM_RETRIES;
return cmd;
}
-/* end of testing_api_cmd_transfer.c */
+/* end of testing_api_cmd_bank_transfer.c */
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c
index 573c68b9..6781568a 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -30,6 +30,12 @@
/**
+ * How often do we retry before giving up?
+ */
+#define NUM_RETRIES 5
+
+
+/**
* State for a "deposit" CMD.
*/
struct DepositState
@@ -104,9 +110,9 @@ struct DepositState
unsigned int expected_response_code;
/**
- * Should we retry on (transient) failures?
+ * How often should we retry on (transient) failures?
*/
- int do_retry;
+ unsigned int do_retry;
/**
* Set to #GNUNET_YES if the /deposit succeeded
@@ -184,8 +190,9 @@ deposit_cb (void *cls,
ds->dh = NULL;
if (ds->expected_response_code != http_status)
{
- if (GNUNET_YES == ds->do_retry)
+ if (0 != ds->do_retry)
{
+ ds->do_retry--;
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
@@ -559,7 +566,7 @@ TALER_TESTING_cmd_deposit_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&deposit_run == cmd.run);
ds = cmd.cls;
- ds->do_retry = GNUNET_YES;
+ ds->do_retry = NUM_RETRIES;
return cmd;
}
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c
index 96412156..b2fc272e 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -32,6 +32,17 @@
/**
+ * How often do we retry before giving up?
+ */
+#define NUM_RETRIES 15
+
+/**
+ * How long do we wait AT LEAST if the exchange says the reserve is unknown?
+ */
+#define UNKNOWN_MIN_BACKOFF GNUNET_TIME_relative_multiply ( \
+ GNUNET_TIME_UNIT_MILLISECONDS, 100)
+
+/**
* State for a "withdraw" CMD.
*/
struct WithdrawState
@@ -100,9 +111,9 @@ struct WithdrawState
/**
* Was this command modified via
* #TALER_TESTING_cmd_withdraw_with_retry to
- * enable retries?
+ * enable retries? How often should we still retry?
*/
- int do_retry;
+ unsigned int do_retry;
};
@@ -160,8 +171,10 @@ reserve_withdraw_cb (void *cls,
ws->wsh = NULL;
if (ws->expected_response_code != http_status)
{
- if (GNUNET_YES == ws->do_retry)
+ if (0 != ws->do_retry)
{
+ if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != ec)
+ ws->do_retry--; /* we don't count reserve unknown as failures here */
if ( (0 == http_status) ||
(TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec) ||
(TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS == ec) ||
@@ -175,8 +188,11 @@ reserve_withdraw_cb (void *cls,
/* on DB conflicts, do not use backoff */
if (TALER_EC_DB_COMMIT_FAILED_ON_RETRY == ec)
ws->backoff = GNUNET_TIME_UNIT_ZERO;
- else
+ else if (TALER_EC_WITHDRAW_RESERVE_UNKNOWN != ec)
ws->backoff = EXCHANGE_LIB_BACKOFF (ws->backoff);
+ else
+ ws->backoff = GNUNET_TIME_relative_max (UNKNOWN_MIN_BACKOFF,
+ ws->backoff);
ws->retry_task = GNUNET_SCHEDULER_add_delayed (ws->backoff,
&do_retry,
ws);
@@ -526,7 +542,7 @@ TALER_TESTING_cmd_withdraw_with_retry (struct TALER_TESTING_Command cmd)
GNUNET_assert (&withdraw_run == cmd.run);
ws = cmd.cls;
- ws->do_retry = GNUNET_YES;
+ ws->do_retry = NUM_RETRIES;
return cmd;
}