diff options
Diffstat (limited to 'src/backend/taler-merchant-wirewatch.c')
-rw-r--r-- | src/backend/taler-merchant-wirewatch.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c index c5fcff7d..a40a3e90 100644 --- a/src/backend/taler-merchant-wirewatch.c +++ b/src/backend/taler-merchant-wirewatch.c @@ -149,6 +149,17 @@ static unsigned int batch_size = 32; */ static int test_mode; +/** + * #GNUNET_YES if we are in persistent mode and do + * not exit on #config_changed. + */ +static int persist_mode; + +/** + * Set to true if we are shutting down due to a + * configuration change. + */ +static bool config_changed_flag; /** * Save progress in DB. @@ -487,7 +498,7 @@ start_watch ( payto_uri); GNUNET_free (w); GNUNET_SCHEDULER_shutdown (); - global_ret = 1; + global_ret = EXIT_NOTCONFIGURED; return; } @@ -518,6 +529,12 @@ config_changed (void *cls, (void) cls; (void) extra; (void) extra_size; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Configuration changed, %s\n", + 0 == persist_mode + ? "restarting" + : "reinitializing"); + config_changed_flag = true; GNUNET_SCHEDULER_shutdown (); } @@ -549,6 +566,7 @@ run (void *cls, { GNUNET_break (0); GNUNET_SCHEDULER_shutdown (); + global_ret = EXIT_NO_RESTART; return; } if (NULL == @@ -557,6 +575,7 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to initialize DB subsystem\n"); GNUNET_SCHEDULER_shutdown (); + global_ret = EXIT_NOTCONFIGURED; return; } if (GNUNET_OK != @@ -565,6 +584,7 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect to database\n"); GNUNET_SCHEDULER_shutdown (); + global_ret = EXIT_NO_RESTART; return; } { @@ -590,14 +610,16 @@ run (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to obtain wirewatch accounts from database\n"); GNUNET_SCHEDULER_shutdown (); + global_ret = EXIT_NO_RESTART; return; } - if ( (0 == qs) && + if ( (NULL == w_head) && (GNUNET_YES == test_mode) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "No active wirewatch accounts in database and in test mode. Exiting.\n"); GNUNET_SCHEDULER_shutdown (); + global_ret = EXIT_SUCCESS; return; } } @@ -616,6 +638,12 @@ main (int argc, char *const *argv) { struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_option_flag ('p', + "persist", + "run in persist mode and do not exit on configuration changes", + &persist_mode), + GNUNET_GETOPT_option_timetravel ('T', + "timetravel"), GNUNET_GETOPT_option_flag ('t', "test", "run in test mode and exit when idle", @@ -630,13 +658,17 @@ main (int argc, &argc, &argv)) return EXIT_INVALIDARGUMENT; TALER_OS_init (); - ret = GNUNET_PROGRAM_run ( - argc, argv, - "taler-merchant-wirewatch", - gettext_noop ( - "background process that watches for incoming wire transfers to the merchant bank account"), - options, - &run, NULL); + do { + config_changed_flag = false; + ret = GNUNET_PROGRAM_run ( + argc, argv, + "taler-merchant-wirewatch", + gettext_noop ( + "background process that watches for incoming wire transfers to the merchant bank account"), + options, + &run, NULL); + } while ( (1 == persist_mode) && + config_changed_flag); GNUNET_free_nz ((void *) argv); if (GNUNET_SYSERR == ret) return EXIT_INVALIDARGUMENT; |