diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-23 00:00:32 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-23 00:00:32 +0200 |
commit | c559b1c935a93c4cdec442beeac59264d483c824 (patch) | |
tree | 625cf48e047e6534606b5b6b9cd0c15f4c3672dc /src/auditor | |
parent | 37f049b3bc98c72f68687e67f102ee5b06f9263d (diff) |
complete implementation of long-polling for reserve status; remove support for multi-threaded exchange httpd
Diffstat (limited to 'src/auditor')
-rw-r--r-- | src/auditor/report-lib.c | 31 | ||||
-rw-r--r-- | src/auditor/report-lib.h | 5 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd.c | 503 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation.c | 1 | ||||
-rw-r--r-- | src/auditor/taler-auditor-sync.c | 51 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-aggregation.c | 5 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-coins.c | 13 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-deposits.c | 1 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 7 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-wire.c | 23 |
10 files changed, 158 insertions, 482 deletions
diff --git a/src/auditor/report-lib.c b/src/auditor/report-lib.c index 5f45d7198..0ae1cc1f6 100644 --- a/src/auditor/report-lib.c +++ b/src/auditor/report-lib.c @@ -42,11 +42,6 @@ struct TALER_Amount TALER_ARL_currency_round_unit; const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; /** - * Our session with the #TALER_ARL_edb. - */ -struct TALER_EXCHANGEDB_Session *TALER_ARL_esession; - -/** * Handle to access the auditor's database. */ struct TALER_AUDITORDB_Plugin *TALER_ARL_adb; @@ -213,7 +208,6 @@ TALER_ARL_get_denomination_info_by_hash ( denominations = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_NO); qs = TALER_ARL_edb->iterate_denomination_info (TALER_ARL_edb->cls, - TALER_ARL_esession, &add_denomination, NULL); if (0 > qs) @@ -239,7 +233,6 @@ TALER_ARL_get_denomination_info_by_hash ( struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; qs = TALER_ARL_edb->get_denomination_info (TALER_ARL_edb->cls, - TALER_ARL_esession, dh, &issue); if (qs <= 0) @@ -324,23 +317,24 @@ transact (TALER_ARL_Analysis analysis, GNUNET_break (0); return GNUNET_SYSERR; } - TALER_ARL_edb->preflight (TALER_ARL_edb->cls, - TALER_ARL_esession); + if (GNUNET_OK != + TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } ret = TALER_ARL_edb->start (TALER_ARL_edb->cls, - TALER_ARL_esession, "auditor"); if (GNUNET_OK != ret) { GNUNET_break (0); - TALER_ARL_edb->rollback (TALER_ARL_edb->cls, - TALER_ARL_esession); + TALER_ARL_edb->rollback (TALER_ARL_edb->cls); return GNUNET_SYSERR; } qs = analysis (analysis_cls); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { - qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls, - TALER_ARL_esession); + qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls); if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -367,8 +361,7 @@ transact (TALER_ARL_Analysis analysis, "Processing failed (or no changes), rolling back transaction\n"); TALER_ARL_adb->rollback (TALER_ARL_adb->cls, TALER_ARL_asession); - TALER_ARL_edb->rollback (TALER_ARL_edb->cls, - TALER_ARL_esession); + TALER_ARL_edb->rollback (TALER_ARL_edb->cls); } switch (qs) { @@ -396,11 +389,11 @@ int TALER_ARL_setup_sessions_and_run (TALER_ARL_Analysis ana, void *ana_cls) { - TALER_ARL_esession = TALER_ARL_edb->get_session (TALER_ARL_edb->cls); - if (NULL == TALER_ARL_esession) + if (GNUNET_OK != + TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize exchange session.\n"); + "Failed to initialize exchange connection.\n"); return GNUNET_SYSERR; } TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); diff --git a/src/auditor/report-lib.h b/src/auditor/report-lib.h index 5df990cf5..d8d825914 100644 --- a/src/auditor/report-lib.h +++ b/src/auditor/report-lib.h @@ -55,11 +55,6 @@ extern struct TALER_Amount TALER_ARL_currency_round_unit; extern const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; /** - * Our session with the #TALER_ARL_edb. - */ -extern struct TALER_EXCHANGEDB_Session *TALER_ARL_esession; - -/** * Handle to access the auditor's database. */ extern struct TALER_AUDITORDB_Plugin *TALER_ARL_adb; diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index 57165ef03..47d618669 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -61,9 +61,9 @@ static int auditor_connection_close; /** - * The auditor's configuration (global) + * The auditor's configuration. */ -static struct GNUNET_CONFIGURATION_Handle *cfg; +static const struct GNUNET_CONFIGURATION_Handle *cfg; /** * Our DB plugin. @@ -86,9 +86,9 @@ static struct TALER_AuditorPublicKeyP auditor_pub; static unsigned int connection_timeout = 30; /** - * The HTTP Daemon. + * Return value from main() */ -static struct MHD_Daemon *mhd; +static int global_ret; /** * Port to run the daemon on. @@ -96,177 +96,10 @@ static struct MHD_Daemon *mhd; static uint16_t serve_port; /** - * Path for the unix domain-socket to run the daemon on. - */ -static char *serve_unixpath; - -/** - * File mode for unix-domain socket. - */ -static mode_t unixpath_mode; - -/** * Our currency. */ char *TAH_currency; -/** - * Pipe used for signaling reloading of our key state. - */ -static int reload_pipe[2] = { -1, -1 }; - - -/** - * Handle a signal, writing relevant signal numbers to the pipe. - * - * @param signal_number the signal number - */ -static void -handle_signal (int signal_number) -{ - char c = signal_number; - - (void) ! write (reload_pipe[1], - &c, - 1); - /* While one might like to "handle errors" here, even logging via fprintf() - isn't safe inside of a signal handler. So there is nothing we safely CAN - do. OTOH, also very little that can go wrong in practice. Calling _exit() - on errors might be a possibility, but that might do more harm than good. */// -} - - -/** - * Call #handle_signal() to pass the received signal via - * the control pipe. - */ -static void -handle_sigint (void) -{ - handle_signal (SIGINT); -} - - -/** - * Call #handle_signal() to pass the received signal via - * the control pipe. - */ -static void -handle_sigterm (void) -{ - handle_signal (SIGTERM); -} - - -/** - * Call #handle_signal() to pass the received signal via - * the control pipe. - */ -static void -handle_sighup (void) -{ - handle_signal (SIGHUP); -} - - -/** - * Call #handle_signal() to pass the received signal via - * the control pipe. - */ -static void -handle_sigchld (void) -{ - handle_signal (SIGCHLD); -} - - -/** - * Read signals from a pipe in a loop, and reload keys from disk if - * SIGUSR1 is received, terminate if SIGTERM/SIGINT is received, and - * restart if SIGHUP is received. - * - * @return #GNUNET_SYSERR on errors, - * #GNUNET_OK to terminate normally - * #GNUNET_NO to restart an update version of the binary - */ -static int -signal_loop (void) -{ - struct GNUNET_SIGNAL_Context *sigterm; - struct GNUNET_SIGNAL_Context *sigint; - struct GNUNET_SIGNAL_Context *sighup; - struct GNUNET_SIGNAL_Context *sigchld; - int ret; - - if (0 != pipe (reload_pipe)) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "pipe"); - return GNUNET_SYSERR; - } - sigterm = GNUNET_SIGNAL_handler_install (SIGTERM, - &handle_sigterm); - sigint = GNUNET_SIGNAL_handler_install (SIGINT, - &handle_sigint); - sighup = GNUNET_SIGNAL_handler_install (SIGHUP, - &handle_sighup); - sigchld = GNUNET_SIGNAL_handler_install (SIGCHLD, - &handle_sigchld); - - ret = 2; - while (2 == ret) - { - char c; - ssize_t res; - - errno = 0; - res = read (reload_pipe[0], - &c, - 1); - if ( (res < 0) && - (EINTR != errno)) - { - GNUNET_break (0); - ret = GNUNET_SYSERR; - break; - } - if (EINTR == errno) - { - /* ignore, do the loop again */ - continue; - } - switch (c) - { - case SIGTERM: - case SIGINT: - /* terminate */ - ret = GNUNET_OK; - break; - case SIGHUP: - /* restart updated binary */ - ret = GNUNET_NO; - break; -#if HAVE_DEVELOPER - case SIGCHLD: - /* running in test-mode, test finished, terminate */ - ret = GNUNET_OK; - break; -#endif - default: - /* unexpected character */ - GNUNET_break (0); - break; - } - } - GNUNET_SIGNAL_handler_uninstall (sigterm); - GNUNET_SIGNAL_handler_uninstall (sigint); - GNUNET_SIGNAL_handler_uninstall (sighup); - GNUNET_SIGNAL_handler_uninstall (sigchld); - GNUNET_break (0 == close (reload_pipe[0])); - GNUNET_break (0 == close (reload_pipe[1])); - return ret; -} - /** * Function called whenever MHD is done with a request. If the @@ -435,7 +268,7 @@ handle_mhd_request (void *cls, * * @return #GNUNET_OK on success */ -static int +static enum GNUNET_GenericReturnValue auditor_serve_process_config (void) { if (NULL == @@ -452,13 +285,11 @@ auditor_serve_process_config (void) "Failed to initialize DB subsystem to query exchange database\n"); return GNUNET_SYSERR; } - if (GNUNET_OK != - TALER_MHD_parse_config (cfg, - "auditor", - &serve_port, - &serve_unixpath, - &unixpath_mode)) + if (GNUNET_SYSERR == + TAH_eplugin->preflight (TAH_eplugin->cls)) { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to initialize DB subsystem to query exchange database\n"); return GNUNET_SYSERR; } if (GNUNET_OK != @@ -534,6 +365,113 @@ auditor_serve_process_config (void) /** + * Function run on shutdown. + * + * @param cls NULL + */ +static void +do_shutdown (void *cls) +{ + struct MHD_Daemon *mhd; + (void) cls; + + mhd = TALER_MHD_daemon_stop (); + TEAH_DEPOSIT_CONFIRMATION_done (); + if (NULL != mhd) + MHD_stop_daemon (mhd); + if (NULL != TAH_plugin) + { + TALER_AUDITORDB_plugin_unload (TAH_plugin); + TAH_plugin = NULL; + } + if (NULL != TAH_eplugin) + { + TALER_EXCHANGEDB_plugin_unload (TAH_eplugin); + TAH_eplugin = NULL; + } +} + + +/** + * Main function that will be run by the scheduler. + * + * @param cls closure + * @param args remaining command-line arguments + * @param cfgfile name of the configuration file used (for saving, can be + * NULL!) + * @param config configuration + */ +static void +run (void *cls, + char *const *args, + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *config) +{ + enum TALER_MHD_GlobalOptions go; + int fh; + + go = TALER_MHD_GO_NONE; + if (auditor_connection_close) + go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE; + TALER_MHD_setup (go); + cfg = config; + + GNUNET_SCHEDULER_add_shutdown (&do_shutdown, + NULL); + if (GNUNET_OK != + auditor_serve_process_config ()) + { + global_ret = EXIT_NOTCONFIGURED; + GNUNET_SCHEDULER_shutdown (); + return; + } + TEAH_DEPOSIT_CONFIRMATION_init (); + fh = TALER_MHD_bind (cfg, + "auditor", + &serve_port); + if ( (0 == serve_port) && + (-1 == fh) ) + { + GNUNET_SCHEDULER_shutdown (); + return; + } + { + struct MHD_Daemon *mhd; + + mhd = MHD_start_daemon (MHD_USE_SUSPEND_RESUME + | MHD_USE_PIPE_FOR_SHUTDOWN + | MHD_USE_DEBUG | MHD_USE_DUAL_STACK + | MHD_USE_TCP_FASTOPEN, + (-1 == fh) ? serve_port : 0, + NULL, NULL, + &handle_mhd_request, NULL, + MHD_OPTION_LISTEN_BACKLOG_SIZE, + (unsigned int) 1024, + MHD_OPTION_LISTEN_SOCKET, + fh, + MHD_OPTION_EXTERNAL_LOGGER, + &TALER_MHD_handle_logs, + NULL, + MHD_OPTION_NOTIFY_COMPLETED, + &handle_mhd_completion_callback, + NULL, + MHD_OPTION_CONNECTION_TIMEOUT, + connection_timeout, + MHD_OPTION_END); + if (NULL == mhd) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to launch HTTP service. Is the port in use?\n"); + GNUNET_SCHEDULER_shutdown (); + return; + } + global_ret = EXIT_SUCCESS; + TALER_MHD_daemon_start (mhd); + } +} + + +/** * The main function of the taler-auditor-httpd server ("the auditor"). * * @param argc number of arguments from the command line @@ -544,15 +482,11 @@ int main (int argc, char *const *argv) { - char *cfgfile = NULL; - char *loglev = NULL; - char *logfile = NULL; const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('C', "connection-close", "force HTTP connections to be closed after each request", &auditor_connection_close), - GNUNET_GETOPT_option_cfgfile (&cfgfile), GNUNET_GETOPT_option_uint ('t', "timeout", "SECONDS", @@ -560,207 +494,22 @@ main (int argc, &connection_timeout), GNUNET_GETOPT_option_help ( "HTTP server providing a RESTful API to access a Taler auditor"), - GNUNET_GETOPT_option_loglevel (&loglev), - GNUNET_GETOPT_option_logfile (&logfile), GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_END }; int ret; - const char *listen_pid; - const char *listen_fds; - int fh = -1; - enum TALER_MHD_GlobalOptions go; TALER_OS_init (); - { - int ret; - - ret = GNUNET_GETOPT_run ("taler-auditor-httpd", - options, - argc, argv); - if (GNUNET_NO == ret) - return EXIT_SUCCESS; - if (GNUNET_SYSERR == ret) - return EXIT_FAILURE; - } - go = TALER_MHD_GO_NONE; - if (auditor_connection_close) - go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE; - TALER_MHD_setup (go); - GNUNET_assert (GNUNET_OK == - GNUNET_log_setup ("taler-auditor-httpd", - (NULL == loglev) ? "INFO" : loglev, - logfile)); - if (NULL == cfgfile) - cfgfile = GNUNET_CONFIGURATION_default_filename (); - if (NULL == cfgfile) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Can't find default configuration file.\n"); - return EXIT_NOTCONFIGURED; - } - cfg = GNUNET_CONFIGURATION_create (); - if (GNUNET_SYSERR == - GNUNET_CONFIGURATION_load (cfg, - cfgfile)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Malformed configuration file `%s', exiting ...\n", - cfgfile); - GNUNET_free (cfgfile); - return EXIT_NOTCONFIGURED; - } - GNUNET_free (cfgfile); - - if (GNUNET_OK != - auditor_serve_process_config ()) - return EXIT_NOTCONFIGURED; - TEAH_DEPOSIT_CONFIRMATION_init (); - /* check for systemd-style FD passing */ - listen_pid = getenv ("LISTEN_PID"); - listen_fds = getenv ("LISTEN_FDS"); - if ( (NULL != listen_pid) && - (NULL != listen_fds) && - (getpid () == strtol (listen_pid, - NULL, - 10)) && - (1 == strtoul (listen_fds, - NULL, - 10)) ) - { - int flags; - - fh = 3; - flags = fcntl (fh, - F_GETFD); - if ( (-1 == flags) && - (EBADF == errno) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Bad listen socket passed, ignored\n"); - fh = -1; - } - flags |= FD_CLOEXEC; - if ( (-1 != fh) && - (0 != fcntl (fh, - F_SETFD, - flags)) ) - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "fcntl"); - } - - /* consider unix path */ - if ( (-1 == fh) && - (NULL != serve_unixpath) ) - { - fh = TALER_MHD_open_unix_path (serve_unixpath, - unixpath_mode); - if (-1 == fh) - { - TEAH_DEPOSIT_CONFIRMATION_done (); - return EXIT_NOPERMISSION; /* most likely at least */ - } - } - - mhd = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN - | MHD_USE_DEBUG | MHD_USE_DUAL_STACK - | MHD_USE_INTERNAL_POLLING_THREAD - | MHD_USE_TCP_FASTOPEN, - (-1 == fh) ? serve_port : 0, - NULL, NULL, - &handle_mhd_request, NULL, - MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) 32, - MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, - MHD_OPTION_LISTEN_SOCKET, fh, - MHD_OPTION_EXTERNAL_LOGGER, &TALER_MHD_handle_logs, - NULL, - MHD_OPTION_NOTIFY_COMPLETED, - &handle_mhd_completion_callback, NULL, - MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, - MHD_OPTION_END); - if (NULL == mhd) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to start HTTP server.\n"); - TEAH_DEPOSIT_CONFIRMATION_done (); - return EXIT_FAILURE; - } - - /* normal behavior */ - ret = signal_loop (); - switch (ret) - { - case GNUNET_OK: - case GNUNET_SYSERR: - MHD_stop_daemon (mhd); - break; - case GNUNET_NO: - { - MHD_socket sock = MHD_quiesce_daemon (mhd); - pid_t chld; - int flags; - - /* Set flags to make 'sock' inherited by child */ - flags = fcntl (sock, F_GETFD); - GNUNET_assert (-1 != flags); - flags &= ~FD_CLOEXEC; - GNUNET_assert (-1 != fcntl (sock, F_SETFD, flags)); - chld = fork (); - if (-1 == chld) - { - /* fork() failed, continue clean up, unhappily */ - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "fork"); - } - if (0 == chld) - { - char pids[12]; - - /* exec another taler-auditor-httpd, passing on the listen socket; - as in systemd it is expected to be on FD #3 */ - if (3 != dup2 (sock, 3)) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "dup2"); - _exit (1); - } - /* Tell the child that it is the desired recipient for FD #3 */ - GNUNET_snprintf (pids, - sizeof (pids), - "%u", - getpid ()); - setenv ("LISTEN_PID", pids, 1); - setenv ("LISTEN_FDS", "1", 1); - /* Finally, exec the (presumably) more recent auditor binary */ - execvp ("taler-auditor-httpd", - argv); - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "execvp"); - _exit (1); - } - /* we're the original process, handle remaining contextions - before exiting; as the listen socket is no longer used, - close it here */ - GNUNET_break (0 == close (sock)); - while (0 != MHD_get_daemon_info (mhd, - MHD_DAEMON_INFO_CURRENT_CONNECTIONS)-> - num_connections) - sleep (1); - /* Now we're really done, practice clean shutdown */ - MHD_stop_daemon (mhd); - } - break; - default: - GNUNET_break (0); - MHD_stop_daemon (mhd); - break; - } - TALER_AUDITORDB_plugin_unload (TAH_plugin); - TAH_plugin = NULL; - TALER_EXCHANGEDB_plugin_unload (TAH_eplugin); - TAH_eplugin = NULL; - TEAH_DEPOSIT_CONFIRMATION_done (); - return (GNUNET_SYSERR == ret) ? EXIT_FAILURE : EXIT_SUCCESS; + ret = GNUNET_PROGRAM_run (argc, argv, + "taler-auditor-httpd", + "Taler auditor HTTP service", + options, + &run, NULL); + if (GNUNET_SYSERR == ret) + return EXIT_INVALIDARGUMENT; + if (GNUNET_NO == ret) + return EXIT_SUCCESS; + return global_ret; } diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c index 9632f0cc5..f38e8ee71 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c @@ -147,7 +147,6 @@ verify_and_execute_deposit_confirmation ( /* check for revocation */ qs = TAH_eplugin->lookup_signkey_revocation (TAH_eplugin->cls, - NULL, &es->exchange_pub, &master_sig); if (0 > qs) diff --git a/src/auditor/taler-auditor-sync.c b/src/auditor/taler-auditor-sync.c index 79135230f..0dfaa19a1 100644 --- a/src/auditor/taler-auditor-sync.c +++ b/src/auditor/taler-auditor-sync.c @@ -120,11 +120,6 @@ static struct Table tables[] = { struct InsertContext { /** - * Database session to use. - */ - struct TALER_EXCHANGEDB_Session *ds; - - /** * Table we are replicating. */ struct Table *table; @@ -154,7 +149,6 @@ do_insert (void *cls, if (0 >= ctx->qs) return GNUNET_SYSERR; qs = dst->insert_records_by_table (dst->cls, - ctx->ds, td); if (0 >= qs) { @@ -193,42 +187,34 @@ do_insert (void *cls, * * @return #GNUNET_OK on success, #GNUNET_SYSERR to rollback */ -static int -transact (struct TALER_EXCHANGEDB_Session *ss, - struct TALER_EXCHANGEDB_Session *ds) +static enum GNUNET_GenericReturnValue +transact (void) { struct InsertContext ctx = { - .ds = ds, .qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT }; if (0 > src->start (src->cls, - ss, "lookup src serials")) return GNUNET_SYSERR; for (unsigned int i = 0; ! tables[i].end; i++) src->lookup_serial_by_table (src->cls, - ss, tables[i].rt, &tables[i].end_serial); if (0 > - src->commit (src->cls, - ss)) + src->commit (src->cls)) return GNUNET_SYSERR; if (GNUNET_OK != dst->start (src->cls, - ds, "lookup dst serials")) return GNUNET_SYSERR; for (unsigned int i = 0; ! tables[i].end; i++) dst->lookup_serial_by_table (dst->cls, - ds, tables[i].rt, &tables[i].start_serial); if (0 > - dst->commit (dst->cls, - ds)) + dst->commit (dst->cls)) return GNUNET_SYSERR; for (unsigned int i = 0; ! tables[i].end; i++) { @@ -248,16 +234,13 @@ transact (struct TALER_EXCHANGEDB_Session *ss, if (GNUNET_OK != src->start (src->cls, - ss, "copy table (src)")) return GNUNET_SYSERR; if (GNUNET_OK != dst->start (dst->cls, - ds, "copy table (dst)")) return GNUNET_SYSERR; qs = src->lookup_records_by_table (src->cls, - ss, table->rt, table->start_serial, &do_insert, @@ -290,10 +273,8 @@ transact (struct TALER_EXCHANGEDB_Session *ss, } if (0 == ctx.qs) return GNUNET_SYSERR; /* insertion failed, maybe record existed? try again */ - src->rollback (src->cls, - ss); - qs = dst->commit (dst->cls, - ds); + src->rollback (src->cls); + qs = dst->commit (dst->cls); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -328,35 +309,29 @@ static void do_sync (void *cls) { static struct GNUNET_TIME_Relative delay; - struct TALER_EXCHANGEDB_Session *ss; - struct TALER_EXCHANGEDB_Session *ds; sync_task = NULL; actual_size = 0; - ss = src->get_session (src->cls); - if (NULL == ss) + if (GNUNET_SYSERR == + src->preflight (src->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to begin transaction with data source. Exiting\n"); return; } - ds = dst->get_session (dst->cls); - if (NULL == ds) + if (GNUNET_SYSERR == + dst->preflight (dst->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to begin transaction with data destination. Exiting\n"); return; } - if (GNUNET_OK != - transact (ss, - ds)) + if (GNUNET_OK != transact ()) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Transaction failed, rolling back\n"); - src->rollback (src->cls, - ss); - dst->rollback (dst->cls, - ds); + src->rollback (src->cls); + dst->rollback (dst->cls); } if (0 != global_ret) { diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index c6398be2f..3bc8c7701 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -756,7 +756,6 @@ wire_transfer_information_cb ( /* Obtain coin's transaction history */ qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls, - TALER_ARL_esession, coin_pub, GNUNET_YES, &tl); @@ -770,7 +769,6 @@ wire_transfer_information_cb ( return; } qs = TALER_ARL_edb->get_known_coin (TALER_ARL_edb->cls, - TALER_ARL_esession, coin_pub, &coin); if (qs <= 0) @@ -946,7 +944,6 @@ get_wire_fee (struct AggregationContext *ac, wfi = GNUNET_new (struct WireFeeInfo); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, - TALER_ARL_esession, method, timestamp, &wfi->start_date, @@ -1083,7 +1080,6 @@ check_wire_out_cb (void *cls, return GNUNET_SYSERR; } qs = TALER_ARL_edb->lookup_wire_transfer (TALER_ARL_edb->cls, - TALER_ARL_esession, wtid, &wire_transfer_information_cb, &wcc); @@ -1258,7 +1254,6 @@ analyze_aggregations (void *cls) ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; qs = TALER_ARL_edb->select_wire_out_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppa.last_wire_out_serial_id, &check_wire_out_cb, &ac); diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index b3050542d..a2c8b8cee 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -476,7 +476,6 @@ check_coin_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, int have_refund; qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls, - TALER_ARL_esession, coin_pub, GNUNET_YES, &tl); @@ -717,7 +716,6 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, TALER_amount2s (&ds->denom_balance), (unsigned long long) ds->num_issued); qs = TALER_ARL_edb->get_denomination_revocation (TALER_ARL_edb->cls, - TALER_ARL_esession, denom_hash, &msig, &rowid); @@ -878,7 +876,6 @@ sync_denomination (void *cls, TALER_amount2s (&ds->denom_balance), (unsigned long long) ds->num_issued); cnt = TALER_ARL_edb->count_known_coins (TALER_ARL_edb->cls, - TALER_ARL_esession, denom_hash); if (0 > cnt) { @@ -1187,7 +1184,6 @@ check_known_coin (const char *operation, "Checking denomination signature on %s\n", TALER_B2S (coin_pub)); qs = TALER_ARL_edb->get_known_coin (TALER_ARL_edb->cls, - TALER_ARL_esession, coin_pub, &ci); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) @@ -1336,7 +1332,6 @@ refresh_session_cb (void *cls, }; qs = TALER_ARL_edb->get_refresh_reveal (TALER_ARL_edb->cls, - TALER_ARL_esession, rc, &reveal_data_cb, &reveal_ctx); @@ -2250,7 +2245,6 @@ check_denomination ( struct TALER_AuditorSignatureP auditor_sig; qs = TALER_ARL_edb->select_auditor_denom_sig (TALER_ARL_edb->cls, - TALER_ARL_esession, &issue->denom_hash, &TALER_ARL_auditor_pub, &auditor_sig); @@ -2329,7 +2323,6 @@ analyze_coins (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking denominations...\n"); qs = TALER_ARL_edb->iterate_denomination_info (TALER_ARL_edb->cls, - TALER_ARL_esession, &check_denomination, NULL); if (0 > qs) @@ -2389,7 +2382,6 @@ analyze_coins (void *cls) if (0 > (qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppc.last_withdraw_serial_id, &withdraw_cb, &cc)) ) @@ -2404,7 +2396,6 @@ analyze_coins (void *cls) if (0 > (qs = TALER_ARL_edb->select_refunds_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppc.last_refund_serial_id, &refund_cb, &cc))) @@ -2419,7 +2410,6 @@ analyze_coins (void *cls) if (0 > (qs = TALER_ARL_edb->select_recoup_refresh_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppc.last_recoup_refresh_serial_id, &recoup_refresh_cb, &cc))) @@ -2432,7 +2422,6 @@ analyze_coins (void *cls) if (0 > (qs = TALER_ARL_edb->select_recoup_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppc.last_recoup_serial_id, &recoup_cb, &cc))) @@ -2447,7 +2436,6 @@ analyze_coins (void *cls) if (0 > (qs = TALER_ARL_edb->select_refreshes_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppc.last_melt_serial_id, &refresh_session_cb, &cc))) @@ -2462,7 +2450,6 @@ analyze_coins (void *cls) if (0 > (qs = TALER_ARL_edb->select_deposits_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppc.last_deposit_serial_id, &deposit_cb, &cc))) diff --git a/src/auditor/taler-helper-auditor-deposits.c b/src/auditor/taler-helper-auditor-deposits.c index c9c8bf662..58b41fbc3 100644 --- a/src/auditor/taler-helper-auditor-deposits.c +++ b/src/auditor/taler-helper-auditor-deposits.c @@ -123,7 +123,6 @@ test_dc (void *cls, struct TALER_Amount deposit_fee; qs = TALER_ARL_edb->have_deposit (TALER_ARL_edb->cls, - TALER_ARL_esession, &dep, GNUNET_NO /* do not check refund deadline */, &deposit_fee, diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index efeaa4f63..592663da6 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -744,7 +744,6 @@ handle_recoup_by_reserve ( if (NULL == rev) { qs = TALER_ARL_edb->get_denomination_revocation (TALER_ARL_edb->cls, - TALER_ARL_esession, &coin->denom_pub_hash, &msig, &rev_rowid); @@ -882,7 +881,6 @@ get_closing_fee (const char *receiver_account, method); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, - TALER_ARL_esession, method, atime, &start_date, @@ -1089,7 +1087,6 @@ verify_reserve_balance (void *cls, reserve.pub = rs->reserve_pub; qs = TALER_ARL_edb->reserves_get (TALER_ARL_edb->cls, - TALER_ARL_esession, &reserve); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { @@ -1377,7 +1374,6 @@ analyze_reserves (void *cls) qs = TALER_ARL_edb->select_reserves_in_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppr.last_reserve_in_serial_id, &handle_reserve_in, &rc); @@ -1388,7 +1384,6 @@ analyze_reserves (void *cls) } qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppr.last_reserve_out_serial_id, &handle_reserve_out, &rc); @@ -1399,7 +1394,6 @@ analyze_reserves (void *cls) } qs = TALER_ARL_edb->select_recoup_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppr.last_reserve_recoup_serial_id, &handle_recoup_by_reserve, &rc); @@ -1410,7 +1404,6 @@ analyze_reserves (void *cls) } qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, ppr.last_reserve_close_serial_id, &handle_reserve_closed, &rc); diff --git a/src/auditor/taler-helper-auditor-wire.c b/src/auditor/taler-helper-auditor-wire.c index eee186ca3..13ee27b70 100644 --- a/src/auditor/taler-helper-auditor-wire.c +++ b/src/auditor/taler-helper-auditor-wire.c @@ -665,8 +665,7 @@ commit (enum GNUNET_DB_QueryStatus qs) "Hard error, not recording progress\n"); TALER_ARL_adb->rollback (TALER_ARL_adb->cls, TALER_ARL_asession); - TALER_ARL_edb->rollback (TALER_ARL_edb->cls, - TALER_ARL_esession); + TALER_ARL_edb->rollback (TALER_ARL_edb->cls); return qs; } for (struct WireAccount *wa = wa_head; @@ -741,8 +740,7 @@ commit (enum GNUNET_DB_QueryStatus qs) if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) { - qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls, - TALER_ARL_esession); + qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls); if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -769,8 +767,7 @@ commit (enum GNUNET_DB_QueryStatus qs) "Processing failed, rolling back transaction\n"); TALER_ARL_adb->rollback (TALER_ARL_adb->cls, TALER_ARL_asession); - TALER_ARL_edb->rollback (TALER_ARL_edb->cls, - TALER_ARL_esession); + TALER_ARL_edb->rollback (TALER_ARL_edb->cls); } return qs; } @@ -870,7 +867,6 @@ check_for_required_transfers (void) "Analyzing exchange's unfinished deposits (deadline: %s)\n", GNUNET_STRINGS_absolute_time_to_string (next_timestamp)); qs = TALER_ARL_edb->select_deposits_missing_wire (TALER_ARL_edb->cls, - TALER_ARL_esession, pp.last_timestamp, next_timestamp, &wire_missing_cb, @@ -1267,7 +1263,6 @@ check_exchange_wire_out (struct WireAccount *wa) wa->ai->section_name); qs = TALER_ARL_edb->select_wire_out_above_serial_id_by_account ( TALER_ARL_edb->cls, - TALER_ARL_esession, wa->ai->section_name, wa->pp.last_wire_out_serial_id, &wire_out_cb, @@ -1824,7 +1819,6 @@ process_credits (void *cls) wa->ai->section_name); qs = TALER_ARL_edb->select_reserves_in_above_serial_id_by_account ( TALER_ARL_edb->cls, - TALER_ARL_esession, wa->ai->section_name, wa->pp.last_reserve_in_serial_id, &reserve_in_cb, @@ -1953,11 +1947,11 @@ reserve_closed_cb (void *cls, static enum GNUNET_DB_QueryStatus begin_transaction (void) { - TALER_ARL_esession = TALER_ARL_edb->get_session (TALER_ARL_edb->cls); - if (NULL == TALER_ARL_esession) + if (GNUNET_OK != + TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize exchange database session.\n"); + "Failed to initialize exchange database connection.\n"); return GNUNET_DB_STATUS_HARD_ERROR; } TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); @@ -1974,11 +1968,9 @@ begin_transaction (void) GNUNET_break (0); return GNUNET_DB_STATUS_HARD_ERROR; } - TALER_ARL_edb->preflight (TALER_ARL_edb->cls, - TALER_ARL_esession); + TALER_ARL_edb->preflight (TALER_ARL_edb->cls); if (GNUNET_OK != TALER_ARL_edb->start (TALER_ARL_edb->cls, - TALER_ARL_esession, "wire auditor")) { GNUNET_break (0); @@ -2031,7 +2023,6 @@ begin_transaction (void) qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( TALER_ARL_edb->cls, - TALER_ARL_esession, pp.last_reserve_close_uuid, &reserve_closed_cb, NULL); |