From a05859ad136ef0182c84507fb2b9c73f952b9e89 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 9 Aug 2018 19:47:23 +0200 Subject: [PATCH] use only one fakebank instance in multi-process benchmark --- src/benchmark/taler-exchange-benchmark.c | 95 +++++++++++++++++++++++- 1 file changed, 91 insertions(+), 4 deletions(-) diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index a5528fff5..c7155fd34 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -356,6 +356,7 @@ run (void *cls, CMD_TRANSFER_TO_EXCHANGE ("create-reserve", TALER_amount_to_string (&total_reserve_amount)), + /* FIXME: remove wirewatch here! */ TALER_TESTING_cmd_exec_wirewatch ("wirewatch", cfg_filename), @@ -435,14 +436,60 @@ run (void *cls, } all_commands[1 + howmany_coins] = TALER_TESTING_cmd_end (); start_time = GNUNET_TIME_absolute_get (); - TALER_TESTING_run_with_fakebank - (is, - all_commands, - exchange_bank_account.bank_base_url); + TALER_TESTING_run (is, + all_commands); result = 1; } +/** + * Stop the fakebank. + * + * @param cls fakebank handle + */ +static void +stop_fakebank (void *cls) +{ + struct TALER_FAKEBANK_Handle *fakebank = cls; + + TALER_FAKEBANK_stop (fakebank); +} + + +/** + * Start the fakebank. + * + * @param cls the URL of the fakebank + */ +static void +launch_fakebank (void *cls) +{ + const char *bank_base_url = cls; + const char *port; + long pnum; + struct TALER_FAKEBANK_Handle * fakebank; + + port = strrchr (bank_base_url, + (unsigned char) ':'); + if (NULL == port) + pnum = 80; + else + pnum = strtol (port + 1, NULL, 10); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Starting Fakebank on port %u (%s)\n", + (unsigned int) pnum, + bank_base_url); + fakebank = TALER_FAKEBANK_start ((uint16_t) pnum); + if (NULL == fakebank) + { + GNUNET_break (0); + return; + } + GNUNET_SCHEDULER_add_shutdown (&stop_fakebank, + fakebank); +} + + /** * Run the benchmark in parallel in many (client) processes * and summarize result. @@ -461,9 +508,11 @@ parallel_benchmark (TALER_TESTING_Main main_cb, { int result; pid_t cpids[howmany_clients]; + pid_t fakebank; int wstatus; struct GNUNET_OS_Process *exchanged; + /* start exchange */ exchanged = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, @@ -482,6 +531,24 @@ parallel_benchmark (TALER_TESTING_Main main_cb, GNUNET_OS_process_destroy (exchanged); return 77; } + /* start fakebank */ + fakebank = fork (); + if (0 == fakebank) + { + GNUNET_SCHEDULER_run (&launch_fakebank, + NULL); + exit (0); + } + if (-1 == fakebank) + { + GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, + "fork"); + result = GNUNET_SYSERR; + return 77; + } + + /* FIXME: start wirewatch */ + result = GNUNET_OK; for (unsigned int i=0;i