summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-09-06 01:26:46 +0200
committerChristian Grothoff <christian@grothoff.org>2021-09-06 01:26:46 +0200
commit9086ed15c11db106179d54d125cbd3850eda0dc7 (patch)
tree725d766573306e6bba15c3138b2142baef8beea1
parent87f5d8211e5c086bf33a0e974fc131a94625af00 (diff)
downloadexchange-9086ed15c11db106179d54d125cbd3850eda0dc7.tar.gz
exchange-9086ed15c11db106179d54d125cbd3850eda0dc7.tar.bz2
exchange-9086ed15c11db106179d54d125cbd3850eda0dc7.zip
-misc bugfixes
-rw-r--r--src/bank-lib/fakebank.c15
-rw-r--r--src/bank-lib/taler-fakebank-run.c27
-rw-r--r--src/exchange/taler-exchange-transfer.c45
3 files changed, 74 insertions, 13 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 6a6278ed..2a53419b 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -597,14 +597,9 @@ lookup_account (struct TALER_FAKEBANK_Handle *h,
0,
sizeof (hc));
slen = strlen (name);
- if (slen < sizeof (hc))
- memcpy (&hc,
- name,
- slen); /* fake hashing for speed! */
- else
- GNUNET_CRYPTO_hash (name,
- strlen (name),
- &hc);
+ GNUNET_CRYPTO_hash (name,
+ slen,
+ &hc);
GNUNET_assert (0 ==
pthread_mutex_lock (&h->accounts_lock));
account = GNUNET_CONTAINER_multihashmap_get (h->accounts,
@@ -2582,6 +2577,8 @@ TALER_FAKEBANK_start2 (uint16_t port,
&handle_mhd_completion_callback, h,
MHD_OPTION_LISTEN_BACKLOG_SIZE,
(unsigned int) 1024,
+ MHD_OPTION_CONNECTION_LIMIT,
+ (unsigned int) 65536,
MHD_OPTION_END);
if (NULL == h->mhd_bank)
{
@@ -2632,6 +2629,8 @@ TALER_FAKEBANK_start2 (uint16_t port,
&handle_mhd_completion_callback, h,
MHD_OPTION_LISTEN_BACKLOG_SIZE,
(unsigned int) 1024,
+ MHD_OPTION_CONNECTION_LIMIT,
+ (unsigned int) 65536,
MHD_OPTION_THREAD_POOL_SIZE,
num_threads,
MHD_OPTION_END);
diff --git a/src/bank-lib/taler-fakebank-run.c b/src/bank-lib/taler-fakebank-run.c
index 282e3950..7fa73046 100644
--- a/src/bank-lib/taler-fakebank-run.c
+++ b/src/bank-lib/taler-fakebank-run.c
@@ -47,6 +47,11 @@ static int ret;
*/
static struct TALER_FAKEBANK_Handle *fb;
+/**
+ * Keepalive task in multi-threaded mode.
+ */
+static struct GNUNET_SCHEDULER_Task *keepalive;
+
/**
* Stop the process.
@@ -59,6 +64,24 @@ do_shutdown (void *cls)
(void) cls;
TALER_FAKEBANK_stop (fb);
fb = NULL;
+ if (NULL != keepalive)
+ {
+ GNUNET_SCHEDULER_cancel (keepalive);
+ keepalive = NULL;
+ }
+}
+
+
+/**
+ * Task that should never be run.
+ *
+ * @param cls NULL
+ */
+static void
+keepalive_task (void *cls)
+{
+ (void) cls;
+ GNUNET_assert (0);
}
@@ -125,10 +148,14 @@ run (void *cls,
num_threads);
if (NULL == fb)
{
+ GNUNET_break (0);
ret = EXIT_FAILURE;
return;
}
GNUNET_free (currency_string);
+ keepalive = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &keepalive_task,
+ NULL);
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
ret = EXIT_SUCCESS;
diff --git a/src/exchange/taler-exchange-transfer.c b/src/exchange/taler-exchange-transfer.c
index f3bd16da..51987fbf 100644
--- a/src/exchange/taler-exchange-transfer.c
+++ b/src/exchange/taler-exchange-transfer.c
@@ -349,10 +349,13 @@ static void
batch_done (void)
{
/* batch done */
+ GNUNET_assert (NULL == wpd_head);
switch (commit_or_warn ())
{
case GNUNET_DB_STATUS_SOFT_ERROR:
/* try again */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Serialization failure, trying again immediately!\n");
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL);
@@ -452,6 +455,7 @@ wire_confirm_cb (void *cls,
(unsigned long long) wpd->row_id,
http_status_code,
ec);
+ cleanup_wpd ();
db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
@@ -463,6 +467,7 @@ wire_confirm_cb (void *cls,
http_status_code,
ec);
db_plugin->rollback (db_plugin->cls);
+ cleanup_wpd ();
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
return;
@@ -475,6 +480,8 @@ wire_confirm_cb (void *cls,
db_plugin->rollback (db_plugin->cls);
cleanup_wpd ();
GNUNET_assert (NULL == task);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Serialization failure, trying again immediately!\n");
task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL);
return;
@@ -518,6 +525,9 @@ wire_prepare_cb (void *cls,
struct WirePrepareData *wpd;
(void) cls;
+ if ( (NULL != task) ||
+ (EXIT_SUCCESS != global_ret) )
+ return; /* current transaction was aborted */
if (rowid >= shard->shard_end)
{
/* skip */
@@ -555,6 +565,7 @@ wire_prepare_cb (void *cls,
/* Should really never happen here, as when we get
here the wire account should be in the cache. */
GNUNET_break (0);
+ cleanup_wpd ();
db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_NOTCONFIGURED;
GNUNET_SCHEDULER_shutdown ();
@@ -569,6 +580,7 @@ wire_prepare_cb (void *cls,
if (NULL == wpd->eh)
{
GNUNET_break (0); /* Irrecoverable */
+ cleanup_wpd ();
db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown ();
@@ -610,9 +622,10 @@ run_transfers (void *cls)
GNUNET_SCHEDULER_shutdown ();
return;
case GNUNET_DB_STATUS_SOFT_ERROR:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Got DB soft error for complete_shard. Rolling back.\n");
GNUNET_free (shard);
+ GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&select_shard,
NULL);
return;
@@ -625,6 +638,7 @@ run_transfers (void *cls)
}
shard_delay = GNUNET_TIME_absolute_get_duration (shard->shard_start_time);
GNUNET_free (shard);
+ GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&select_shard,
NULL);
return;
@@ -647,6 +661,7 @@ run_transfers (void *cls)
GNUNET_SCHEDULER_shutdown ();
return;
}
+ GNUNET_assert (NULL == task);
qs = db_plugin->wire_prepare_data_get (db_plugin->cls,
shard->batch_start,
limit,
@@ -655,6 +670,7 @@ run_transfers (void *cls)
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
+ cleanup_wpd ();
db_plugin->rollback (db_plugin->cls);
GNUNET_break (0);
global_ret = EXIT_FAILURE;
@@ -663,6 +679,9 @@ run_transfers (void *cls)
case GNUNET_DB_STATUS_SOFT_ERROR:
/* try again */
db_plugin->rollback (db_plugin->cls);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Serialization failure, trying again immediately!\n");
+ cleanup_wpd ();
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL);
@@ -670,6 +689,7 @@ run_transfers (void *cls)
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
/* no more prepared wire transfers, go sleep a bit! */
db_plugin->rollback (db_plugin->cls);
+ GNUNET_assert (NULL == wpd_head);
GNUNET_assert (NULL == task);
if (GNUNET_YES == test_mode)
{
@@ -679,8 +699,9 @@ run_transfers (void *cls)
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"No more pending wire transfers, going idle\n");
+ GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval,
&run_transfers,
NULL);
@@ -708,6 +729,7 @@ select_shard (void *cls)
(void) cls;
task = NULL;
+ GNUNET_assert (NULL == wpd_head);
if (GNUNET_SYSERR ==
db_plugin->preflight (db_plugin->cls))
{
@@ -742,12 +764,24 @@ select_shard (void *cls)
return;
case GNUNET_DB_STATUS_SOFT_ERROR:
/* try again */
- task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval,
- &select_shard,
- NULL);
+ {
+ static struct GNUNET_TIME_Relative delay;
+
+ delay = GNUNET_TIME_randomized_backoff (delay,
+ GNUNET_TIME_UNIT_SECONDS);
+ GNUNET_assert (NULL == task);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Serialization failure, trying again in %s!\n",
+ GNUNET_STRINGS_relative_time_to_string (delay,
+ GNUNET_YES));
+ task = GNUNET_SCHEDULER_add_delayed (delay,
+ &select_shard,
+ NULL);
+ }
return;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_break (0);
+ GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval,
&select_shard,
NULL);
@@ -765,6 +799,7 @@ select_shard (void *cls)
shard->shard_start = start;
shard->shard_end = end;
shard->batch_start = start;
+ GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL);
}