-misc bugfixes

This commit is contained in:
Christian Grothoff 2021-09-06 01:26:46 +02:00
parent 87f5d8211e
commit 9086ed15c1
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 74 additions and 13 deletions

View File

@ -597,13 +597,8 @@ lookup_account (struct TALER_FAKEBANK_Handle *h,
0, 0,
sizeof (hc)); sizeof (hc));
slen = strlen (name); slen = strlen (name);
if (slen < sizeof (hc))
memcpy (&hc,
name,
slen); /* fake hashing for speed! */
else
GNUNET_CRYPTO_hash (name, GNUNET_CRYPTO_hash (name,
strlen (name), slen,
&hc); &hc);
GNUNET_assert (0 == GNUNET_assert (0 ==
pthread_mutex_lock (&h->accounts_lock)); pthread_mutex_lock (&h->accounts_lock));
@ -2582,6 +2577,8 @@ TALER_FAKEBANK_start2 (uint16_t port,
&handle_mhd_completion_callback, h, &handle_mhd_completion_callback, h,
MHD_OPTION_LISTEN_BACKLOG_SIZE, MHD_OPTION_LISTEN_BACKLOG_SIZE,
(unsigned int) 1024, (unsigned int) 1024,
MHD_OPTION_CONNECTION_LIMIT,
(unsigned int) 65536,
MHD_OPTION_END); MHD_OPTION_END);
if (NULL == h->mhd_bank) if (NULL == h->mhd_bank)
{ {
@ -2632,6 +2629,8 @@ TALER_FAKEBANK_start2 (uint16_t port,
&handle_mhd_completion_callback, h, &handle_mhd_completion_callback, h,
MHD_OPTION_LISTEN_BACKLOG_SIZE, MHD_OPTION_LISTEN_BACKLOG_SIZE,
(unsigned int) 1024, (unsigned int) 1024,
MHD_OPTION_CONNECTION_LIMIT,
(unsigned int) 65536,
MHD_OPTION_THREAD_POOL_SIZE, MHD_OPTION_THREAD_POOL_SIZE,
num_threads, num_threads,
MHD_OPTION_END); MHD_OPTION_END);

View File

@ -47,6 +47,11 @@ static int ret;
*/ */
static struct TALER_FAKEBANK_Handle *fb; static struct TALER_FAKEBANK_Handle *fb;
/**
* Keepalive task in multi-threaded mode.
*/
static struct GNUNET_SCHEDULER_Task *keepalive;
/** /**
* Stop the process. * Stop the process.
@ -59,6 +64,24 @@ do_shutdown (void *cls)
(void) cls; (void) cls;
TALER_FAKEBANK_stop (fb); TALER_FAKEBANK_stop (fb);
fb = NULL; 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); num_threads);
if (NULL == fb) if (NULL == fb)
{ {
GNUNET_break (0);
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
return; return;
} }
GNUNET_free (currency_string); GNUNET_free (currency_string);
keepalive = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&keepalive_task,
NULL);
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL); NULL);
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;

View File

@ -349,10 +349,13 @@ static void
batch_done (void) batch_done (void)
{ {
/* batch done */ /* batch done */
GNUNET_assert (NULL == wpd_head);
switch (commit_or_warn ()) switch (commit_or_warn ())
{ {
case GNUNET_DB_STATUS_SOFT_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR:
/* try again */ /* try again */
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Serialization failure, trying again immediately!\n");
GNUNET_assert (NULL == task); GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&run_transfers, task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL); NULL);
@ -452,6 +455,7 @@ wire_confirm_cb (void *cls,
(unsigned long long) wpd->row_id, (unsigned long long) wpd->row_id,
http_status_code, http_status_code,
ec); ec);
cleanup_wpd ();
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_FAILURE; global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
@ -463,6 +467,7 @@ wire_confirm_cb (void *cls,
http_status_code, http_status_code,
ec); ec);
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
cleanup_wpd ();
global_ret = EXIT_FAILURE; global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
@ -475,6 +480,8 @@ wire_confirm_cb (void *cls,
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
cleanup_wpd (); cleanup_wpd ();
GNUNET_assert (NULL == task); GNUNET_assert (NULL == task);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Serialization failure, trying again immediately!\n");
task = GNUNET_SCHEDULER_add_now (&run_transfers, task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL); NULL);
return; return;
@ -518,6 +525,9 @@ wire_prepare_cb (void *cls,
struct WirePrepareData *wpd; struct WirePrepareData *wpd;
(void) cls; (void) cls;
if ( (NULL != task) ||
(EXIT_SUCCESS != global_ret) )
return; /* current transaction was aborted */
if (rowid >= shard->shard_end) if (rowid >= shard->shard_end)
{ {
/* skip */ /* skip */
@ -555,6 +565,7 @@ wire_prepare_cb (void *cls,
/* Should really never happen here, as when we get /* Should really never happen here, as when we get
here the wire account should be in the cache. */ here the wire account should be in the cache. */
GNUNET_break (0); GNUNET_break (0);
cleanup_wpd ();
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_NOTCONFIGURED; global_ret = EXIT_NOTCONFIGURED;
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
@ -569,6 +580,7 @@ wire_prepare_cb (void *cls,
if (NULL == wpd->eh) if (NULL == wpd->eh)
{ {
GNUNET_break (0); /* Irrecoverable */ GNUNET_break (0); /* Irrecoverable */
cleanup_wpd ();
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_FAILURE; global_ret = EXIT_FAILURE;
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
@ -610,9 +622,10 @@ run_transfers (void *cls)
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
case GNUNET_DB_STATUS_SOFT_ERROR: 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"); "Got DB soft error for complete_shard. Rolling back.\n");
GNUNET_free (shard); GNUNET_free (shard);
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&select_shard, task = GNUNET_SCHEDULER_add_now (&select_shard,
NULL); NULL);
return; return;
@ -625,6 +638,7 @@ run_transfers (void *cls)
} }
shard_delay = GNUNET_TIME_absolute_get_duration (shard->shard_start_time); shard_delay = GNUNET_TIME_absolute_get_duration (shard->shard_start_time);
GNUNET_free (shard); GNUNET_free (shard);
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&select_shard, task = GNUNET_SCHEDULER_add_now (&select_shard,
NULL); NULL);
return; return;
@ -647,6 +661,7 @@ run_transfers (void *cls)
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
} }
GNUNET_assert (NULL == task);
qs = db_plugin->wire_prepare_data_get (db_plugin->cls, qs = db_plugin->wire_prepare_data_get (db_plugin->cls,
shard->batch_start, shard->batch_start,
limit, limit,
@ -655,6 +670,7 @@ run_transfers (void *cls)
switch (qs) switch (qs)
{ {
case GNUNET_DB_STATUS_HARD_ERROR: case GNUNET_DB_STATUS_HARD_ERROR:
cleanup_wpd ();
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
GNUNET_break (0); GNUNET_break (0);
global_ret = EXIT_FAILURE; global_ret = EXIT_FAILURE;
@ -663,6 +679,9 @@ run_transfers (void *cls)
case GNUNET_DB_STATUS_SOFT_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR:
/* try again */ /* try again */
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Serialization failure, trying again immediately!\n");
cleanup_wpd ();
GNUNET_assert (NULL == task); GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&run_transfers, task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL); NULL);
@ -670,6 +689,7 @@ run_transfers (void *cls)
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
/* no more prepared wire transfers, go sleep a bit! */ /* no more prepared wire transfers, go sleep a bit! */
db_plugin->rollback (db_plugin->cls); db_plugin->rollback (db_plugin->cls);
GNUNET_assert (NULL == wpd_head);
GNUNET_assert (NULL == task); GNUNET_assert (NULL == task);
if (GNUNET_YES == test_mode) if (GNUNET_YES == test_mode)
{ {
@ -679,8 +699,9 @@ run_transfers (void *cls)
} }
else else
{ {
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"No more pending wire transfers, going idle\n"); "No more pending wire transfers, going idle\n");
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval, task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval,
&run_transfers, &run_transfers,
NULL); NULL);
@ -708,6 +729,7 @@ select_shard (void *cls)
(void) cls; (void) cls;
task = NULL; task = NULL;
GNUNET_assert (NULL == wpd_head);
if (GNUNET_SYSERR == if (GNUNET_SYSERR ==
db_plugin->preflight (db_plugin->cls)) db_plugin->preflight (db_plugin->cls))
{ {
@ -742,12 +764,24 @@ select_shard (void *cls)
return; return;
case GNUNET_DB_STATUS_SOFT_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR:
/* try again */ /* try again */
task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval, {
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, &select_shard,
NULL); NULL);
}
return; return;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_break (0); GNUNET_break (0);
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval, task = GNUNET_SCHEDULER_add_delayed (transfer_idle_sleep_interval,
&select_shard, &select_shard,
NULL); NULL);
@ -765,6 +799,7 @@ select_shard (void *cls)
shard->shard_start = start; shard->shard_start = start;
shard->shard_end = end; shard->shard_end = end;
shard->batch_start = start; shard->batch_start = start;
GNUNET_assert (NULL == task);
task = GNUNET_SCHEDULER_add_now (&run_transfers, task = GNUNET_SCHEDULER_add_now (&run_transfers,
NULL); NULL);
} }