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 | |
parent | 37f049b3bc98c72f68687e67f102ee5b06f9263d (diff) | |
download | exchange-c559b1c935a93c4cdec442beeac59264d483c824.tar.gz exchange-c559b1c935a93c4cdec442beeac59264d483c824.zip |
complete implementation of long-polling for reserve status; remove support for multi-threaded exchange httpd
58 files changed, 1113 insertions, 3095 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; | |||
42 | const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; | 42 | const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Our session with the #TALER_ARL_edb. | ||
46 | */ | ||
47 | struct TALER_EXCHANGEDB_Session *TALER_ARL_esession; | ||
48 | |||
49 | /** | ||
50 | * Handle to access the auditor's database. | 45 | * Handle to access the auditor's database. |
51 | */ | 46 | */ |
52 | struct TALER_AUDITORDB_Plugin *TALER_ARL_adb; | 47 | struct TALER_AUDITORDB_Plugin *TALER_ARL_adb; |
@@ -213,7 +208,6 @@ TALER_ARL_get_denomination_info_by_hash ( | |||
213 | denominations = GNUNET_CONTAINER_multihashmap_create (256, | 208 | denominations = GNUNET_CONTAINER_multihashmap_create (256, |
214 | GNUNET_NO); | 209 | GNUNET_NO); |
215 | qs = TALER_ARL_edb->iterate_denomination_info (TALER_ARL_edb->cls, | 210 | qs = TALER_ARL_edb->iterate_denomination_info (TALER_ARL_edb->cls, |
216 | TALER_ARL_esession, | ||
217 | &add_denomination, | 211 | &add_denomination, |
218 | NULL); | 212 | NULL); |
219 | if (0 > qs) | 213 | if (0 > qs) |
@@ -239,7 +233,6 @@ TALER_ARL_get_denomination_info_by_hash ( | |||
239 | struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; | 233 | struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; |
240 | 234 | ||
241 | qs = TALER_ARL_edb->get_denomination_info (TALER_ARL_edb->cls, | 235 | qs = TALER_ARL_edb->get_denomination_info (TALER_ARL_edb->cls, |
242 | TALER_ARL_esession, | ||
243 | dh, | 236 | dh, |
244 | &issue); | 237 | &issue); |
245 | if (qs <= 0) | 238 | if (qs <= 0) |
@@ -324,23 +317,24 @@ transact (TALER_ARL_Analysis analysis, | |||
324 | GNUNET_break (0); | 317 | GNUNET_break (0); |
325 | return GNUNET_SYSERR; | 318 | return GNUNET_SYSERR; |
326 | } | 319 | } |
327 | TALER_ARL_edb->preflight (TALER_ARL_edb->cls, | 320 | if (GNUNET_OK != |
328 | TALER_ARL_esession); | 321 | TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) |
322 | { | ||
323 | GNUNET_break (0); | ||
324 | return GNUNET_SYSERR; | ||
325 | } | ||
329 | ret = TALER_ARL_edb->start (TALER_ARL_edb->cls, | 326 | ret = TALER_ARL_edb->start (TALER_ARL_edb->cls, |
330 | TALER_ARL_esession, | ||
331 | "auditor"); | 327 | "auditor"); |
332 | if (GNUNET_OK != ret) | 328 | if (GNUNET_OK != ret) |
333 | { | 329 | { |
334 | GNUNET_break (0); | 330 | GNUNET_break (0); |
335 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls, | 331 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls); |
336 | TALER_ARL_esession); | ||
337 | return GNUNET_SYSERR; | 332 | return GNUNET_SYSERR; |
338 | } | 333 | } |
339 | qs = analysis (analysis_cls); | 334 | qs = analysis (analysis_cls); |
340 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) | 335 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) |
341 | { | 336 | { |
342 | qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls, | 337 | qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls); |
343 | TALER_ARL_esession); | ||
344 | if (0 > qs) | 338 | if (0 > qs) |
345 | { | 339 | { |
346 | GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); | 340 | GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); |
@@ -367,8 +361,7 @@ transact (TALER_ARL_Analysis analysis, | |||
367 | "Processing failed (or no changes), rolling back transaction\n"); | 361 | "Processing failed (or no changes), rolling back transaction\n"); |
368 | TALER_ARL_adb->rollback (TALER_ARL_adb->cls, | 362 | TALER_ARL_adb->rollback (TALER_ARL_adb->cls, |
369 | TALER_ARL_asession); | 363 | TALER_ARL_asession); |
370 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls, | 364 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls); |
371 | TALER_ARL_esession); | ||
372 | } | 365 | } |
373 | switch (qs) | 366 | switch (qs) |
374 | { | 367 | { |
@@ -396,11 +389,11 @@ int | |||
396 | TALER_ARL_setup_sessions_and_run (TALER_ARL_Analysis ana, | 389 | TALER_ARL_setup_sessions_and_run (TALER_ARL_Analysis ana, |
397 | void *ana_cls) | 390 | void *ana_cls) |
398 | { | 391 | { |
399 | TALER_ARL_esession = TALER_ARL_edb->get_session (TALER_ARL_edb->cls); | 392 | if (GNUNET_OK != |
400 | if (NULL == TALER_ARL_esession) | 393 | TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) |
401 | { | 394 | { |
402 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 395 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
403 | "Failed to initialize exchange session.\n"); | 396 | "Failed to initialize exchange connection.\n"); |
404 | return GNUNET_SYSERR; | 397 | return GNUNET_SYSERR; |
405 | } | 398 | } |
406 | TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); | 399 | 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; | |||
55 | extern const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; | 55 | extern const struct GNUNET_CONFIGURATION_Handle *TALER_ARL_cfg; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Our session with the #TALER_ARL_edb. | ||
59 | */ | ||
60 | extern struct TALER_EXCHANGEDB_Session *TALER_ARL_esession; | ||
61 | |||
62 | /** | ||
63 | * Handle to access the auditor's database. | 58 | * Handle to access the auditor's database. |
64 | */ | 59 | */ |
65 | extern struct TALER_AUDITORDB_Plugin *TALER_ARL_adb; | 60 | 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 @@ | |||
61 | static int auditor_connection_close; | 61 | static int auditor_connection_close; |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * The auditor's configuration (global) | 64 | * The auditor's configuration. |
65 | */ | 65 | */ |
66 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 66 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Our DB plugin. | 69 | * Our DB plugin. |
@@ -86,9 +86,9 @@ static struct TALER_AuditorPublicKeyP auditor_pub; | |||
86 | static unsigned int connection_timeout = 30; | 86 | static unsigned int connection_timeout = 30; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * The HTTP Daemon. | 89 | * Return value from main() |
90 | */ | 90 | */ |
91 | static struct MHD_Daemon *mhd; | 91 | static int global_ret; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Port to run the daemon on. | 94 | * Port to run the daemon on. |
@@ -96,177 +96,10 @@ static struct MHD_Daemon *mhd; | |||
96 | static uint16_t serve_port; | 96 | static uint16_t serve_port; |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Path for the unix domain-socket to run the daemon on. | ||
100 | */ | ||
101 | static char *serve_unixpath; | ||
102 | |||
103 | /** | ||
104 | * File mode for unix-domain socket. | ||
105 | */ | ||
106 | static mode_t unixpath_mode; | ||
107 | |||
108 | /** | ||
109 | * Our currency. | 99 | * Our currency. |
110 | */ | 100 | */ |
111 | char *TAH_currency; | 101 | char *TAH_currency; |
112 | 102 | ||
113 | /** | ||
114 | * Pipe used for signaling reloading of our key state. | ||
115 | */ | ||
116 | static int reload_pipe[2] = { -1, -1 }; | ||
117 | |||
118 | |||
119 | /** | ||
120 | * Handle a signal, writing relevant signal numbers to the pipe. | ||
121 | * | ||
122 | * @param signal_number the signal number | ||
123 | */ | ||
124 | static void | ||
125 | handle_signal (int signal_number) | ||
126 | { | ||
127 | char c = signal_number; | ||
128 | |||
129 | (void) ! write (reload_pipe[1], | ||
130 | &c, | ||
131 | 1); | ||
132 | /* While one might like to "handle errors" here, even logging via fprintf() | ||
133 | isn't safe inside of a signal handler. So there is nothing we safely CAN | ||
134 | do. OTOH, also very little that can go wrong in practice. Calling _exit() | ||
135 | on errors might be a possibility, but that might do more harm than good. */// | ||
136 | } | ||
137 | |||
138 | |||
139 | /** | ||
140 | * Call #handle_signal() to pass the received signal via | ||
141 | * the control pipe. | ||
142 | */ | ||
143 | static void | ||
144 | handle_sigint (void) | ||
145 | { | ||
146 | handle_signal (SIGINT); | ||
147 | } | ||
148 | |||
149 | |||
150 | /** | ||
151 | * Call #handle_signal() to pass the received signal via | ||
152 | * the control pipe. | ||
153 | */ | ||
154 | static void | ||
155 | handle_sigterm (void) | ||
156 | { | ||
157 | handle_signal (SIGTERM); | ||
158 | } | ||
159 | |||
160 | |||
161 | /** | ||
162 | * Call #handle_signal() to pass the received signal via | ||
163 | * the control pipe. | ||
164 | */ | ||
165 | static void | ||
166 | handle_sighup (void) | ||
167 | { | ||
168 | handle_signal (SIGHUP); | ||
169 | } | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Call #handle_signal() to pass the received signal via | ||
174 | * the control pipe. | ||
175 | */ | ||
176 | static void | ||
177 | handle_sigchld (void) | ||
178 | { | ||
179 | handle_signal (SIGCHLD); | ||
180 | } | ||
181 | |||
182 | |||
183 | /** | ||
184 | * Read signals from a pipe in a loop, and reload keys from disk if | ||
185 | * SIGUSR1 is received, terminate if SIGTERM/SIGINT is received, and | ||
186 | * restart if SIGHUP is received. | ||
187 | * | ||
188 | * @return #GNUNET_SYSERR on errors, | ||
189 | * #GNUNET_OK to terminate normally | ||
190 | * #GNUNET_NO to restart an update version of the binary | ||
191 | */ | ||
192 | static int | ||
193 | signal_loop (void) | ||
194 | { | ||
195 | struct GNUNET_SIGNAL_Context *sigterm; | ||
196 | struct GNUNET_SIGNAL_Context *sigint; | ||
197 | struct GNUNET_SIGNAL_Context *sighup; | ||
198 | struct GNUNET_SIGNAL_Context *sigchld; | ||
199 | int ret; | ||
200 | |||
201 | if (0 != pipe (reload_pipe)) | ||
202 | { | ||
203 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
204 | "pipe"); | ||
205 | return GNUNET_SYSERR; | ||
206 | } | ||
207 | sigterm = GNUNET_SIGNAL_handler_install (SIGTERM, | ||
208 | &handle_sigterm); | ||
209 | sigint = GNUNET_SIGNAL_handler_install (SIGINT, | ||
210 | &handle_sigint); | ||
211 | sighup = GNUNET_SIGNAL_handler_install (SIGHUP, | ||
212 | &handle_sighup); | ||
213 | sigchld = GNUNET_SIGNAL_handler_install (SIGCHLD, | ||
214 | &handle_sigchld); | ||
215 | |||
216 | ret = 2; | ||
217 | while (2 == ret) | ||
218 | { | ||
219 | char c; | ||
220 | ssize_t res; | ||
221 | |||
222 | errno = 0; | ||
223 | res = read (reload_pipe[0], | ||
224 | &c, | ||
225 | 1); | ||
226 | if ( (res < 0) && | ||
227 | (EINTR != errno)) | ||
228 | { | ||
229 | GNUNET_break (0); | ||
230 | ret = GNUNET_SYSERR; | ||
231 | break; | ||
232 | } | ||
233 | if (EINTR == errno) | ||
234 | { | ||
235 | /* ignore, do the loop again */ | ||
236 | continue; | ||
237 | } | ||
238 | switch (c) | ||
239 | { | ||
240 | case SIGTERM: | ||
241 | case SIGINT: | ||
242 | /* terminate */ | ||
243 | ret = GNUNET_OK; | ||
244 | break; | ||
245 | case SIGHUP: | ||
246 | /* restart updated binary */ | ||
247 | ret = GNUNET_NO; | ||
248 | break; | ||
249 | #if HAVE_DEVELOPER | ||
250 | case SIGCHLD: | ||
251 | /* running in test-mode, test finished, terminate */ | ||
252 | ret = GNUNET_OK; | ||
253 | break; | ||
254 | #endif | ||
255 | default: | ||
256 | /* unexpected character */ | ||
257 | GNUNET_break (0); | ||
258 | break; | ||
259 | } | ||
260 | } | ||
261 | GNUNET_SIGNAL_handler_uninstall (sigterm); | ||
262 | GNUNET_SIGNAL_handler_uninstall (sigint); | ||
263 | GNUNET_SIGNAL_handler_uninstall (sighup); | ||
264 | GNUNET_SIGNAL_handler_uninstall (sigchld); | ||
265 | GNUNET_break (0 == close (reload_pipe[0])); | ||
266 | GNUNET_break (0 == close (reload_pipe[1])); | ||
267 | return ret; | ||
268 | } | ||
269 | |||
270 | 103 | ||
271 | /** | 104 | /** |
272 | * Function called whenever MHD is done with a request. If the | 105 | * Function called whenever MHD is done with a request. If the |
@@ -435,7 +268,7 @@ handle_mhd_request (void *cls, | |||
435 | * | 268 | * |
436 | * @return #GNUNET_OK on success | 269 | * @return #GNUNET_OK on success |
437 | */ | 270 | */ |
438 | static int | 271 | static enum GNUNET_GenericReturnValue |
439 | auditor_serve_process_config (void) | 272 | auditor_serve_process_config (void) |
440 | { | 273 | { |
441 | if (NULL == | 274 | if (NULL == |
@@ -452,13 +285,11 @@ auditor_serve_process_config (void) | |||
452 | "Failed to initialize DB subsystem to query exchange database\n"); | 285 | "Failed to initialize DB subsystem to query exchange database\n"); |
453 | return GNUNET_SYSERR; | 286 | return GNUNET_SYSERR; |
454 | } | 287 | } |
455 | if (GNUNET_OK != | 288 | if (GNUNET_SYSERR == |
456 | TALER_MHD_parse_config (cfg, | 289 | TAH_eplugin->preflight (TAH_eplugin->cls)) |
457 | "auditor", | ||
458 | &serve_port, | ||
459 | &serve_unixpath, | ||
460 | &unixpath_mode)) | ||
461 | { | 290 | { |
291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
292 | "Failed to initialize DB subsystem to query exchange database\n"); | ||
462 | return GNUNET_SYSERR; | 293 | return GNUNET_SYSERR; |
463 | } | 294 | } |
464 | if (GNUNET_OK != | 295 | if (GNUNET_OK != |
@@ -534,6 +365,113 @@ auditor_serve_process_config (void) | |||
534 | 365 | ||
535 | 366 | ||
536 | /** | 367 | /** |
368 | * Function run on shutdown. | ||
369 | * | ||
370 | * @param cls NULL | ||
371 | */ | ||
372 | static void | ||
373 | do_shutdown (void *cls) | ||
374 | { | ||
375 | struct MHD_Daemon *mhd; | ||
376 | (void) cls; | ||
377 | |||
378 | mhd = TALER_MHD_daemon_stop (); | ||
379 | TEAH_DEPOSIT_CONFIRMATION_done (); | ||
380 | if (NULL != mhd) | ||
381 | MHD_stop_daemon (mhd); | ||
382 | if (NULL != TAH_plugin) | ||
383 | { | ||
384 | TALER_AUDITORDB_plugin_unload (TAH_plugin); | ||
385 | TAH_plugin = NULL; | ||
386 | } | ||
387 | if (NULL != TAH_eplugin) | ||
388 | { | ||
389 | TALER_EXCHANGEDB_plugin_unload (TAH_eplugin); | ||
390 | TAH_eplugin = NULL; | ||
391 | } | ||
392 | } | ||
393 | |||
394 | |||
395 | /** | ||
396 | * Main function that will be run by the scheduler. | ||
397 | * | ||
398 | * @param cls closure | ||
399 | * @param args remaining command-line arguments | ||
400 | * @param cfgfile name of the configuration file used (for saving, can be | ||
401 | * NULL!) | ||
402 | * @param config configuration | ||
403 | */ | ||
404 | static void | ||
405 | run (void *cls, | ||
406 | char *const *args, | ||
407 | const char *cfgfile, | ||
408 | const struct GNUNET_CONFIGURATION_Handle *config) | ||
409 | { | ||
410 | enum TALER_MHD_GlobalOptions go; | ||
411 | int fh; | ||
412 | |||
413 | go = TALER_MHD_GO_NONE; | ||
414 | if (auditor_connection_close) | ||
415 | go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE; | ||
416 | TALER_MHD_setup (go); | ||
417 | cfg = config; | ||
418 | |||
419 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | ||
420 | NULL); | ||
421 | if (GNUNET_OK != | ||
422 | auditor_serve_process_config ()) | ||
423 | { | ||
424 | global_ret = EXIT_NOTCONFIGURED; | ||
425 | GNUNET_SCHEDULER_shutdown (); | ||
426 | return; | ||
427 | } | ||
428 | TEAH_DEPOSIT_CONFIRMATION_init (); | ||
429 | fh = TALER_MHD_bind (cfg, | ||
430 | "auditor", | ||
431 | &serve_port); | ||
432 | if ( (0 == serve_port) && | ||
433 | (-1 == fh) ) | ||
434 | { | ||
435 | GNUNET_SCHEDULER_shutdown (); | ||
436 | return; | ||
437 | } | ||
438 | { | ||
439 | struct MHD_Daemon *mhd; | ||
440 | |||
441 | mhd = MHD_start_daemon (MHD_USE_SUSPEND_RESUME | ||
442 | | MHD_USE_PIPE_FOR_SHUTDOWN | ||
443 | | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | ||
444 | | MHD_USE_TCP_FASTOPEN, | ||
445 | (-1 == fh) ? serve_port : 0, | ||
446 | NULL, NULL, | ||
447 | &handle_mhd_request, NULL, | ||
448 | MHD_OPTION_LISTEN_BACKLOG_SIZE, | ||
449 | (unsigned int) 1024, | ||
450 | MHD_OPTION_LISTEN_SOCKET, | ||
451 | fh, | ||
452 | MHD_OPTION_EXTERNAL_LOGGER, | ||
453 | &TALER_MHD_handle_logs, | ||
454 | NULL, | ||
455 | MHD_OPTION_NOTIFY_COMPLETED, | ||
456 | &handle_mhd_completion_callback, | ||
457 | NULL, | ||
458 | MHD_OPTION_CONNECTION_TIMEOUT, | ||
459 | connection_timeout, | ||
460 | MHD_OPTION_END); | ||
461 | if (NULL == mhd) | ||
462 | { | ||
463 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
464 | "Failed to launch HTTP service. Is the port in use?\n"); | ||
465 | GNUNET_SCHEDULER_shutdown (); | ||
466 | return; | ||
467 | } | ||
468 | global_ret = EXIT_SUCCESS; | ||
469 | TALER_MHD_daemon_start (mhd); | ||
470 | } | ||
471 | } | ||
472 | |||
473 | |||
474 | /** | ||
537 | * The main function of the taler-auditor-httpd server ("the auditor"). | 475 | * The main function of the taler-auditor-httpd server ("the auditor"). |
538 | * | 476 | * |
539 | * @param argc number of arguments from the command line | 477 | * @param argc number of arguments from the command line |
@@ -544,15 +482,11 @@ int | |||
544 | main (int argc, | 482 | main (int argc, |
545 | char *const *argv) | 483 | char *const *argv) |
546 | { | 484 | { |
547 | char *cfgfile = NULL; | ||
548 | char *loglev = NULL; | ||
549 | char *logfile = NULL; | ||
550 | const struct GNUNET_GETOPT_CommandLineOption options[] = { | 485 | const struct GNUNET_GETOPT_CommandLineOption options[] = { |
551 | GNUNET_GETOPT_option_flag ('C', | 486 | GNUNET_GETOPT_option_flag ('C', |
552 | "connection-close", | 487 | "connection-close", |
553 | "force HTTP connections to be closed after each request", | 488 | "force HTTP connections to be closed after each request", |
554 | &auditor_connection_close), | 489 | &auditor_connection_close), |
555 | GNUNET_GETOPT_option_cfgfile (&cfgfile), | ||
556 | GNUNET_GETOPT_option_uint ('t', | 490 | GNUNET_GETOPT_option_uint ('t', |
557 | "timeout", | 491 | "timeout", |
558 | "SECONDS", | 492 | "SECONDS", |
@@ -560,207 +494,22 @@ main (int argc, | |||
560 | &connection_timeout), | 494 | &connection_timeout), |
561 | GNUNET_GETOPT_option_help ( | 495 | GNUNET_GETOPT_option_help ( |
562 | "HTTP server providing a RESTful API to access a Taler auditor"), | 496 | "HTTP server providing a RESTful API to access a Taler auditor"), |
563 | GNUNET_GETOPT_option_loglevel (&loglev), | ||
564 | GNUNET_GETOPT_option_logfile (&logfile), | ||
565 | GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), | 497 | GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), |
566 | GNUNET_GETOPT_OPTION_END | 498 | GNUNET_GETOPT_OPTION_END |
567 | }; | 499 | }; |
568 | int ret; | 500 | int ret; |
569 | const char *listen_pid; | ||
570 | const char *listen_fds; | ||
571 | int fh = -1; | ||
572 | enum TALER_MHD_GlobalOptions go; | ||
573 | 501 | ||
574 | TALER_OS_init (); | 502 | TALER_OS_init (); |
575 | { | 503 | ret = GNUNET_PROGRAM_run (argc, argv, |
576 | int ret; | 504 | "taler-auditor-httpd", |
577 | 505 | "Taler auditor HTTP service", | |
578 | ret = GNUNET_GETOPT_run ("taler-auditor-httpd", | 506 | options, |
579 | options, | 507 | &run, NULL); |
580 | argc, argv); | 508 | if (GNUNET_SYSERR == ret) |
581 | if (GNUNET_NO == ret) | 509 | return EXIT_INVALIDARGUMENT; |
582 | return EXIT_SUCCESS; | 510 | if (GNUNET_NO == ret) |
583 | if (GNUNET_SYSERR == ret) | 511 | return EXIT_SUCCESS; |
584 | return EXIT_FAILURE; | 512 | return global_ret; |
585 | } | ||
586 | go = TALER_MHD_GO_NONE; | ||
587 | if (auditor_connection_close) | ||
588 | go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE; | ||
589 | TALER_MHD_setup (go); | ||
590 | GNUNET_assert (GNUNET_OK == | ||
591 | GNUNET_log_setup ("taler-auditor-httpd", | ||
592 | (NULL == loglev) ? "INFO" : loglev, | ||
593 | logfile)); | ||
594 | if (NULL == cfgfile) | ||
595 | cfgfile = GNUNET_CONFIGURATION_default_filename (); | ||
596 | if (NULL == cfgfile) | ||
597 | { | ||
598 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
599 | "Can't find default configuration file.\n"); | ||
600 | return EXIT_NOTCONFIGURED; | ||
601 | } | ||
602 | cfg = GNUNET_CONFIGURATION_create (); | ||
603 | if (GNUNET_SYSERR == | ||
604 | GNUNET_CONFIGURATION_load (cfg, | ||
605 | cfgfile)) | ||
606 | { | ||
607 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
608 | "Malformed configuration file `%s', exiting ...\n", | ||
609 | cfgfile); | ||
610 | GNUNET_free (cfgfile); | ||
611 | return EXIT_NOTCONFIGURED; | ||
612 | } | ||
613 | GNUNET_free (cfgfile); | ||
614 | |||
615 | if (GNUNET_OK != | ||
616 | auditor_serve_process_config ()) | ||
617 | return EXIT_NOTCONFIGURED; | ||
618 | TEAH_DEPOSIT_CONFIRMATION_init (); | ||
619 | /* check for systemd-style FD passing */ | ||
620 | listen_pid = getenv ("LISTEN_PID"); | ||
621 | listen_fds = getenv ("LISTEN_FDS"); | ||
622 | if ( (NULL != listen_pid) && | ||
623 | (NULL != listen_fds) && | ||
624 | (getpid () == strtol (listen_pid, | ||
625 | NULL, | ||
626 | 10)) && | ||
627 | (1 == strtoul (listen_fds, | ||
628 | NULL, | ||
629 | 10)) ) | ||
630 | { | ||
631 | int flags; | ||
632 | |||
633 | fh = 3; | ||
634 | flags = fcntl (fh, | ||
635 | F_GETFD); | ||
636 | if ( (-1 == flags) && | ||
637 | (EBADF == errno) ) | ||
638 | { | ||
639 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
640 | "Bad listen socket passed, ignored\n"); | ||
641 | fh = -1; | ||
642 | } | ||
643 | flags |= FD_CLOEXEC; | ||
644 | if ( (-1 != fh) && | ||
645 | (0 != fcntl (fh, | ||
646 | F_SETFD, | ||
647 | flags)) ) | ||
648 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
649 | "fcntl"); | ||
650 | } | ||
651 | |||
652 | /* consider unix path */ | ||
653 | if ( (-1 == fh) && | ||
654 | (NULL != serve_unixpath) ) | ||
655 | { | ||
656 | fh = TALER_MHD_open_unix_path (serve_unixpath, | ||
657 | unixpath_mode); | ||
658 | if (-1 == fh) | ||
659 | { | ||
660 | TEAH_DEPOSIT_CONFIRMATION_done (); | ||
661 | return EXIT_NOPERMISSION; /* most likely at least */ | ||
662 | } | ||
663 | } | ||
664 | |||
665 | mhd = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN | ||
666 | | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | ||
667 | | MHD_USE_INTERNAL_POLLING_THREAD | ||
668 | | MHD_USE_TCP_FASTOPEN, | ||
669 | (-1 == fh) ? serve_port : 0, | ||
670 | NULL, NULL, | ||
671 | &handle_mhd_request, NULL, | ||
672 | MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) 32, | ||
673 | MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, | ||
674 | MHD_OPTION_LISTEN_SOCKET, fh, | ||
675 | MHD_OPTION_EXTERNAL_LOGGER, &TALER_MHD_handle_logs, | ||
676 | NULL, | ||
677 | MHD_OPTION_NOTIFY_COMPLETED, | ||
678 | &handle_mhd_completion_callback, NULL, | ||
679 | MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, | ||
680 | MHD_OPTION_END); | ||
681 | if (NULL == mhd) | ||
682 | { | ||
683 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
684 | "Failed to start HTTP server.\n"); | ||
685 | TEAH_DEPOSIT_CONFIRMATION_done (); | ||
686 | return EXIT_FAILURE; | ||
687 | } | ||
688 | |||
689 | /* normal behavior */ | ||
690 | ret = signal_loop (); | ||
691 | switch (ret) | ||
692 | { | ||
693 | case GNUNET_OK: | ||
694 | case GNUNET_SYSERR: | ||
695 | MHD_stop_daemon (mhd); | ||
696 | break; | ||
697 | case GNUNET_NO: | ||
698 | { | ||
699 | MHD_socket sock = MHD_quiesce_daemon (mhd); | ||
700 | pid_t chld; | ||
701 | int flags; | ||
702 | |||
703 | /* Set flags to make 'sock' inherited by child */ | ||
704 | flags = fcntl (sock, F_GETFD); | ||
705 | GNUNET_assert (-1 != flags); | ||
706 | flags &= ~FD_CLOEXEC; | ||
707 | GNUNET_assert (-1 != fcntl (sock, F_SETFD, flags)); | ||
708 | chld = fork (); | ||
709 | if (-1 == chld) | ||
710 | { | ||
711 | /* fork() failed, continue clean up, unhappily */ | ||
712 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
713 | "fork"); | ||
714 | } | ||
715 | if (0 == chld) | ||
716 | { | ||
717 | char pids[12]; | ||
718 | |||
719 | /* exec another taler-auditor-httpd, passing on the listen socket; | ||
720 | as in systemd it is expected to be on FD #3 */ | ||
721 | if (3 != dup2 (sock, 3)) | ||
722 | { | ||
723 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
724 | "dup2"); | ||
725 | _exit (1); | ||
726 | } | ||
727 | /* Tell the child that it is the desired recipient for FD #3 */ | ||
728 | GNUNET_snprintf (pids, | ||
729 | sizeof (pids), | ||
730 | "%u", | ||
731 | getpid ()); | ||
732 | setenv ("LISTEN_PID", pids, 1); | ||
733 | setenv ("LISTEN_FDS", "1", 1); | ||
734 | /* Finally, exec the (presumably) more recent auditor binary */ | ||
735 | execvp ("taler-auditor-httpd", | ||
736 | argv); | ||
737 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
738 | "execvp"); | ||
739 | _exit (1); | ||
740 | } | ||
741 | /* we're the original process, handle remaining contextions | ||
742 | before exiting; as the listen socket is no longer used, | ||
743 | close it here */ | ||
744 | GNUNET_break (0 == close (sock)); | ||
745 | while (0 != MHD_get_daemon_info (mhd, | ||
746 | MHD_DAEMON_INFO_CURRENT_CONNECTIONS)-> | ||
747 | num_connections) | ||
748 | sleep (1); | ||
749 | /* Now we're really done, practice clean shutdown */ | ||
750 | MHD_stop_daemon (mhd); | ||
751 | } | ||
752 | break; | ||
753 | default: | ||
754 | GNUNET_break (0); | ||
755 | MHD_stop_daemon (mhd); | ||
756 | break; | ||
757 | } | ||
758 | TALER_AUDITORDB_plugin_unload (TAH_plugin); | ||
759 | TAH_plugin = NULL; | ||
760 | TALER_EXCHANGEDB_plugin_unload (TAH_eplugin); | ||
761 | TAH_eplugin = NULL; | ||
762 | TEAH_DEPOSIT_CONFIRMATION_done (); | ||
763 | return (GNUNET_SYSERR == ret) ? EXIT_FAILURE : EXIT_SUCCESS; | ||
764 | } | 513 | } |
765 | 514 | ||
766 | 515 | ||
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 ( | |||
147 | 147 | ||
148 | /* check for revocation */ | 148 | /* check for revocation */ |
149 | qs = TAH_eplugin->lookup_signkey_revocation (TAH_eplugin->cls, | 149 | qs = TAH_eplugin->lookup_signkey_revocation (TAH_eplugin->cls, |
150 | NULL, | ||
151 | &es->exchange_pub, | 150 | &es->exchange_pub, |
152 | &master_sig); | 151 | &master_sig); |
153 | if (0 > qs) | 152 | 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[] = { | |||
120 | struct InsertContext | 120 | struct InsertContext |
121 | { | 121 | { |
122 | /** | 122 | /** |
123 | * Database session to use. | ||
124 | */ | ||
125 | struct TALER_EXCHANGEDB_Session *ds; | ||
126 | |||
127 | /** | ||
128 | * Table we are replicating. | 123 | * Table we are replicating. |
129 | */ | 124 | */ |
130 | struct Table *table; | 125 | struct Table *table; |
@@ -154,7 +149,6 @@ do_insert (void *cls, | |||
154 | if (0 >= ctx->qs) | 149 | if (0 >= ctx->qs) |
155 | return GNUNET_SYSERR; | 150 | return GNUNET_SYSERR; |
156 | qs = dst->insert_records_by_table (dst->cls, | 151 | qs = dst->insert_records_by_table (dst->cls, |
157 | ctx->ds, | ||
158 | td); | 152 | td); |
159 | if (0 >= qs) | 153 | if (0 >= qs) |
160 | { | 154 | { |
@@ -193,42 +187,34 @@ do_insert (void *cls, | |||
193 | * | 187 | * |
194 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to rollback | 188 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to rollback |
195 | */ | 189 | */ |
196 | static int | 190 | static enum GNUNET_GenericReturnValue |
197 | transact (struct TALER_EXCHANGEDB_Session *ss, | 191 | transact (void) |
198 | struct TALER_EXCHANGEDB_Session *ds) | ||
199 | { | 192 | { |
200 | struct InsertContext ctx = { | 193 | struct InsertContext ctx = { |
201 | .ds = ds, | ||
202 | .qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT | 194 | .qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT |
203 | }; | 195 | }; |
204 | 196 | ||
205 | if (0 > | 197 | if (0 > |
206 | src->start (src->cls, | 198 | src->start (src->cls, |
207 | ss, | ||
208 | "lookup src serials")) | 199 | "lookup src serials")) |
209 | return GNUNET_SYSERR; | 200 | return GNUNET_SYSERR; |
210 | for (unsigned int i = 0; ! tables[i].end; i++) | 201 | for (unsigned int i = 0; ! tables[i].end; i++) |
211 | src->lookup_serial_by_table (src->cls, | 202 | src->lookup_serial_by_table (src->cls, |
212 | ss, | ||
213 | tables[i].rt, | 203 | tables[i].rt, |
214 | &tables[i].end_serial); | 204 | &tables[i].end_serial); |
215 | if (0 > | 205 | if (0 > |
216 | src->commit (src->cls, | 206 | src->commit (src->cls)) |
217 | ss)) | ||
218 | return GNUNET_SYSERR; | 207 | return GNUNET_SYSERR; |
219 | if (GNUNET_OK != | 208 | if (GNUNET_OK != |
220 | dst->start (src->cls, | 209 | dst->start (src->cls, |
221 | ds, | ||
222 | "lookup dst serials")) | 210 | "lookup dst serials")) |
223 | return GNUNET_SYSERR; | 211 | return GNUNET_SYSERR; |
224 | for (unsigned int i = 0; ! tables[i].end; i++) | 212 | for (unsigned int i = 0; ! tables[i].end; i++) |
225 | dst->lookup_serial_by_table (dst->cls, | 213 | dst->lookup_serial_by_table (dst->cls, |
226 | ds, | ||
227 | tables[i].rt, | 214 | tables[i].rt, |
228 | &tables[i].start_serial); | 215 | &tables[i].start_serial); |
229 | if (0 > | 216 | if (0 > |
230 | dst->commit (dst->cls, | 217 | dst->commit (dst->cls)) |
231 | ds)) | ||
232 | return GNUNET_SYSERR; | 218 | return GNUNET_SYSERR; |
233 | for (unsigned int i = 0; ! tables[i].end; i++) | 219 | for (unsigned int i = 0; ! tables[i].end; i++) |
234 | { | 220 | { |
@@ -248,16 +234,13 @@ transact (struct TALER_EXCHANGEDB_Session *ss, | |||
248 | 234 | ||
249 | if (GNUNET_OK != | 235 | if (GNUNET_OK != |
250 | src->start (src->cls, | 236 | src->start (src->cls, |
251 | ss, | ||
252 | "copy table (src)")) | 237 | "copy table (src)")) |
253 | return GNUNET_SYSERR; | 238 | return GNUNET_SYSERR; |
254 | if (GNUNET_OK != | 239 | if (GNUNET_OK != |
255 | dst->start (dst->cls, | 240 | dst->start (dst->cls, |
256 | ds, | ||
257 | "copy table (dst)")) | 241 | "copy table (dst)")) |
258 | return GNUNET_SYSERR; | 242 | return GNUNET_SYSERR; |
259 | qs = src->lookup_records_by_table (src->cls, | 243 | qs = src->lookup_records_by_table (src->cls, |
260 | ss, | ||
261 | table->rt, | 244 | table->rt, |
262 | table->start_serial, | 245 | table->start_serial, |
263 | &do_insert, | 246 | &do_insert, |
@@ -290,10 +273,8 @@ transact (struct TALER_EXCHANGEDB_Session *ss, | |||
290 | } | 273 | } |
291 | if (0 == ctx.qs) | 274 | if (0 == ctx.qs) |
292 | return GNUNET_SYSERR; /* insertion failed, maybe record existed? try again */ | 275 | return GNUNET_SYSERR; /* insertion failed, maybe record existed? try again */ |
293 | src->rollback (src->cls, | 276 | src->rollback (src->cls); |
294 | ss); | 277 | qs = dst->commit (dst->cls); |
295 | qs = dst->commit (dst->cls, | ||
296 | ds); | ||
297 | if (GNUNET_DB_STATUS_SOFT_ERROR == qs) | 278 | if (GNUNET_DB_STATUS_SOFT_ERROR == qs) |
298 | { | 279 | { |
299 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 280 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -328,35 +309,29 @@ static void | |||
328 | do_sync (void *cls) | 309 | do_sync (void *cls) |
329 | { | 310 | { |
330 | static struct GNUNET_TIME_Relative delay; | 311 | static struct GNUNET_TIME_Relative delay; |
331 | struct TALER_EXCHANGEDB_Session *ss; | ||
332 | struct TALER_EXCHANGEDB_Session *ds; | ||
333 | 312 | ||
334 | sync_task = NULL; | 313 | sync_task = NULL; |
335 | actual_size = 0; | 314 | actual_size = 0; |
336 | ss = src->get_session (src->cls); | 315 | if (GNUNET_SYSERR == |
337 | if (NULL == ss) | 316 | src->preflight (src->cls)) |
338 | { | 317 | { |
339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 318 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
340 | "Failed to begin transaction with data source. Exiting\n"); | 319 | "Failed to begin transaction with data source. Exiting\n"); |
341 | return; | 320 | return; |
342 | } | 321 | } |
343 | ds = dst->get_session (dst->cls); | 322 | if (GNUNET_SYSERR == |
344 | if (NULL == ds) | 323 | dst->preflight (dst->cls)) |
345 | { | 324 | { |
346 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 325 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
347 | "Failed to begin transaction with data destination. Exiting\n"); | 326 | "Failed to begin transaction with data destination. Exiting\n"); |
348 | return; | 327 | return; |
349 | } | 328 | } |
350 | if (GNUNET_OK != | 329 | if (GNUNET_OK != transact ()) |
351 | transact (ss, | ||
352 | ds)) | ||
353 | { | 330 | { |
354 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 331 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
355 | "Transaction failed, rolling back\n"); | 332 | "Transaction failed, rolling back\n"); |
356 | src->rollback (src->cls, | 333 | src->rollback (src->cls); |
357 | ss); | 334 | dst->rollback (dst->cls); |
358 | dst->rollback (dst->cls, | ||
359 | ds); | ||
360 | } | 335 | } |
361 | if (0 != global_ret) | 336 | if (0 != global_ret) |
362 | { | 337 | { |
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 ( | |||
756 | 756 | ||
757 | /* Obtain coin's transaction history */ | 757 | /* Obtain coin's transaction history */ |
758 | qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls, | 758 | qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls, |
759 | TALER_ARL_esession, | ||
760 | coin_pub, | 759 | coin_pub, |
761 | GNUNET_YES, | 760 | GNUNET_YES, |
762 | &tl); | 761 | &tl); |
@@ -770,7 +769,6 @@ wire_transfer_information_cb ( | |||
770 | return; | 769 | return; |
771 | } | 770 | } |
772 | qs = TALER_ARL_edb->get_known_coin (TALER_ARL_edb->cls, | 771 | qs = TALER_ARL_edb->get_known_coin (TALER_ARL_edb->cls, |
773 | TALER_ARL_esession, | ||
774 | coin_pub, | 772 | coin_pub, |
775 | &coin); | 773 | &coin); |
776 | if (qs <= 0) | 774 | if (qs <= 0) |
@@ -946,7 +944,6 @@ get_wire_fee (struct AggregationContext *ac, | |||
946 | wfi = GNUNET_new (struct WireFeeInfo); | 944 | wfi = GNUNET_new (struct WireFeeInfo); |
947 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != | 945 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != |
948 | TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, | 946 | TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, |
949 | TALER_ARL_esession, | ||
950 | method, | 947 | method, |
951 | timestamp, | 948 | timestamp, |
952 | &wfi->start_date, | 949 | &wfi->start_date, |
@@ -1083,7 +1080,6 @@ check_wire_out_cb (void *cls, | |||
1083 | return GNUNET_SYSERR; | 1080 | return GNUNET_SYSERR; |
1084 | } | 1081 | } |
1085 | qs = TALER_ARL_edb->lookup_wire_transfer (TALER_ARL_edb->cls, | 1082 | qs = TALER_ARL_edb->lookup_wire_transfer (TALER_ARL_edb->cls, |
1086 | TALER_ARL_esession, | ||
1087 | wtid, | 1083 | wtid, |
1088 | &wire_transfer_information_cb, | 1084 | &wire_transfer_information_cb, |
1089 | &wcc); | 1085 | &wcc); |
@@ -1258,7 +1254,6 @@ analyze_aggregations (void *cls) | |||
1258 | ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; | 1254 | ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; |
1259 | qs = TALER_ARL_edb->select_wire_out_above_serial_id ( | 1255 | qs = TALER_ARL_edb->select_wire_out_above_serial_id ( |
1260 | TALER_ARL_edb->cls, | 1256 | TALER_ARL_edb->cls, |
1261 | TALER_ARL_esession, | ||
1262 | ppa.last_wire_out_serial_id, | 1257 | ppa.last_wire_out_serial_id, |
1263 | &check_wire_out_cb, | 1258 | &check_wire_out_cb, |
1264 | &ac); | 1259 | &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, | |||
476 | int have_refund; | 476 | int have_refund; |
477 | 477 | ||
478 | qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls, | 478 | qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls, |
479 | TALER_ARL_esession, | ||
480 | coin_pub, | 479 | coin_pub, |
481 | GNUNET_YES, | 480 | GNUNET_YES, |
482 | &tl); | 481 | &tl); |
@@ -717,7 +716,6 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, | |||
717 | TALER_amount2s (&ds->denom_balance), | 716 | TALER_amount2s (&ds->denom_balance), |
718 | (unsigned long long) ds->num_issued); | 717 | (unsigned long long) ds->num_issued); |
719 | qs = TALER_ARL_edb->get_denomination_revocation (TALER_ARL_edb->cls, | 718 | qs = TALER_ARL_edb->get_denomination_revocation (TALER_ARL_edb->cls, |
720 | TALER_ARL_esession, | ||
721 | denom_hash, | 719 | denom_hash, |
722 | &msig, | 720 | &msig, |
723 | &rowid); | 721 | &rowid); |
@@ -878,7 +876,6 @@ sync_denomination (void *cls, | |||
878 | TALER_amount2s (&ds->denom_balance), | 876 | TALER_amount2s (&ds->denom_balance), |
879 | (unsigned long long) ds->num_issued); | 877 | (unsigned long long) ds->num_issued); |
880 | cnt = TALER_ARL_edb->count_known_coins (TALER_ARL_edb->cls, | 878 | cnt = TALER_ARL_edb->count_known_coins (TALER_ARL_edb->cls, |
881 | TALER_ARL_esession, | ||
882 | denom_hash); | 879 | denom_hash); |
883 | if (0 > cnt) | 880 | if (0 > cnt) |
884 | { | 881 | { |
@@ -1187,7 +1184,6 @@ check_known_coin (const char *operation, | |||
1187 | "Checking denomination signature on %s\n", | 1184 | "Checking denomination signature on %s\n", |
1188 | TALER_B2S (coin_pub)); | 1185 | TALER_B2S (coin_pub)); |
1189 | qs = TALER_ARL_edb->get_known_coin (TALER_ARL_edb->cls, | 1186 | qs = TALER_ARL_edb->get_known_coin (TALER_ARL_edb->cls, |
1190 | TALER_ARL_esession, | ||
1191 | coin_pub, | 1187 | coin_pub, |
1192 | &ci); | 1188 | &ci); |
1193 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | 1189 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) |
@@ -1336,7 +1332,6 @@ refresh_session_cb (void *cls, | |||
1336 | }; | 1332 | }; |
1337 | 1333 | ||
1338 | qs = TALER_ARL_edb->get_refresh_reveal (TALER_ARL_edb->cls, | 1334 | qs = TALER_ARL_edb->get_refresh_reveal (TALER_ARL_edb->cls, |
1339 | TALER_ARL_esession, | ||
1340 | rc, | 1335 | rc, |
1341 | &reveal_data_cb, | 1336 | &reveal_data_cb, |
1342 | &reveal_ctx); | 1337 | &reveal_ctx); |
@@ -2250,7 +2245,6 @@ check_denomination ( | |||
2250 | struct TALER_AuditorSignatureP auditor_sig; | 2245 | struct TALER_AuditorSignatureP auditor_sig; |
2251 | 2246 | ||
2252 | qs = TALER_ARL_edb->select_auditor_denom_sig (TALER_ARL_edb->cls, | 2247 | qs = TALER_ARL_edb->select_auditor_denom_sig (TALER_ARL_edb->cls, |
2253 | TALER_ARL_esession, | ||
2254 | &issue->denom_hash, | 2248 | &issue->denom_hash, |
2255 | &TALER_ARL_auditor_pub, | 2249 | &TALER_ARL_auditor_pub, |
2256 | &auditor_sig); | 2250 | &auditor_sig); |
@@ -2329,7 +2323,6 @@ analyze_coins (void *cls) | |||
2329 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2330 | "Checking denominations...\n"); | 2324 | "Checking denominations...\n"); |
2331 | qs = TALER_ARL_edb->iterate_denomination_info (TALER_ARL_edb->cls, | 2325 | qs = TALER_ARL_edb->iterate_denomination_info (TALER_ARL_edb->cls, |
2332 | TALER_ARL_esession, | ||
2333 | &check_denomination, | 2326 | &check_denomination, |
2334 | NULL); | 2327 | NULL); |
2335 | if (0 > qs) | 2328 | if (0 > qs) |
@@ -2389,7 +2382,6 @@ analyze_coins (void *cls) | |||
2389 | if (0 > | 2382 | if (0 > |
2390 | (qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( | 2383 | (qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( |
2391 | TALER_ARL_edb->cls, | 2384 | TALER_ARL_edb->cls, |
2392 | TALER_ARL_esession, | ||
2393 | ppc.last_withdraw_serial_id, | 2385 | ppc.last_withdraw_serial_id, |
2394 | &withdraw_cb, | 2386 | &withdraw_cb, |
2395 | &cc)) ) | 2387 | &cc)) ) |
@@ -2404,7 +2396,6 @@ analyze_coins (void *cls) | |||
2404 | if (0 > | 2396 | if (0 > |
2405 | (qs = TALER_ARL_edb->select_refunds_above_serial_id ( | 2397 | (qs = TALER_ARL_edb->select_refunds_above_serial_id ( |
2406 | TALER_ARL_edb->cls, | 2398 | TALER_ARL_edb->cls, |
2407 | TALER_ARL_esession, | ||
2408 | ppc.last_refund_serial_id, | 2399 | ppc.last_refund_serial_id, |
2409 | &refund_cb, | 2400 | &refund_cb, |
2410 | &cc))) | 2401 | &cc))) |
@@ -2419,7 +2410,6 @@ analyze_coins (void *cls) | |||
2419 | if (0 > | 2410 | if (0 > |
2420 | (qs = TALER_ARL_edb->select_recoup_refresh_above_serial_id ( | 2411 | (qs = TALER_ARL_edb->select_recoup_refresh_above_serial_id ( |
2421 | TALER_ARL_edb->cls, | 2412 | TALER_ARL_edb->cls, |
2422 | TALER_ARL_esession, | ||
2423 | ppc.last_recoup_refresh_serial_id, | 2413 | ppc.last_recoup_refresh_serial_id, |
2424 | &recoup_refresh_cb, | 2414 | &recoup_refresh_cb, |
2425 | &cc))) | 2415 | &cc))) |
@@ -2432,7 +2422,6 @@ analyze_coins (void *cls) | |||
2432 | if (0 > | 2422 | if (0 > |
2433 | (qs = TALER_ARL_edb->select_recoup_above_serial_id ( | 2423 | (qs = TALER_ARL_edb->select_recoup_above_serial_id ( |
2434 | TALER_ARL_edb->cls, | 2424 | TALER_ARL_edb->cls, |
2435 | TALER_ARL_esession, | ||
2436 | ppc.last_recoup_serial_id, | 2425 | ppc.last_recoup_serial_id, |
2437 | &recoup_cb, | 2426 | &recoup_cb, |
2438 | &cc))) | 2427 | &cc))) |
@@ -2447,7 +2436,6 @@ analyze_coins (void *cls) | |||
2447 | if (0 > | 2436 | if (0 > |
2448 | (qs = TALER_ARL_edb->select_refreshes_above_serial_id ( | 2437 | (qs = TALER_ARL_edb->select_refreshes_above_serial_id ( |
2449 | TALER_ARL_edb->cls, | 2438 | TALER_ARL_edb->cls, |
2450 | TALER_ARL_esession, | ||
2451 | ppc.last_melt_serial_id, | 2439 | ppc.last_melt_serial_id, |
2452 | &refresh_session_cb, | 2440 | &refresh_session_cb, |
2453 | &cc))) | 2441 | &cc))) |
@@ -2462,7 +2450,6 @@ analyze_coins (void *cls) | |||
2462 | if (0 > | 2450 | if (0 > |
2463 | (qs = TALER_ARL_edb->select_deposits_above_serial_id ( | 2451 | (qs = TALER_ARL_edb->select_deposits_above_serial_id ( |
2464 | TALER_ARL_edb->cls, | 2452 | TALER_ARL_edb->cls, |
2465 | TALER_ARL_esession, | ||
2466 | ppc.last_deposit_serial_id, | 2453 | ppc.last_deposit_serial_id, |
2467 | &deposit_cb, | 2454 | &deposit_cb, |
2468 | &cc))) | 2455 | &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, | |||
123 | struct TALER_Amount deposit_fee; | 123 | struct TALER_Amount deposit_fee; |
124 | 124 | ||
125 | qs = TALER_ARL_edb->have_deposit (TALER_ARL_edb->cls, | 125 | qs = TALER_ARL_edb->have_deposit (TALER_ARL_edb->cls, |
126 | TALER_ARL_esession, | ||
127 | &dep, | 126 | &dep, |
128 | GNUNET_NO /* do not check refund deadline */, | 127 | GNUNET_NO /* do not check refund deadline */, |
129 | &deposit_fee, | 128 | &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 ( | |||
744 | if (NULL == rev) | 744 | if (NULL == rev) |
745 | { | 745 | { |
746 | qs = TALER_ARL_edb->get_denomination_revocation (TALER_ARL_edb->cls, | 746 | qs = TALER_ARL_edb->get_denomination_revocation (TALER_ARL_edb->cls, |
747 | TALER_ARL_esession, | ||
748 | &coin->denom_pub_hash, | 747 | &coin->denom_pub_hash, |
749 | &msig, | 748 | &msig, |
750 | &rev_rowid); | 749 | &rev_rowid); |
@@ -882,7 +881,6 @@ get_closing_fee (const char *receiver_account, | |||
882 | method); | 881 | method); |
883 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != | 882 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != |
884 | TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, | 883 | TALER_ARL_edb->get_wire_fee (TALER_ARL_edb->cls, |
885 | TALER_ARL_esession, | ||
886 | method, | 884 | method, |
887 | atime, | 885 | atime, |
888 | &start_date, | 886 | &start_date, |
@@ -1089,7 +1087,6 @@ verify_reserve_balance (void *cls, | |||
1089 | 1087 | ||
1090 | reserve.pub = rs->reserve_pub; | 1088 | reserve.pub = rs->reserve_pub; |
1091 | qs = TALER_ARL_edb->reserves_get (TALER_ARL_edb->cls, | 1089 | qs = TALER_ARL_edb->reserves_get (TALER_ARL_edb->cls, |
1092 | TALER_ARL_esession, | ||
1093 | &reserve); | 1090 | &reserve); |
1094 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | 1091 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) |
1095 | { | 1092 | { |
@@ -1377,7 +1374,6 @@ analyze_reserves (void *cls) | |||
1377 | 1374 | ||
1378 | qs = TALER_ARL_edb->select_reserves_in_above_serial_id ( | 1375 | qs = TALER_ARL_edb->select_reserves_in_above_serial_id ( |
1379 | TALER_ARL_edb->cls, | 1376 | TALER_ARL_edb->cls, |
1380 | TALER_ARL_esession, | ||
1381 | ppr.last_reserve_in_serial_id, | 1377 | ppr.last_reserve_in_serial_id, |
1382 | &handle_reserve_in, | 1378 | &handle_reserve_in, |
1383 | &rc); | 1379 | &rc); |
@@ -1388,7 +1384,6 @@ analyze_reserves (void *cls) | |||
1388 | } | 1384 | } |
1389 | qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( | 1385 | qs = TALER_ARL_edb->select_withdrawals_above_serial_id ( |
1390 | TALER_ARL_edb->cls, | 1386 | TALER_ARL_edb->cls, |
1391 | TALER_ARL_esession, | ||
1392 | ppr.last_reserve_out_serial_id, | 1387 | ppr.last_reserve_out_serial_id, |
1393 | &handle_reserve_out, | 1388 | &handle_reserve_out, |
1394 | &rc); | 1389 | &rc); |
@@ -1399,7 +1394,6 @@ analyze_reserves (void *cls) | |||
1399 | } | 1394 | } |
1400 | qs = TALER_ARL_edb->select_recoup_above_serial_id ( | 1395 | qs = TALER_ARL_edb->select_recoup_above_serial_id ( |
1401 | TALER_ARL_edb->cls, | 1396 | TALER_ARL_edb->cls, |
1402 | TALER_ARL_esession, | ||
1403 | ppr.last_reserve_recoup_serial_id, | 1397 | ppr.last_reserve_recoup_serial_id, |
1404 | &handle_recoup_by_reserve, | 1398 | &handle_recoup_by_reserve, |
1405 | &rc); | 1399 | &rc); |
@@ -1410,7 +1404,6 @@ analyze_reserves (void *cls) | |||
1410 | } | 1404 | } |
1411 | qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( | 1405 | qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( |
1412 | TALER_ARL_edb->cls, | 1406 | TALER_ARL_edb->cls, |
1413 | TALER_ARL_esession, | ||
1414 | ppr.last_reserve_close_serial_id, | 1407 | ppr.last_reserve_close_serial_id, |
1415 | &handle_reserve_closed, | 1408 | &handle_reserve_closed, |
1416 | &rc); | 1409 | &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) | |||
665 | "Hard error, not recording progress\n"); | 665 | "Hard error, not recording progress\n"); |
666 | TALER_ARL_adb->rollback (TALER_ARL_adb->cls, | 666 | TALER_ARL_adb->rollback (TALER_ARL_adb->cls, |
667 | TALER_ARL_asession); | 667 | TALER_ARL_asession); |
668 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls, | 668 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls); |
669 | TALER_ARL_esession); | ||
670 | return qs; | 669 | return qs; |
671 | } | 670 | } |
672 | for (struct WireAccount *wa = wa_head; | 671 | for (struct WireAccount *wa = wa_head; |
@@ -741,8 +740,7 @@ commit (enum GNUNET_DB_QueryStatus qs) | |||
741 | 740 | ||
742 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) | 741 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) |
743 | { | 742 | { |
744 | qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls, | 743 | qs = TALER_ARL_edb->commit (TALER_ARL_edb->cls); |
745 | TALER_ARL_esession); | ||
746 | if (0 > qs) | 744 | if (0 > qs) |
747 | { | 745 | { |
748 | GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); | 746 | GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); |
@@ -769,8 +767,7 @@ commit (enum GNUNET_DB_QueryStatus qs) | |||
769 | "Processing failed, rolling back transaction\n"); | 767 | "Processing failed, rolling back transaction\n"); |
770 | TALER_ARL_adb->rollback (TALER_ARL_adb->cls, | 768 | TALER_ARL_adb->rollback (TALER_ARL_adb->cls, |
771 | TALER_ARL_asession); | 769 | TALER_ARL_asession); |
772 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls, | 770 | TALER_ARL_edb->rollback (TALER_ARL_edb->cls); |
773 | TALER_ARL_esession); | ||
774 | } | 771 | } |
775 | return qs; | 772 | return qs; |
776 | } | 773 | } |
@@ -870,7 +867,6 @@ check_for_required_transfers (void) | |||
870 | "Analyzing exchange's unfinished deposits (deadline: %s)\n", | 867 | "Analyzing exchange's unfinished deposits (deadline: %s)\n", |
871 | GNUNET_STRINGS_absolute_time_to_string (next_timestamp)); | 868 | GNUNET_STRINGS_absolute_time_to_string (next_timestamp)); |
872 | qs = TALER_ARL_edb->select_deposits_missing_wire (TALER_ARL_edb->cls, | 869 | qs = TALER_ARL_edb->select_deposits_missing_wire (TALER_ARL_edb->cls, |
873 | TALER_ARL_esession, | ||
874 | pp.last_timestamp, | 870 | pp.last_timestamp, |
875 | next_timestamp, | 871 | next_timestamp, |
876 | &wire_missing_cb, | 872 | &wire_missing_cb, |
@@ -1267,7 +1263,6 @@ check_exchange_wire_out (struct WireAccount *wa) | |||
1267 | wa->ai->section_name); | 1263 | wa->ai->section_name); |
1268 | qs = TALER_ARL_edb->select_wire_out_above_serial_id_by_account ( | 1264 | qs = TALER_ARL_edb->select_wire_out_above_serial_id_by_account ( |
1269 | TALER_ARL_edb->cls, | 1265 | TALER_ARL_edb->cls, |
1270 | TALER_ARL_esession, | ||
1271 | wa->ai->section_name, | 1266 | wa->ai->section_name, |
1272 | wa->pp.last_wire_out_serial_id, | 1267 | wa->pp.last_wire_out_serial_id, |
1273 | &wire_out_cb, | 1268 | &wire_out_cb, |
@@ -1824,7 +1819,6 @@ process_credits (void *cls) | |||
1824 | wa->ai->section_name); | 1819 | wa->ai->section_name); |
1825 | qs = TALER_ARL_edb->select_reserves_in_above_serial_id_by_account ( | 1820 | qs = TALER_ARL_edb->select_reserves_in_above_serial_id_by_account ( |
1826 | TALER_ARL_edb->cls, | 1821 | TALER_ARL_edb->cls, |
1827 | TALER_ARL_esession, | ||
1828 | wa->ai->section_name, | 1822 | wa->ai->section_name, |
1829 | wa->pp.last_reserve_in_serial_id, | 1823 | wa->pp.last_reserve_in_serial_id, |
1830 | &reserve_in_cb, | 1824 | &reserve_in_cb, |
@@ -1953,11 +1947,11 @@ reserve_closed_cb (void *cls, | |||
1953 | static enum GNUNET_DB_QueryStatus | 1947 | static enum GNUNET_DB_QueryStatus |
1954 | begin_transaction (void) | 1948 | begin_transaction (void) |
1955 | { | 1949 | { |
1956 | TALER_ARL_esession = TALER_ARL_edb->get_session (TALER_ARL_edb->cls); | 1950 | if (GNUNET_OK != |
1957 | if (NULL == TALER_ARL_esession) | 1951 | TALER_ARL_edb->preflight (TALER_ARL_edb->cls)) |
1958 | { | 1952 | { |
1959 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1953 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1960 | "Failed to initialize exchange database session.\n"); | 1954 | "Failed to initialize exchange database connection.\n"); |
1961 | return GNUNET_DB_STATUS_HARD_ERROR; | 1955 | return GNUNET_DB_STATUS_HARD_ERROR; |
1962 | } | 1956 | } |
1963 | TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); | 1957 | TALER_ARL_asession = TALER_ARL_adb->get_session (TALER_ARL_adb->cls); |
@@ -1974,11 +1968,9 @@ begin_transaction (void) | |||
1974 | GNUNET_break (0); | 1968 | GNUNET_break (0); |
1975 | return GNUNET_DB_STATUS_HARD_ERROR; | 1969 | return GNUNET_DB_STATUS_HARD_ERROR; |
1976 | } | 1970 | } |
1977 | TALER_ARL_edb->preflight (TALER_ARL_edb->cls, | 1971 | TALER_ARL_edb->preflight (TALER_ARL_edb->cls); |
1978 | TALER_ARL_esession); | ||
1979 | if (GNUNET_OK != | 1972 | if (GNUNET_OK != |
1980 | TALER_ARL_edb->start (TALER_ARL_edb->cls, | 1973 | TALER_ARL_edb->start (TALER_ARL_edb->cls, |
1981 | TALER_ARL_esession, | ||
1982 | "wire auditor")) | 1974 | "wire auditor")) |
1983 | { | 1975 | { |
1984 | GNUNET_break (0); | 1976 | GNUNET_break (0); |
@@ -2031,7 +2023,6 @@ begin_transaction (void) | |||
2031 | 2023 | ||
2032 | qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( | 2024 | qs = TALER_ARL_edb->select_reserve_closed_above_serial_id ( |
2033 | TALER_ARL_edb->cls, | 2025 | TALER_ARL_edb->cls, |
2034 | TALER_ARL_esession, | ||
2035 | pp.last_reserve_close_uuid, | 2026 | pp.last_reserve_close_uuid, |
2036 | &reserve_closed_cb, | 2027 | &reserve_closed_cb, |
2037 | NULL); | 2028 | NULL); |
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index 96d568f68..d1a05297d 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c | |||
@@ -226,7 +226,6 @@ TALER_BANK_admin_add_incoming ( | |||
226 | { | 226 | { |
227 | GNUNET_free (aai); | 227 | GNUNET_free (aai); |
228 | json_decref (admin_obj); | 228 | json_decref (admin_obj); |
229 | GNUNET_break (0); | ||
230 | return NULL; | 229 | return NULL; |
231 | } | 230 | } |
232 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 231 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index 4c1f26dfc..1f53b0123 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am | |||
@@ -84,7 +84,6 @@ taler_exchange_httpd_SOURCES = \ | |||
84 | taler-exchange-httpd_deposits_get.c taler-exchange-httpd_deposits_get.h \ | 84 | taler-exchange-httpd_deposits_get.c taler-exchange-httpd_deposits_get.h \ |
85 | taler-exchange-httpd_keys.c taler-exchange-httpd_keys.h \ | 85 | taler-exchange-httpd_keys.c taler-exchange-httpd_keys.h \ |
86 | taler-exchange-httpd_link.c taler-exchange-httpd_link.h \ | 86 | taler-exchange-httpd_link.c taler-exchange-httpd_link.h \ |
87 | taler-exchange-httpd_loop.c taler-exchange-httpd_loop.h \ | ||
88 | taler-exchange-httpd_management.h \ | 87 | taler-exchange-httpd_management.h \ |
89 | taler-exchange-httpd_management_auditors.c \ | 88 | taler-exchange-httpd_management_auditors.c \ |
90 | taler-exchange-httpd_management_auditors_AP_disable.c \ | 89 | taler-exchange-httpd_management_auditors_AP_disable.c \ |
@@ -122,7 +121,6 @@ taler_exchange_httpd_LDADD = \ | |||
122 | -lgnunetjson \ | 121 | -lgnunetjson \ |
123 | -ljansson \ | 122 | -ljansson \ |
124 | -lz \ | 123 | -lz \ |
125 | -lpthread \ | ||
126 | $(XLIB) | 124 | $(XLIB) |
127 | 125 | ||
128 | # Testcases | 126 | # Testcases |
@@ -130,8 +128,7 @@ taler_exchange_httpd_LDADD = \ | |||
130 | AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; | 128 | AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; |
131 | 129 | ||
132 | check_SCRIPTS = \ | 130 | check_SCRIPTS = \ |
133 | test_taler_exchange_httpd.sh \ | 131 | test_taler_exchange_httpd.sh |
134 | test_taler_exchange_httpd_restart.sh | ||
135 | if HAVE_EXPENSIVE_TESTS | 132 | if HAVE_EXPENSIVE_TESTS |
136 | check_SCRIPTS += \ | 133 | check_SCRIPTS += \ |
137 | test_taler_exchange_httpd_afl.sh | 134 | test_taler_exchange_httpd_afl.sh |
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 5da0a8094..c82b66669 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c | |||
@@ -90,11 +90,6 @@ struct AggregationUnit | |||
90 | const struct TALER_EXCHANGEDB_AccountInfo *wa; | 90 | const struct TALER_EXCHANGEDB_AccountInfo *wa; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Database session for all of our transactions. | ||
94 | */ | ||
95 | struct TALER_EXCHANGEDB_Session *session; | ||
96 | |||
97 | /** | ||
98 | * Array of row_ids from the aggregation. | 93 | * Array of row_ids from the aggregation. |
99 | */ | 94 | */ |
100 | uint64_t additional_rows[TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT]; | 95 | uint64_t additional_rows[TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT]; |
@@ -355,7 +350,6 @@ deposit_cb (void *cls, | |||
355 | au->total_amount = *amount_with_fee; | 350 | au->total_amount = *amount_with_fee; |
356 | au->have_refund = GNUNET_NO; | 351 | au->have_refund = GNUNET_NO; |
357 | qs = db_plugin->select_refunds_by_coin (db_plugin->cls, | 352 | qs = db_plugin->select_refunds_by_coin (db_plugin->cls, |
358 | au->session, | ||
359 | coin_pub, | 353 | coin_pub, |
360 | &au->merchant_pub, | 354 | &au->merchant_pub, |
361 | h_contract_terms, | 355 | h_contract_terms, |
@@ -444,7 +438,6 @@ deposit_cb (void *cls, | |||
444 | enum GNUNET_DB_QueryStatus qs; | 438 | enum GNUNET_DB_QueryStatus qs; |
445 | 439 | ||
446 | qs = db_plugin->get_wire_fee (db_plugin->cls, | 440 | qs = db_plugin->get_wire_fee (db_plugin->cls, |
447 | au->session, | ||
448 | au->wa->method, | 441 | au->wa->method, |
449 | au->execution_time, | 442 | au->execution_time, |
450 | &start_date, | 443 | &start_date, |
@@ -468,7 +461,6 @@ deposit_cb (void *cls, | |||
468 | TALER_B2S (&au->wtid), | 461 | TALER_B2S (&au->wtid), |
469 | TALER_amount2s (&au->wire_fee)); | 462 | TALER_amount2s (&au->wire_fee)); |
470 | qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, | 463 | qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, |
471 | au->session, | ||
472 | &au->wtid, | 464 | &au->wtid, |
473 | row_id); | 465 | row_id); |
474 | if (qs <= 0) | 466 | if (qs <= 0) |
@@ -480,7 +472,6 @@ deposit_cb (void *cls, | |||
480 | "Aggregator marks deposit %llu as done\n", | 472 | "Aggregator marks deposit %llu as done\n", |
481 | (unsigned long long) row_id); | 473 | (unsigned long long) row_id); |
482 | qs = db_plugin->mark_deposit_done (db_plugin->cls, | 474 | qs = db_plugin->mark_deposit_done (db_plugin->cls, |
483 | au->session, | ||
484 | row_id); | 475 | row_id); |
485 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | 476 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) |
486 | { | 477 | { |
@@ -535,7 +526,6 @@ aggregate_cb (void *cls, | |||
535 | /* compute contribution of this coin (after fees) */ | 526 | /* compute contribution of this coin (after fees) */ |
536 | au->have_refund = GNUNET_NO; | 527 | au->have_refund = GNUNET_NO; |
537 | qs = db_plugin->select_refunds_by_coin (db_plugin->cls, | 528 | qs = db_plugin->select_refunds_by_coin (db_plugin->cls, |
538 | au->session, | ||
539 | coin_pub, | 529 | coin_pub, |
540 | &au->merchant_pub, | 530 | &au->merchant_pub, |
541 | h_contract_terms, | 531 | h_contract_terms, |
@@ -596,7 +586,6 @@ aggregate_cb (void *cls, | |||
596 | au->additional_rows[au->rows_offset++] = row_id; | 586 | au->additional_rows[au->rows_offset++] = row_id; |
597 | /* insert into aggregation tracking table */ | 587 | /* insert into aggregation tracking table */ |
598 | qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, | 588 | qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, |
599 | au->session, | ||
600 | &au->wtid, | 589 | &au->wtid, |
601 | row_id); | 590 | row_id); |
602 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | 591 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) |
@@ -605,7 +594,6 @@ aggregate_cb (void *cls, | |||
605 | return qs; | 594 | return qs; |
606 | } | 595 | } |
607 | qs = db_plugin->mark_deposit_done (db_plugin->cls, | 596 | qs = db_plugin->mark_deposit_done (db_plugin->cls, |
608 | au->session, | ||
609 | row_id); | 597 | row_id); |
610 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | 598 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) |
611 | { | 599 | { |
@@ -622,16 +610,14 @@ aggregate_cb (void *cls, | |||
622 | /** | 610 | /** |
623 | * Perform a database commit. If it fails, print a warning. | 611 | * Perform a database commit. If it fails, print a warning. |
624 | * | 612 | * |
625 | * @param session session to perform the commit for. | ||
626 | * @return status of commit | 613 | * @return status of commit |
627 | */ | 614 | */ |
628 | static enum GNUNET_DB_QueryStatus | 615 | static enum GNUNET_DB_QueryStatus |
629 | commit_or_warn (struct TALER_EXCHANGEDB_Session *session) | 616 | commit_or_warn (void) |
630 | { | 617 | { |
631 | enum GNUNET_DB_QueryStatus qs; | 618 | enum GNUNET_DB_QueryStatus qs; |
632 | 619 | ||
633 | qs = db_plugin->commit (db_plugin->cls, | 620 | qs = db_plugin->commit (db_plugin->cls); |
634 | session); | ||
635 | if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) | 621 | if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) |
636 | return qs; | 622 | return qs; |
637 | GNUNET_log ((GNUNET_DB_STATUS_SOFT_ERROR == qs) | 623 | GNUNET_log ((GNUNET_DB_STATUS_SOFT_ERROR == qs) |
@@ -652,24 +638,23 @@ static void | |||
652 | run_aggregation (void *cls) | 638 | run_aggregation (void *cls) |
653 | { | 639 | { |
654 | struct AggregationUnit au_active; | 640 | struct AggregationUnit au_active; |
655 | struct TALER_EXCHANGEDB_Session *session; | ||
656 | enum GNUNET_DB_QueryStatus qs; | 641 | enum GNUNET_DB_QueryStatus qs; |
657 | 642 | ||
658 | (void) cls; | 643 | (void) cls; |
659 | task = NULL; | 644 | task = NULL; |
660 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 645 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
661 | "Checking for ready deposits to aggregate\n"); | 646 | "Checking for ready deposits to aggregate\n"); |
662 | if (NULL == (session = db_plugin->get_session (db_plugin->cls))) | 647 | if (GNUNET_SYSERR == |
648 | db_plugin->preflight (db_plugin->cls)) | ||
663 | { | 649 | { |
664 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 650 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
665 | "Failed to obtain database session!\n"); | 651 | "Failed to obtain database connection!\n"); |
666 | global_ret = EXIT_FAILURE; | 652 | global_ret = EXIT_FAILURE; |
667 | GNUNET_SCHEDULER_shutdown (); | 653 | GNUNET_SCHEDULER_shutdown (); |
668 | return; | 654 | return; |
669 | } | 655 | } |
670 | if (GNUNET_OK != | 656 | if (GNUNET_OK != |
671 | db_plugin->start_deferred_wire_out (db_plugin->cls, | 657 | db_plugin->start_deferred_wire_out (db_plugin->cls)) |
672 | session)) | ||
673 | { | 658 | { |
674 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 659 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
675 | "Failed to start database transaction!\n"); | 660 | "Failed to start database transaction!\n"); |
@@ -680,16 +665,13 @@ run_aggregation (void *cls) | |||
680 | memset (&au_active, | 665 | memset (&au_active, |
681 | 0, | 666 | 0, |
682 | sizeof (au_active)); | 667 | sizeof (au_active)); |
683 | au_active.session = session; | ||
684 | qs = db_plugin->get_ready_deposit (db_plugin->cls, | 668 | qs = db_plugin->get_ready_deposit (db_plugin->cls, |
685 | session, | ||
686 | &deposit_cb, | 669 | &deposit_cb, |
687 | &au_active); | 670 | &au_active); |
688 | if (0 >= qs) | 671 | if (0 >= qs) |
689 | { | 672 | { |
690 | cleanup_au (&au_active); | 673 | cleanup_au (&au_active); |
691 | db_plugin->rollback (db_plugin->cls, | 674 | db_plugin->rollback (db_plugin->cls); |
692 | session); | ||
693 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | 675 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) |
694 | { | 676 | { |
695 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 677 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -729,7 +711,6 @@ run_aggregation (void *cls) | |||
729 | "Found ready deposit for %s, aggregating\n", | 711 | "Found ready deposit for %s, aggregating\n", |
730 | TALER_B2S (&au_active.merchant_pub)); | 712 | TALER_B2S (&au_active.merchant_pub)); |
731 | qs = db_plugin->iterate_matching_deposits (db_plugin->cls, | 713 | qs = db_plugin->iterate_matching_deposits (db_plugin->cls, |
732 | session, | ||
733 | &au_active.h_wire, | 714 | &au_active.h_wire, |
734 | &au_active.merchant_pub, | 715 | &au_active.merchant_pub, |
735 | &aggregate_cb, | 716 | &aggregate_cb, |
@@ -741,8 +722,7 @@ run_aggregation (void *cls) | |||
741 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 722 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
742 | "Failed to execute deposit iteration!\n"); | 723 | "Failed to execute deposit iteration!\n"); |
743 | cleanup_au (&au_active); | 724 | cleanup_au (&au_active); |
744 | db_plugin->rollback (db_plugin->cls, | 725 | db_plugin->rollback (db_plugin->cls); |
745 | session); | ||
746 | global_ret = EXIT_FAILURE; | 726 | global_ret = EXIT_FAILURE; |
747 | GNUNET_SCHEDULER_shutdown (); | 727 | GNUNET_SCHEDULER_shutdown (); |
748 | return; | 728 | return; |
@@ -752,8 +732,7 @@ run_aggregation (void *cls) | |||
752 | /* serializiability issue, try again */ | 732 | /* serializiability issue, try again */ |
753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 733 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
754 | "Serialization issue, trying again later!\n"); | 734 | "Serialization issue, trying again later!\n"); |
755 | db_plugin->rollback (db_plugin->cls, | 735 | db_plugin->rollback (db_plugin->cls); |
756 | session); | ||
757 | cleanup_au (&au_active); | 736 | cleanup_au (&au_active); |
758 | GNUNET_assert (NULL == task); | 737 | GNUNET_assert (NULL == task); |
759 | task = GNUNET_SCHEDULER_add_now (&run_aggregation, | 738 | task = GNUNET_SCHEDULER_add_now (&run_aggregation, |
@@ -780,14 +759,12 @@ run_aggregation (void *cls) | |||
780 | TALER_amount2s (&au_active.final_amount)); | 759 | TALER_amount2s (&au_active.final_amount)); |
781 | /* Rollback ongoing transaction, as we will not use the respective | 760 | /* Rollback ongoing transaction, as we will not use the respective |
782 | WTID and thus need to remove the tracking data */ | 761 | WTID and thus need to remove the tracking data */ |
783 | db_plugin->rollback (db_plugin->cls, | 762 | db_plugin->rollback (db_plugin->cls); |
784 | session); | ||
785 | 763 | ||
786 | /* There were results, just the value was too low. Start another | 764 | /* There were results, just the value was too low. Start another |
787 | transaction to mark all* of the selected deposits as minor! */ | 765 | transaction to mark all* of the selected deposits as minor! */ |
788 | if (GNUNET_OK != | 766 | if (GNUNET_OK != |
789 | db_plugin->start (db_plugin->cls, | 767 | db_plugin->start (db_plugin->cls, |
790 | session, | ||
791 | "aggregator mark tiny transactions")) | 768 | "aggregator mark tiny transactions")) |
792 | { | 769 | { |
793 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 770 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -799,14 +776,12 @@ run_aggregation (void *cls) | |||
799 | } | 776 | } |
800 | /* Mark transactions by row_id as minor */ | 777 | /* Mark transactions by row_id as minor */ |
801 | qs = db_plugin->mark_deposit_tiny (db_plugin->cls, | 778 | qs = db_plugin->mark_deposit_tiny (db_plugin->cls, |
802 | session, | ||
803 | au_active.row_id); | 779 | au_active.row_id); |
804 | if (0 <= qs) | 780 | if (0 <= qs) |
805 | { | 781 | { |
806 | for (unsigned int i = 0; i<au_active.rows_offset; i++) | 782 | for (unsigned int i = 0; i<au_active.rows_offset; i++) |
807 | { | 783 | { |
808 | qs = db_plugin->mark_deposit_tiny (db_plugin->cls, | 784 | qs = db_plugin->mark_deposit_tiny (db_plugin->cls, |
809 | session, | ||
810 | au_active.additional_rows[i]); | 785 | au_active.additional_rows[i]); |
811 | if (0 > qs) | 786 | if (0 > qs) |
812 | break; | 787 | break; |
@@ -816,8 +791,7 @@ run_aggregation (void *cls) | |||
816 | { | 791 | { |
817 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 792 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
818 | "Serialization issue, trying again later!\n"); | 793 | "Serialization issue, trying again later!\n"); |
819 | db_plugin->rollback (db_plugin->cls, | 794 | db_plugin->rollback (db_plugin->cls); |
820 | session); | ||
821 | cleanup_au (&au_active); | 795 | cleanup_au (&au_active); |
822 | /* start again */ | 796 | /* start again */ |
823 | GNUNET_assert (NULL == task); | 797 | GNUNET_assert (NULL == task); |
@@ -827,15 +801,14 @@ run_aggregation (void *cls) | |||
827 | } | 801 | } |
828 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | 802 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) |
829 | { | 803 | { |
830 | db_plugin->rollback (db_plugin->cls, | 804 | db_plugin->rollback (db_plugin->cls); |
831 | session); | ||
832 | cleanup_au (&au_active); | 805 | cleanup_au (&au_active); |
833 | global_ret = EXIT_FAILURE; | 806 | global_ret = EXIT_FAILURE; |
834 | GNUNET_SCHEDULER_shutdown (); | 807 | GNUNET_SCHEDULER_shutdown (); |
835 | return; | 808 | return; |
836 | } | 809 | } |
837 | /* commit */ | 810 | /* commit */ |
838 | (void) commit_or_warn (session); | 811 | (void) commit_or_warn (); |
839 | cleanup_au (&au_active); | 812 | cleanup_au (&au_active); |
840 | 813 | ||
841 | /* start again */ | 814 | /* start again */ |
@@ -877,7 +850,6 @@ run_aggregation (void *cls) | |||
877 | (unsigned int) buf_size); | 850 | (unsigned int) buf_size); |
878 | /* Commit our intention to execute the wire transfer! */ | 851 | /* Commit our intention to execute the wire transfer! */ |
879 | qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, | 852 | qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, |
880 | session, | ||
881 | au_active.wa->method, | 853 | au_active.wa->method, |
882 | buf, | 854 | buf, |
883 | buf_size); | 855 | buf_size); |
@@ -887,7 +859,6 @@ run_aggregation (void *cls) | |||
887 | table constraints */ | 859 | table constraints */ |
888 | if (qs >= 0) | 860 | if (qs >= 0) |
889 | qs = db_plugin->store_wire_transfer_out (db_plugin->cls, | 861 | qs = db_plugin->store_wire_transfer_out (db_plugin->cls, |
890 | session, | ||
891 | au_active.execution_time, | 862 | au_active.execution_time, |
892 | &au_active.wtid, | 863 | &au_active.wtid, |
893 | au_active.wire, | 864 | au_active.wire, |
@@ -899,8 +870,7 @@ run_aggregation (void *cls) | |||
899 | { | 870 | { |
900 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 871 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
901 | "Serialization issue for prepared wire data; trying again later!\n"); | 872 | "Serialization issue for prepared wire data; trying again later!\n"); |
902 | db_plugin->rollback (db_plugin->cls, | 873 | db_plugin->rollback (db_plugin->cls); |
903 | session); | ||
904 | /* start again */ | 874 | /* start again */ |
905 | GNUNET_assert (NULL == task); | 875 | GNUNET_assert (NULL == task); |
906 | task = GNUNET_SCHEDULER_add_now (&run_aggregation, | 876 | task = GNUNET_SCHEDULER_add_now (&run_aggregation, |
@@ -910,8 +880,7 @@ run_aggregation (void *cls) | |||
910 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | 880 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) |
911 | { | 881 | { |
912 | GNUNET_break (0); | 882 | GNUNET_break (0); |
913 | db_plugin->rollback (db_plugin->cls, | 883 | db_plugin->rollback (db_plugin->cls); |
914 | session); | ||
915 | /* die hard */ | 884 | /* die hard */ |
916 | global_ret = EXIT_FAILURE; | 885 | global_ret = EXIT_FAILURE; |
917 | GNUNET_SCHEDULER_shutdown (); | 886 | GNUNET_SCHEDULER_shutdown (); |
@@ -923,7 +892,7 @@ run_aggregation (void *cls) | |||
923 | 892 | ||
924 | /* Now we can finally commit the overall transaction, as we are | 893 | /* Now we can finally commit the overall transaction, as we are |
925 | again consistent if all of this passes. */ | 894 | again consistent if all of this passes. */ |
926 | switch (commit_or_warn (session)) | 895 | switch (commit_or_warn ()) |
927 | { | 896 | { |
928 | case GNUNET_DB_STATUS_SOFT_ERROR: | 897 | case GNUNET_DB_STATUS_SOFT_ERROR: |
929 | /* try again */ | 898 | /* try again */ |
diff --git a/src/exchange/taler-exchange-closer.c b/src/exchange/taler-exchange-closer.c index 89e439998..926c93554 100644 --- a/src/exchange/taler-exchange-closer.c +++ b/src/exchange/taler-exchange-closer.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2016-2020 Taler Systems SA | 3 | Copyright (C) 2016-2021 Taler Systems SA |
4 | 4 | ||
5 | TALER is free software; you can redistribute it and/or modify it under the | 5 | TALER is free software; you can redistribute it and/or modify it under the |
6 | terms of the GNU Affero General Public License as published by the Free Software | 6 | terms of the GNU Affero General Public License as published by the Free Software |
@@ -174,16 +174,14 @@ parse_wirewatch_config (void) | |||
174 | /** | 174 | /** |
175 | * Perform a database commit. If it fails, print a warning. | 175 | * Perform a database commit. If it fails, print a warning. |
176 | * | 176 | * |
177 | * @param session session to perform the commit for. | ||
178 | * @return status of commit | 177 | * @return status of commit |
179 | */ | 178 | */ |
180 | static enum GNUNET_DB_QueryStatus | 179 | static enum GNUNET_DB_QueryStatus |
181 | commit_or_warn (struct TALER_EXCHANGEDB_Session *session) | 180 | commit_or_warn (void) |
182 | { | 181 | { |
183 | enum GNUNET_DB_QueryStatus qs; | 182 | enum GNUNET_DB_QueryStatus qs; |
184 | 183 | ||
185 | qs = db_plugin->commit (db_plugin->cls, | 184 | qs = db_plugin->commit (db_plugin->cls); |
186 | session); | ||
187 | if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) | 185 | if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) |
188 | return qs; | 186 | return qs; |
189 | GNUNET_log ((GNUNET_DB_STATUS_SOFT_ERROR == qs) | 187 | GNUNET_log ((GNUNET_DB_STATUS_SOFT_ERROR == qs) |
@@ -195,26 +193,12 @@ commit_or_warn (struct TALER_EXCHANGEDB_Session *session) | |||
195 | 193 | ||
196 | 194 | ||
197 | /** | 195 | /** |
198 | * Closure for #expired_reserve_cb(). | ||
199 | */ | ||
200 | struct ExpiredReserveContext | ||
201 | { | ||
202 | |||
203 | /** | ||
204 | * Database session we are using. | ||
205 | */ | ||
206 | struct TALER_EXCHANGEDB_Session *session; | ||
207 | |||
208 | }; | ||
209 | |||
210 | |||
211 | /** | ||
212 | * Function called with details about expired reserves. | 196 | * Function called with details about expired reserves. |
213 | * We trigger the reserve closure by inserting the respective | 197 | * We trigger the reserve closure by inserting the respective |
214 | * closing record and prewire instructions into the respective | 198 | * closing record and prewire instructions into the respective |
215 | * tables. | 199 | * tables. |
216 | * | 200 | * |
217 | * @param cls a `struct ExpiredReserveContext *` | 201 | * @param cls NULL |
218 | * @param reserve_pub public key of the reserve | 202 | * @param reserve_pub public key of the reserve |
219 | * @param left amount left in the reserve | 203 | * @param left amount left in the reserve |
220 | * @param account_payto_uri information about the bank account that initially | 204 | * @param account_payto_uri information about the bank account that initially |
@@ -229,8 +213,6 @@ expired_reserve_cb (void *cls, | |||
229 | const char *account_payto_uri, | 213 | const char *account_payto_uri, |
230 | struct GNUNET_TIME_Absolute expiration_date) | 214 | struct GNUNET_TIME_Absolute expiration_date) |
231 | { | 215 | { |
232 | struct ExpiredReserveContext *erc = cls; | ||
233 | struct TALER_EXCHANGEDB_Session *session = erc->session; | ||
234 | struct GNUNET_TIME_Absolute now; | 216 | struct GNUNET_TIME_Absolute now; |
235 | struct TALER_WireTransferIdentifierRawP wtid; | 217 | struct TALER_WireTransferIdentifierRawP wtid; |
236 | struct TALER_Amount amount_without_fee; | 218 | struct TALER_Amount amount_without_fee; |
@@ -239,6 +221,7 @@ expired_reserve_cb (void *cls, | |||
239 | enum GNUNET_DB_QueryStatus qs; | 221 | enum GNUNET_DB_QueryStatus qs; |
240 | const struct TALER_EXCHANGEDB_AccountInfo *wa; | 222 | const struct TALER_EXCHANGEDB_AccountInfo *wa; |
241 | 223 | ||
224 | (void) cls; | ||
242 | /* NOTE: potential optimization: use custom SQL API to not | 225 | /* NOTE: potential optimization: use custom SQL API to not |
243 | fetch this: */ | 226 | fetch this: */ |
244 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 227 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -269,7 +252,6 @@ expired_reserve_cb (void *cls, | |||
269 | enum GNUNET_DB_QueryStatus qs; | 252 | enum GNUNET_DB_QueryStatus qs; |
270 | 253 | ||
271 | qs = db_plugin->get_wire_fee (db_plugin->cls, | 254 | qs = db_plugin->get_wire_fee (db_plugin->cls, |
272 | session, | ||
273 | wa->method, | 255 | wa->method, |
274 | expiration_date, | 256 | expiration_date, |
275 | &start_date, | 257 | &start_date, |
@@ -326,7 +308,6 @@ expired_reserve_cb (void *cls, | |||
326 | sizeof (*reserve_pub))); | 308 | sizeof (*reserve_pub))); |
327 | if (GNUNET_SYSERR != ret) | 309 | if (GNUNET_SYSERR != ret) |
328 | qs = db_plugin->insert_reserve_closed (db_plugin->cls, | 310 | qs = db_plugin->insert_reserve_closed (db_plugin->cls, |
329 | session, | ||
330 | reserve_pub, | 311 | reserve_pub, |
331 | now, | 312 | now, |
332 | account_payto_uri, | 313 | account_payto_uri, |
@@ -356,7 +337,7 @@ expired_reserve_cb (void *cls, | |||
356 | /* Reserve balance was almost zero OR soft error */ | 337 | /* Reserve balance was almost zero OR soft error */ |
357 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 338 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
358 | "Reserve was virtually empty, moving on\n"); | 339 | "Reserve was virtually empty, moving on\n"); |
359 | (void) commit_or_warn (session); | 340 | (void) commit_or_warn (); |
360 | return qs; | 341 | return qs; |
361 | } | 342 | } |
362 | 343 | ||
@@ -373,7 +354,6 @@ expired_reserve_cb (void *cls, | |||
373 | &buf_size); | 354 | &buf_size); |
374 | /* Commit our intention to execute the wire transfer! */ | 355 | /* Commit our intention to execute the wire transfer! */ |
375 | qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, | 356 | qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, |
376 | session, | ||
377 | wa->method, | 357 | wa->method, |
378 | buf, | 358 | buf, |
379 | buf_size); | 359 | buf_size); |
@@ -404,17 +384,16 @@ expired_reserve_cb (void *cls, | |||
404 | static void | 384 | static void |
405 | run_reserve_closures (void *cls) | 385 | run_reserve_closures (void *cls) |
406 | { | 386 | { |
407 | struct TALER_EXCHANGEDB_Session *session; | ||
408 | enum GNUNET_DB_QueryStatus qs; | 387 | enum GNUNET_DB_QueryStatus qs; |
409 | struct ExpiredReserveContext erc; | ||
410 | struct GNUNET_TIME_Absolute now; | 388 | struct GNUNET_TIME_Absolute now; |
411 | 389 | ||
412 | (void) cls; | 390 | (void) cls; |
413 | task = NULL; | 391 | task = NULL; |
414 | if (NULL == (session = db_plugin->get_session (db_plugin->cls))) | 392 | if (GNUNET_SYSERR == |
393 | db_plugin->preflight (db_plugin->cls)) | ||
415 | { | 394 | { |
416 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 395 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
417 | "Failed to obtain database session!\n"); | 396 | "Failed to obtain database connection!\n"); |
418 | global_ret = EXIT_FAILURE; | 397 | global_ret = EXIT_FAILURE; |
419 | GNUNET_SCHEDULER_shutdown (); | 398 | GNUNET_SCHEDULER_shutdown (); |
420 | return; | 399 | return; |
@@ -422,7 +401,6 @@ run_reserve_closures (void *cls) | |||
422 | 401 | ||
423 | if (GNUNET_OK != | 402 | if (GNUNET_OK != |
424 | db_plugin->start (db_plugin->cls, | 403 | db_plugin->start (db_plugin->cls, |
425 | session, | ||
426 | "aggregator reserve closures")) | 404 | "aggregator reserve closures")) |
427 | { | 405 | { |
428 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 406 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -431,30 +409,26 @@ run_reserve_closures (void *cls) | |||
431 | GNUNET_SCHEDULER_shutdown (); | 409 | GNUNET_SCHEDULER_shutdown (); |
432 | return; | 410 | return; |
433 | } | 411 | } |
434 | erc.session = session; | ||
435 | now = GNUNET_TIME_absolute_get (); | 412 | now = GNUNET_TIME_absolute_get (); |
436 | (void) GNUNET_TIME_round_abs (&now); | 413 | (void) GNUNET_TIME_round_abs (&now); |
437 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 414 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
438 | "Checking for reserves to close by date %s\n", | 415 | "Checking for reserves to close by date %s\n", |
439 | GNUNET_STRINGS_absolute_time_to_string (now)); | 416 | GNUNET_STRINGS_absolute_time_to_string (now)); |
440 | qs = db_plugin->get_expired_reserves (db_plugin->cls, | 417 | qs = db_plugin->get_expired_reserves (db_plugin->cls, |
441 | session, | ||
442 | now, | 418 | now, |
443 | &expired_reserve_cb, | 419 | &expired_reserve_cb, |
444 | &erc); | 420 | NULL); |
445 | GNUNET_assert (1 >= qs); | 421 | GNUNET_assert (1 >= qs); |
446 | switch (qs) | 422 | switch (qs) |
447 | { | 423 | { |
448 | case GNUNET_DB_STATUS_HARD_ERROR: | 424 | case GNUNET_DB_STATUS_HARD_ERROR: |
449 | GNUNET_break (0); | 425 | GNUNET_break (0); |
450 | db_plugin->rollback (db_plugin->cls, | 426 | db_plugin->rollback (db_plugin->cls); |
451 | session); | ||
452 | global_ret = EXIT_FAILURE; | 427 | global_ret = EXIT_FAILURE; |
453 | GNUNET_SCHEDULER_shutdown (); | 428 | GNUNET_SCHEDULER_shutdown (); |
454 | return; | 429 | return; |
455 | case GNUNET_DB_STATUS_SOFT_ERROR: | 430 | case GNUNET_DB_STATUS_SOFT_ERROR: |
456 | db_plugin->rollback (db_plugin->cls, | 431 | db_plugin->rollback (db_plugin->cls); |
457 | session); | ||
458 | GNUNET_assert (NULL == task); | 432 | GNUNET_assert (NULL == task); |
459 | task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, | 433 | task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, |
460 | NULL); | 434 | NULL); |
@@ -462,8 +436,7 @@ run_reserve_closures (void *cls) | |||
462 | case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: | 436 | case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: |
463 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 437 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
464 | "No more idle reserves to close, going to sleep.\n"); | 438 | "No more idle reserves to close, going to sleep.\n"); |
465 | db_plugin->rollback (db_plugin->cls, | 439 | db_plugin->rollback (db_plugin->cls); |
466 | session); | ||
467 | GNUNET_assert (NULL == task); | 440 | GNUNET_assert (NULL == task); |
468 | if (GNUNET_YES == test_mode) | 441 | if (GNUNET_YES == test_mode) |
469 | { | 442 | { |
@@ -477,7 +450,7 @@ run_reserve_closures (void *cls) | |||
477 | } | 450 | } |
478 | return; | 451 | return; |
479 | case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: | 452 | case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: |
480 | (void) commit_or_warn (session); | 453 | (void) commit_or_warn (); |
481 | GNUNET_assert (NULL == task); | 454 | GNUNET_assert (NULL == task); |
482 | task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, | 455 | task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, |
483 | NULL); | 456 | NULL); |
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index c06695e4d..627ac00f9 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2014-2020 Taler Systems SA | 3 | Copyright (C) 2014-2021 Taler Systems SA |
4 | 4 | ||
5 | TALER is free software; you can redistribute it and/or modify it under the | 5 | TALER is free software; you can redistribute it and/or modify it under the |
6 | terms of the GNU Affero General Public License as published by the Free Software | 6 | terms of the GNU Affero General Public License as published by the Free Software |
@@ -34,7 +34,6 @@ | |||
34 | #include "taler-exchange-httpd_deposits_get.h" | 34 | #include "taler-exchange-httpd_deposits_get.h" |
35 | #include "taler-exchange-httpd_keys.h" | 35 | #include "taler-exchange-httpd_keys.h" |
36 | #include "taler-exchange-httpd_link.h" | 36 | #include "taler-exchange-httpd_link.h" |
37 | #include "taler-exchange-httpd_loop.h" | ||
38 | #include "taler-exchange-httpd_management.h" | 37 | #include "taler-exchange-httpd_management.h" |
39 | #include "taler-exchange-httpd_melt.h" | 38 | #include "taler-exchange-httpd_melt.h" |
40 | #include "taler-exchange-httpd_mhd.h" | 39 | #include "taler-exchange-httpd_mhd.h" |
@@ -53,7 +52,7 @@ | |||
53 | /** | 52 | /** |
54 | * Backlog for listen operation on unix domain sockets. | 53 | * Backlog for listen operation on unix domain sockets. |
55 | */ | 54 | */ |
56 | #define UNIX_BACKLOG 500 | 55 | #define UNIX_BACKLOG 50 |
57 | 56 | ||
58 | 57 | ||
59 | /** | 58 | /** |
@@ -67,7 +66,7 @@ int TEH_allow_keys_timetravel; | |||
67 | /** | 66 | /** |
68 | * The exchange's configuration (global) | 67 | * The exchange's configuration (global) |
69 | */ | 68 | */ |
70 | struct GNUNET_CONFIGURATION_Handle *TEH_cfg; | 69 | const struct GNUNET_CONFIGURATION_Handle *TEH_cfg; |
71 | 70 | ||
72 | /** | 71 | /** |
73 | * How long is caching /keys allowed at most? (global) | 72 | * How long is caching /keys allowed at most? (global) |
@@ -101,16 +100,14 @@ char *TEH_currency; | |||
101 | static unsigned int connection_timeout = 30; | 100 | static unsigned int connection_timeout = 30; |
102 | 101 | ||
103 | /** | 102 | /** |
104 | * How many threads to use. | 103 | * -C command-line flag given? |
105 | * The default value (0) sets the actual number of threads | ||
106 | * based on the number of available cores. | ||
107 | */ | 104 | */ |
108 | static unsigned int num_threads = 0; | 105 | static int connection_close; |
109 | 106 | ||
110 | /** | 107 | /** |
111 | * The HTTP Daemon. | 108 | * Value to return from main() |
112 | */ | 109 | */ |
113 | static struct MHD_Daemon *mhd; | 110 | static int global_ret; |
114 | 111 | ||
115 | /** | 112 | /** |
116 | * Port to run the daemon on. | 113 | * Port to run the daemon on. |
@@ -118,17 +115,6 @@ static struct MHD_Daemon *mhd; | |||
118 | static uint16_t serve_port; | 115 | static uint16_t serve_port; |
119 | 116 | ||
120 | /** | 117 | /** |
121 | * Path for the unix domain-socket | ||
122 | * to run the daemon on. | ||
123 | */ | ||
124 | static char *serve_unixpath; | ||
125 | |||
126 | /** | ||
127 | * File mode for unix-domain socket. | ||
128 | */ | ||
129 | static mode_t unixpath_mode; | ||
130 | |||
131 | /** | ||
132 | * Counter for the number of requests this HTTP has processed so far. | 118 | * Counter for the number of requests this HTTP has processed so far. |
133 | */ | 119 | */ |
134 | static unsigned long long req_count; | 120 | static unsigned long long req_count; |
@@ -302,11 +288,8 @@ handle_mhd_completion_callback (void *cls, | |||
302 | 288 | ||
303 | TALER_MHD_parse_post_cleanup_callback (rc->opaque_post_parsing_context); | 289 | TALER_MHD_parse_post_cleanup_callback (rc->opaque_post_parsing_context); |
304 | /* Sanity-check that we didn't leave any transactions hanging */ | 290 | /* Sanity-check that we didn't leave any transactions hanging */ |
305 | /* NOTE: In high-performance production, we could consider | 291 | GNUNET_break (GNUNET_OK == |
306 | removing this as it should not be needed and might be costly | 292 | TEH_plugin->preflight (TEH_plugin->cls)); |
307 | (to be benchmarked). */ | ||
308 | TEH_plugin->preflight (TEH_plugin->cls, | ||
309 | TEH_plugin->get_session (TEH_plugin->cls)); | ||
310 | GNUNET_free (rc); | 293 | GNUNET_free (rc); |
311 | *con_cls = NULL; | 294 | *con_cls = NULL; |
312 | GNUNET_async_scope_restore (&old_scope); | 295 | GNUNET_async_scope_restore (&old_scope); |
@@ -1179,18 +1162,6 @@ exchange_serve_process_config (void) | |||
1179 | "Failed to initialize DB subsystem\n"); | 1162 | "Failed to initialize DB subsystem\n"); |
1180 | return GNUNET_SYSERR; | 1163 | return GNUNET_SYSERR; |
1181 | } | 1164 | } |
1182 | |||
1183 | if (GNUNET_OK != | ||
1184 | TALER_MHD_parse_config (TEH_cfg, | ||
1185 | "exchange", | ||
1186 | &serve_port, | ||
1187 | &serve_unixpath, | ||
1188 | &unixpath_mode)) | ||
1189 | { | ||
1190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1191 | "Failed to setup HTTPd subsystem\n"); | ||
1192 | return GNUNET_SYSERR; | ||
1193 | } | ||
1194 | return GNUNET_OK; | 1165 | return GNUNET_OK; |
1195 | } | 1166 | } |
1196 | 1167 | ||
@@ -1248,16 +1219,11 @@ write_stats (void) | |||
1248 | /* Developer logic for supporting the `-f' option. */ | 1219 | /* Developer logic for supporting the `-f' option. */ |
1249 | #if HAVE_DEVELOPER | 1220 | #if HAVE_DEVELOPER |
1250 | 1221 | ||
1251 | |||
1252 | /** | 1222 | /** |
1253 | * Option `-f' (specifies an input file to give to the HTTP server). | 1223 | * Option `-f' (specifies an input file to give to the HTTP server). |
1254 | */ | 1224 | */ |
1255 | static char *input_filename; | 1225 | static char *input_filename; |
1256 | 1226 | ||
1257 | /** | ||
1258 | * We finished handling the request and should now terminate. | ||
1259 | */ | ||
1260 | static int do_terminate; | ||
1261 | 1227 | ||
1262 | /** | 1228 | /** |
1263 | * Run 'nc' or 'ncat' as a fake HTTP client using #input_filename | 1229 | * Run 'nc' or 'ncat' as a fake HTTP client using #input_filename |
@@ -1277,7 +1243,8 @@ run_fake_client (void) | |||
1277 | "-")) | 1243 | "-")) |
1278 | fd = STDIN_FILENO; | 1244 | fd = STDIN_FILENO; |
1279 | else | 1245 | else |
1280 | fd = open (input_filename, O_RDONLY); | 1246 | fd = open (input_filename, |
1247 | O_RDONLY); | ||
1281 | if (-1 == fd) | 1248 | if (-1 == fd) |
1282 | { | 1249 | { |
1283 | fprintf (stderr, | 1250 | fprintf (stderr, |
@@ -1325,6 +1292,50 @@ run_fake_client (void) | |||
1325 | 1292 | ||
1326 | 1293 | ||
1327 | /** | 1294 | /** |
1295 | * Run the exchange to serve a single request only, without threads. | ||
1296 | * | ||
1297 | * @return #GNUNET_OK on success | ||
1298 | */ | ||
1299 | static void | ||
1300 | run_single_request (void) | ||
1301 | { | ||
1302 | pid_t xfork; | ||
1303 | |||
1304 | xfork = fork (); | ||
1305 | if (-1 == xfork) | ||
1306 | { | ||
1307 | global_ret = EXIT_FAILURE; | ||
1308 | GNUNET_SCHEDULER_shutdown (); | ||
1309 | return; | ||
1310 | } | ||
1311 | if (0 == xfork) | ||
1312 | { | ||
1313 | pid_t cld; | ||
1314 | |||
1315 | cld = run_fake_client (); | ||
1316 | if (-1 == cld) | ||
1317 | _exit (EXIT_FAILURE); | ||
1318 | _exit (EXIT_SUCCESS); | ||
1319 | } | ||
1320 | |||
1321 | { | ||
1322 | int status; | ||
1323 | |||
1324 | if (xfork != waitpid (xfork, | ||
1325 | &status, | ||
1326 | 0)) | ||
1327 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1328 | "Waiting for `nc' child failed: %s\n", | ||
1329 | strerror (errno)); | ||
1330 | } | ||
1331 | } | ||
1332 | |||
1333 | |||
1334 | /* end of HAVE_DEVELOPER */ | ||
1335 | #endif | ||
1336 | |||
1337 | |||
1338 | /** | ||
1328 | * Signature of the callback used by MHD to notify the application | 1339 | * Signature of the callback used by MHD to notify the application |
1329 | * about completed connections. If we are running in test-mode with | 1340 | * about completed connections. If we are running in test-mode with |
1330 | * an #input_filename, this function is used to terminate the HTTPD | 1341 | * an #input_filename, this function is used to terminate the HTTPD |
@@ -1344,240 +1355,138 @@ connection_done (void *cls, | |||
1344 | (void) cls; | 1355 | (void) cls; |
1345 | (void) connection; | 1356 | (void) connection; |
1346 | (void) socket_context; | 1357 | (void) socket_context; |
1358 | |||
1359 | #if HAVE_DEVELOPER | ||
1347 | /* We only act if the connection is closed. */ | 1360 | /* We only act if the connection is closed. */ |
1348 | if (MHD_CONNECTION_NOTIFY_CLOSED != toe) | 1361 | if (MHD_CONNECTION_NOTIFY_CLOSED != toe) |
1349 | return; | 1362 | return; |
1350 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1363 | if (NULL != input_filename) |
1351 | "Connection done!\n"); | 1364 | GNUNET_SCHEDULER_shutdown (); |
1352 | do_terminate = GNUNET_YES; | 1365 | #endif |
1353 | } | 1366 | } |
1354 | 1367 | ||
1355 | 1368 | ||
1356 | /** | 1369 | /** |
1357 | * Run the exchange to serve a single request only, without threads. | 1370 | * Function run on shutdown. |
1358 | * | 1371 | * |
1359 | * @return #GNUNET_OK on success | 1372 | * @param cls NULL |
1360 | */ | 1373 | */ |
1361 | static int | 1374 | static void |
1362 | run_single_request (void) | 1375 | do_shutdown (void *cls) |
1363 | { | 1376 | { |
1364 | pid_t cld; | 1377 | struct MHD_Daemon *mhd; |
1365 | int status; | 1378 | (void) cls; |
1366 | |||
1367 | /* run only the testfile input, then terminate */ | ||
1368 | mhd | ||
1369 | = MHD_start_daemon (MHD_USE_PIPE_FOR_SHUTDOWN | ||
1370 | | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | ||
1371 | | MHD_USE_TCP_FASTOPEN, | ||
1372 | 0, /* pick free port */ | ||
1373 | NULL, NULL, | ||
1374 | &handle_mhd_request, NULL, | ||
1375 | MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 10, | ||
1376 | MHD_OPTION_EXTERNAL_LOGGER, &TALER_MHD_handle_logs, | ||
1377 | NULL, | ||
1378 | MHD_OPTION_NOTIFY_COMPLETED, | ||
1379 | &handle_mhd_completion_callback, NULL, | ||
1380 | MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, | ||
1381 | MHD_OPTION_NOTIFY_CONNECTION, &connection_done, NULL, | ||
1382 | MHD_OPTION_END); | ||
1383 | if (NULL == mhd) | ||
1384 | { | ||
1385 | fprintf (stderr, | ||
1386 | "Failed to start HTTP server.\n"); | ||
1387 | return GNUNET_SYSERR; | ||
1388 | } | ||
1389 | serve_port = MHD_get_daemon_info (mhd, | ||
1390 | MHD_DAEMON_INFO_BIND_PORT)->port; | ||
1391 | cld = run_fake_client (); | ||
1392 | if (-1 == cld) | ||
1393 | return GNUNET_SYSERR; | ||
1394 | /* run the event loop until #connection_done() was called */ | ||
1395 | while (GNUNET_NO == do_terminate) | ||
1396 | { | ||
1397 | fd_set rs; | ||
1398 | fd_set ws; | ||
1399 | fd_set es; | ||
1400 | struct timeval tv; | ||
1401 | MHD_UNSIGNED_LONG_LONG timeout; | ||
1402 | int maxsock = -1; | ||
1403 | int have_tv; | ||
1404 | |||
1405 | FD_ZERO (&rs); | ||
1406 | FD_ZERO (&ws); | ||
1407 | FD_ZERO (&es); | ||
1408 | if (MHD_YES != | ||
1409 | MHD_get_fdset (mhd, | ||
1410 | &rs, | ||
1411 | &ws, | ||
1412 | &es, | ||
1413 | &maxsock)) | ||
1414 | { | ||
1415 | GNUNET_break (0); | ||
1416 | return GNUNET_SYSERR; | ||
1417 | } | ||
1418 | have_tv = MHD_get_timeout (mhd, | ||
1419 | &timeout); | ||
1420 | tv.tv_sec = timeout / 1000; | ||
1421 | tv.tv_usec = 1000 * (timeout % 1000); | ||
1422 | if (-1 == select (maxsock + 1, | ||
1423 | &rs, | ||
1424 | &ws, | ||
1425 | &es, | ||
1426 | have_tv ? &tv : NULL)) | ||
1427 | { | ||
1428 | GNUNET_break (0); | ||
1429 | return GNUNET_SYSERR; | ||
1430 | } | ||
1431 | MHD_run (mhd); | ||
1432 | } | ||
1433 | { | ||
1434 | MHD_socket sock = MHD_quiesce_daemon (mhd); | ||
1435 | 1379 | ||
1436 | TEH_resume_keys_requests (true); | 1380 | mhd = TALER_MHD_daemon_stop (); |
1437 | TEH_reserves_get_cleanup (); | 1381 | TEH_resume_keys_requests (true); |
1382 | TEH_reserves_get_cleanup (); | ||
1383 | if (NULL != mhd) | ||
1438 | MHD_stop_daemon (mhd); | 1384 | MHD_stop_daemon (mhd); |
1439 | GNUNET_break (0 == close (sock)); | 1385 | TALER_EXCHANGEDB_plugin_unload (TEH_plugin); |
1440 | } | 1386 | TEH_WIRE_done (); |
1441 | mhd = NULL; | ||
1442 | if (cld != waitpid (cld, | ||
1443 | &status, | ||
1444 | 0)) | ||
1445 | fprintf (stderr, | ||
1446 | "Waiting for `nc' child failed: %s\n", | ||
1447 | strerror (errno)); | ||
1448 | return GNUNET_OK; | ||
1449 | } | 1387 | } |
1450 | 1388 | ||
1451 | 1389 | ||
1452 | /* end of HAVE_DEVELOPER */ | ||
1453 | #endif | ||
1454 | |||
1455 | |||
1456 | /** | 1390 | /** |
1457 | * Run the ordinary multi-threaded main loop and the logic to | 1391 | * Main function that will be run by the scheduler. |
1458 | * wait for CTRL-C. | ||
1459 | * | 1392 | * |
1460 | * @param fh listen socket | 1393 | * @param cls closure |
1461 | * @param argv command line arguments | 1394 | * @param args remaining command-line arguments |
1462 | * @return #GNUNET_OK on success | 1395 | * @param cfgfile name of the configuration file used (for saving, can be |
1396 | * NULL!) | ||
1397 | * @param config configuration | ||
1463 | */ | 1398 | */ |
1464 | static int | 1399 | static void |
1465 | run_main_loop (int fh, | 1400 | run (void *cls, |
1466 | char *const *argv) | 1401 | char *const *args, |
1402 | const char *cfgfile, | ||
1403 | const struct GNUNET_CONFIGURATION_Handle *config) | ||
1467 | { | 1404 | { |
1468 | int ret; | 1405 | enum TALER_MHD_GlobalOptions go; |
1469 | 1406 | int fh; | |
1470 | GNUNET_assert (0 < num_threads); | 1407 | |
1471 | 1408 | go = TALER_MHD_GO_NONE; | |
1472 | mhd | 1409 | if (connection_close) |
1473 | = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN | 1410 | go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE; |
1474 | | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | 1411 | TALER_MHD_setup (go); |
1475 | | MHD_USE_INTERNAL_POLLING_THREAD | 1412 | TEH_cfg = config; |
1476 | | MHD_ALLOW_SUSPEND_RESUME | 1413 | |
1477 | | MHD_USE_TCP_FASTOPEN, | 1414 | if (GNUNET_OK != |
1478 | (-1 == fh) ? serve_port : 0, | 1415 | exchange_serve_process_config ()) |
1479 | NULL, NULL, | ||
1480 | &handle_mhd_request, NULL, | ||
1481 | MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) num_threads, | ||
1482 | MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, | ||
1483 | MHD_OPTION_LISTEN_SOCKET, fh, | ||
1484 | MHD_OPTION_EXTERNAL_LOGGER, &TALER_MHD_handle_logs, | ||
1485 | NULL, | ||
1486 | MHD_OPTION_NOTIFY_COMPLETED, | ||
1487 | &handle_mhd_completion_callback, NULL, | ||
1488 | MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, | ||
1489 | MHD_OPTION_END); | ||
1490 | if (NULL == mhd) | ||
1491 | { | 1416 | { |
1492 | fprintf (stderr, | 1417 | global_ret = EXIT_NOTCONFIGURED; |
1493 | "Failed to start HTTP server.\n"); | 1418 | GNUNET_SCHEDULER_shutdown (); |
1494 | return GNUNET_SYSERR; | 1419 | return; |
1495 | } | 1420 | } |
1496 | 1421 | if (GNUNET_OK != | |
1497 | atexit (&write_stats); | 1422 | TEH_WIRE_init ()) |
1498 | ret = TEH_loop_run (); | ||
1499 | switch (ret) | ||
1500 | { | 1423 | { |
1501 | case GNUNET_OK: | 1424 | global_ret = EXIT_FAILURE; |
1502 | case GNUNET_SYSERR: | 1425 | GNUNET_SCHEDULER_shutdown (); |
1503 | { | 1426 | return; |
1504 | MHD_socket sock = MHD_quiesce_daemon (mhd); | 1427 | } |
1428 | if (GNUNET_OK != | ||
1429 | TEH_keys_init ()) | ||
1430 | { | ||
1431 | global_ret = EXIT_FAILURE; | ||
1432 | GNUNET_SCHEDULER_shutdown (); | ||
1433 | return; | ||
1434 | } | ||
1505 | 1435 | ||
1506 | TEH_resume_keys_requests (true); | 1436 | TEH_load_terms (TEH_cfg); |
1507 | TEH_reserves_get_cleanup (); | 1437 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
1508 | MHD_stop_daemon (mhd); | 1438 | NULL); |
1509 | GNUNET_break (0 == close (sock)); | 1439 | fh = TALER_MHD_bind (TEH_cfg, |
1510 | } | 1440 | "exchange", |
1511 | mhd = NULL; | 1441 | &serve_port); |
1512 | break; | 1442 | if ( (0 == serve_port) && |
1513 | case GNUNET_NO: | 1443 | (-1 == fh) ) |
1444 | { | ||
1445 | GNUNET_SCHEDULER_shutdown (); | ||
1446 | return; | ||
1447 | } | ||
1448 | { | ||
1449 | struct MHD_Daemon *mhd; | ||
1450 | |||
1451 | mhd = MHD_start_daemon (MHD_USE_SUSPEND_RESUME | ||
1452 | | MHD_USE_PIPE_FOR_SHUTDOWN | ||
1453 | | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | ||
1454 | | MHD_USE_TCP_FASTOPEN, | ||
1455 | (-1 == fh) ? serve_port : 0, | ||
1456 | NULL, NULL, | ||
1457 | &handle_mhd_request, NULL, | ||
1458 | MHD_OPTION_LISTEN_BACKLOG_SIZE, | ||
1459 | (unsigned int) 1024, | ||
1460 | MHD_OPTION_LISTEN_SOCKET, | ||
1461 | fh, | ||
1462 | MHD_OPTION_EXTERNAL_LOGGER, | ||
1463 | &TALER_MHD_handle_logs, | ||
1464 | NULL, | ||
1465 | MHD_OPTION_NOTIFY_COMPLETED, | ||
1466 | &handle_mhd_completion_callback, | ||
1467 | NULL, | ||
1468 | MHD_OPTION_NOTIFY_CONNECTION, | ||
1469 | &connection_done, | ||
1470 | NULL, | ||
1471 | MHD_OPTION_CONNECTION_TIMEOUT, | ||
1472 | connection_timeout, | ||
1473 | MHD_OPTION_END); | ||
1474 | if (NULL == mhd) | ||
1514 | { | 1475 | { |
1515 | MHD_socket sock = MHD_quiesce_daemon (mhd); | 1476 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1516 | pid_t chld; | 1477 | "Failed to launch HTTP service. Is the port in use?\n"); |
1517 | int flags; | 1478 | GNUNET_SCHEDULER_shutdown (); |
1518 | 1479 | return; | |
1519 | /* Set flags to make 'sock' inherited by child */ | ||
1520 | flags = fcntl (sock, F_GETFD); | ||
1521 | GNUNET_assert (-1 != flags); | ||
1522 | flags &= ~FD_CLOEXEC; | ||
1523 | GNUNET_assert (-1 != fcntl (sock, | ||
1524 | F_SETFD, | ||
1525 | flags)); | ||
1526 | chld = fork (); | ||
1527 | if (-1 == chld) | ||
1528 | { | ||
1529 | /* fork() failed, continue clean up, unhappily */ | ||
1530 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
1531 | "fork"); | ||
1532 | } | ||
1533 | if (0 == chld) | ||
1534 | { | ||
1535 | char pids[12]; | ||
1536 | |||
1537 | /* exec another taler-exchange-httpd, passing on the listen socket; | ||
1538 | as in systemd it is expected to be on FD #3 */ | ||
1539 | if (3 != dup2 (sock, 3)) | ||
1540 | { | ||
1541 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
1542 | "dup2"); | ||
1543 | _exit (1); | ||
1544 | } | ||
1545 | /* Tell the child that it is the desired recipient for FD #3 */ | ||
1546 | GNUNET_snprintf (pids, | ||
1547 | sizeof (pids), | ||
1548 | "%u", | ||
1549 | getpid ()); | ||
1550 | setenv ("LISTEN_PID", pids, 1); | ||
1551 | setenv ("LISTEN_FDS", "1", 1); | ||
1552 | /* Finally, exec the (presumably) more recent exchange binary */ | ||
1553 | execvp ("taler-exchange-httpd", | ||
1554 | argv); | ||
1555 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
1556 | "execvp"); | ||
1557 | _exit (1); | ||
1558 | } | ||
1559 | /* we're the original process, handle remaining contextions | ||
1560 | before exiting; as the listen socket is no longer used, | ||
1561 | close it here */ | ||
1562 | GNUNET_break (0 == close (sock)); | ||
1563 | while (0 != MHD_get_daemon_info (mhd, | ||
1564 | MHD_DAEMON_INFO_CURRENT_CONNECTIONS)-> | ||
1565 | num_connections) | ||
1566 | sleep (1); | ||
1567 | /* Now we're really done, practice clean shutdown */ | ||
1568 | TEH_resume_keys_requests (true); | ||
1569 | TEH_reserves_get_cleanup (); | ||
1570 | MHD_stop_daemon (mhd); | ||
1571 | } | 1480 | } |
1572 | break; | 1481 | global_ret = EXIT_SUCCESS; |
1573 | default: | 1482 | TALER_MHD_daemon_start (mhd); |
1574 | GNUNET_break (0); | ||
1575 | TEH_resume_keys_requests (true); | ||
1576 | MHD_stop_daemon (mhd); | ||
1577 | break; | ||
1578 | } | 1483 | } |
1484 | atexit (&write_stats); | ||
1579 | 1485 | ||
1580 | return ret; | 1486 | #if HAVE_DEVELOPER |
1487 | if (NULL != input_filename) | ||
1488 | run_single_request (); | ||
1489 | #endif | ||
1581 | } | 1490 | } |
1582 | 1491 | ||
1583 | 1492 | ||
@@ -1592,10 +1501,6 @@ int | |||
1592 | main (int argc, | 1501 | main (int argc, |
1593 | char *const *argv) | 1502 | char *const *argv) |
1594 | { | 1503 | { |
1595 | char *cfgfile = NULL; | ||
1596 | char *loglev = NULL; | ||
1597 | char *logfile = NULL; | ||
1598 | int connection_close = GNUNET_NO; | ||
1599 | const struct GNUNET_GETOPT_CommandLineOption options[] = { | 1504 | const struct GNUNET_GETOPT_CommandLineOption options[] = { |
1600 | GNUNET_GETOPT_option_flag ('a', | 1505 | GNUNET_GETOPT_option_flag ('a', |
1601 | "allow-timetravel", | 1506 | "allow-timetravel", |
@@ -1605,7 +1510,6 @@ main (int argc, | |||
1605 | "connection-close", | 1510 | "connection-close", |
1606 | "force HTTP connections to be closed after each request", | 1511 | "force HTTP connections to be closed after each request", |
1607 | &connection_close), | 1512 | &connection_close), |
1608 | GNUNET_GETOPT_option_cfgfile (&cfgfile), | ||
1609 | GNUNET_GETOPT_option_uint ('t', | 1513 | GNUNET_GETOPT_option_uint ('t', |
1610 | "timeout", | 1514 | "timeout", |
1611 | "SECONDS", | 1515 | "SECONDS", |
@@ -1613,11 +1517,6 @@ main (int argc, | |||
1613 | &connection_timeout), | 1517 | &connection_timeout), |
1614 | GNUNET_GETOPT_option_timetravel ('T', | 1518 | GNUNET_GETOPT_option_timetravel ('T', |
1615 | "timetravel"), | 1519 | "timetravel"), |
1616 | GNUNET_GETOPT_option_uint ('n', | ||
1617 | "num-threads", | ||
1618 | "NUM_THREADS", | ||
1619 | "size of the thread pool", | ||
1620 | &num_threads), | ||
1621 | #if HAVE_DEVELOPER | 1520 | #if HAVE_DEVELOPER |
1622 | GNUNET_GETOPT_option_filename ('f', | 1521 | GNUNET_GETOPT_option_filename ('f', |
1623 | "file-input", | 1522 | "file-input", |
@@ -1627,141 +1526,22 @@ main (int argc, | |||
1627 | #endif | 1526 | #endif |
1628 | GNUNET_GETOPT_option_help ( | 1527 | GNUNET_GETOPT_option_help ( |
1629 | "HTTP server providing a RESTful API to access a Taler exchange"), | 1528 | "HTTP server providing a RESTful API to access a Taler exchange"), |
1630 | GNUNET_GETOPT_option_loglevel (&loglev), | ||
1631 | GNUNET_GETOPT_option_logfile (&logfile), | ||
1632 | GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), | 1529 | GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), |
1633 | GNUNET_GETOPT_OPTION_END | 1530 | GNUNET_GETOPT_OPTION_END |
1634 | }; | 1531 | }; |
1635 | int ret; | 1532 | enum GNUNET_GenericReturnValue ret; |
1636 | const char *listen_pid; | ||
1637 | const char *listen_fds; | ||
1638 | int fh = -1; | ||
1639 | enum TALER_MHD_GlobalOptions go; | ||
1640 | 1533 | ||
1641 | TALER_OS_init (); | 1534 | TALER_OS_init (); |
1642 | ret = GNUNET_GETOPT_run ("taler-exchange-httpd", | 1535 | ret = GNUNET_PROGRAM_run (argc, argv, |
1643 | options, | 1536 | "taler-exchange-httpd", |
1644 | argc, argv); | 1537 | "Taler exchange HTTP service", |
1538 | options, | ||
1539 | &run, NULL); | ||
1645 | if (GNUNET_SYSERR == ret) | 1540 | if (GNUNET_SYSERR == ret) |
1646 | return EXIT_INVALIDARGUMENT; | 1541 | return EXIT_INVALIDARGUMENT; |
1647 | if (GNUNET_NO == ret) | 1542 | if (GNUNET_NO == ret) |
1648 | return EXIT_SUCCESS; | 1543 | return EXIT_SUCCESS; |
1649 | if (0 == num_threads) | 1544 | return global_ret; |
1650 | { | ||
1651 | cpu_set_t mask; | ||
1652 | GNUNET_assert (0 == | ||
1653 | sched_getaffinity (0, | ||
1654 | sizeof (cpu_set_t), | ||
1655 | &mask)); | ||
1656 | num_threads = CPU_COUNT (&mask); | ||
1657 | } | ||
1658 | go = TALER_MHD_GO_NONE; | ||
1659 | if (connection_close) | ||
1660 | go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE; | ||
1661 | TALER_MHD_setup (go); | ||
1662 | GNUNET_assert (GNUNET_OK == | ||
1663 | GNUNET_log_setup ("taler-exchange-httpd", | ||
1664 | (NULL == loglev) ? "INFO" : loglev, | ||
1665 | logfile)); | ||
1666 | GNUNET_free (loglev); | ||
1667 | GNUNET_free (logfile); | ||
1668 | if (NULL == cfgfile) | ||
1669 | cfgfile = GNUNET_CONFIGURATION_default_filename (); | ||
1670 | if (NULL == cfgfile) | ||
1671 | { | ||
1672 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1673 | "Can't find default configuration file.\n"); | ||
1674 | return EXIT_NOTCONFIGURED; | ||
1675 | } | ||
1676 | |||
1677 | TEH_cfg = GNUNET_CONFIGURATION_create (); | ||
1678 | if (GNUNET_SYSERR == | ||
1679 | GNUNET_CONFIGURATION_load (TEH_cfg, | ||
1680 | cfgfile)) | ||
1681 | { | ||
1682 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1683 | "Malformed configuration file `%s', exit ...\n", | ||
1684 | cfgfile); | ||
1685 | GNUNET_free (cfgfile); | ||
1686 | return EXIT_NOTCONFIGURED; | ||
1687 | } | ||
1688 | GNUNET_free (cfgfile); | ||
1689 | if (GNUNET_OK != | ||
1690 | exchange_serve_process_config ()) | ||
1691 | return EXIT_NOTCONFIGURED; | ||
1692 | TEH_load_terms (TEH_cfg); | ||
1693 | |||
1694 | /* check for systemd-style FD passing */ | ||
1695 | listen_pid = getenv ("LISTEN_PID"); | ||
1696 | listen_fds = getenv ("LISTEN_FDS"); | ||
1697 | if ( (NULL != listen_pid) && | ||
1698 | (NULL != listen_fds) && | ||
1699 | (getpid () == strtol (listen_pid, | ||
1700 | NULL, | ||
1701 | 10)) && | ||
1702 | (1 == strtoul (listen_fds, | ||
1703 | NULL, | ||
1704 | 10)) ) | ||
1705 | { | ||
1706 | int flags; | ||
1707 | |||
1708 | fh = 3; | ||
1709 | flags = fcntl (fh, | ||
1710 | F_GETFD); | ||
1711 | if ( (-1 == flags) && | ||
1712 | (EBADF == errno) ) | ||
1713 | { | ||
1714 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1715 | "Bad listen socket passed, ignored\n"); | ||
1716 | fh = -1; | ||
1717 | } | ||
1718 | flags |= FD_CLOEXEC; | ||
1719 | if ( (-1 != fh) && | ||
1720 | (0 != fcntl (fh, | ||
1721 | F_SETFD, | ||
1722 | flags)) ) | ||
1723 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
1724 | "fcntl"); | ||
1725 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1726 | "Successfully obtained listen socket from hypervisor\n"); | ||
1727 | } | ||
1728 | |||
1729 | /* initialize #internal_key_state with an RC of 1 */ | ||
1730 | if (GNUNET_OK != | ||
1731 | TEH_WIRE_init ()) | ||
1732 | return EXIT_FAILURE; | ||
1733 | if (GNUNET_OK != | ||
1734 | TEH_keys_init ()) | ||
1735 | return EXIT_FAILURE; | ||
1736 | ret = TEH_loop_init (); | ||
1737 | if (GNUNET_OK == ret) | ||
1738 | { | ||
1739 | #if HAVE_DEVELOPER | ||
1740 | if (NULL != input_filename) | ||
1741 | { | ||
1742 | ret = run_single_request (); | ||
1743 | } | ||
1744 | else | ||
1745 | #endif | ||
1746 | { | ||
1747 | /* consider unix path */ | ||
1748 | if ( (-1 == fh) && | ||
1749 | (NULL != serve_unixpath) ) | ||
1750 | { | ||
1751 | fh = TALER_MHD_open_unix_path (serve_unixpath, | ||
1752 | unixpath_mode); | ||
1753 | if (-1 == fh) | ||
1754 | return EXIT_NOPERMISSION; /* at least most likely */ | ||
1755 | } | ||
1756 | ret = run_main_loop (fh, | ||
1757 | argv); | ||
1758 | } | ||
1759 | /* release signal handlers */ | ||
1760 | TEH_loop_done (); | ||
1761 | } | ||
1762 | TALER_EXCHANGEDB_plugin_unload (TEH_plugin); | ||
1763 | TEH_WIRE_done (); | ||
1764 | return (GNUNET_SYSERR == ret) ? EXIT_FAILURE : EXIT_SUCCESS; | ||
1765 | } | 1545 | } |
1766 | 1546 | ||
1767 | 1547 | ||
diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h index eaecc9720..e43426488 100644 --- a/src/exchange/taler-exchange-httpd.h +++ b/src/exchange/taler-exchange-httpd.h | |||
@@ -42,7 +42,7 @@ extern struct GNUNET_TIME_Relative TEH_reserve_closing_delay; | |||
42 | /** | 42 | /** |
43 | * The exchange's configuration. | 43 | * The exchange's configuration. |
44 | */ | 44 | */ |
45 | extern struct GNUNET_CONFIGURATION_Handle *TEH_cfg; | 45 | extern const struct GNUNET_CONFIGURATION_Handle *TEH_cfg; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Main directory with exchange data. | 48 | * Main directory with exchange data. |
diff --git a/src/exchange/taler-exchange-httpd_auditors.c b/src/exchange/taler-exchange-httpd_auditors.c index f3c061e39..34e640ad7 100644 --- a/src/exchange/taler-exchange-httpd_auditors.c +++ b/src/exchange/taler-exchange-httpd_auditors.c | |||
@@ -65,7 +65,6 @@ struct AddAuditorDenomContext | |||
65 | * | 65 | * |
66 | * @param cls closure with a `struct AddAuditorDenomContext` | 66 | * @param cls closure with a `struct AddAuditorDenomContext` |
67 | * @param connection MHD request which triggered the transaction | 67 | * @param connection MHD request which triggered the transaction |
68 | * @param session database session to use | ||
69 | * @param[out] mhd_ret set to MHD response status for @a connection, | 68 | * @param[out] mhd_ret set to MHD response status for @a connection, |
70 | * if transaction failed (!) | 69 | * if transaction failed (!) |
71 | * @return transaction status | 70 | * @return transaction status |
@@ -73,7 +72,6 @@ struct AddAuditorDenomContext | |||
73 | static enum GNUNET_DB_QueryStatus | 72 | static enum GNUNET_DB_QueryStatus |
74 | add_auditor_denom_sig (void *cls, | 73 | add_auditor_denom_sig (void *cls, |
75 | struct MHD_Connection *connection, | 74 | struct MHD_Connection *connection, |
76 | struct TALER_EXCHANGEDB_Session *session, | ||
77 | MHD_RESULT *mhd_ret) | 75 | MHD_RESULT *mhd_ret) |
78 | { | 76 | { |
79 | struct AddAuditorDenomContext *awc = cls; | 77 | struct AddAuditorDenomContext *awc = cls; |
@@ -84,7 +82,6 @@ add_auditor_denom_sig (void *cls, | |||
84 | 82 | ||
85 | qs = TEH_plugin->lookup_denomination_key ( | 83 | qs = TEH_plugin->lookup_denomination_key ( |
86 | TEH_plugin->cls, | 84 | TEH_plugin->cls, |
87 | session, | ||
88 | awc->h_denom_pub, | 85 | awc->h_denom_pub, |
89 | &meta); | 86 | &meta); |
90 | if (qs < 0) | 87 | if (qs < 0) |
@@ -110,7 +107,6 @@ add_auditor_denom_sig (void *cls, | |||
110 | 107 | ||
111 | qs = TEH_plugin->lookup_auditor_status ( | 108 | qs = TEH_plugin->lookup_auditor_status ( |
112 | TEH_plugin->cls, | 109 | TEH_plugin->cls, |
113 | session, | ||
114 | awc->auditor_pub, | 110 | awc->auditor_pub, |
115 | &auditor_url, | 111 | &auditor_url, |
116 | &enabled); | 112 | &enabled); |
@@ -174,7 +170,6 @@ add_auditor_denom_sig (void *cls, | |||
174 | GNUNET_free (auditor_url); | 170 | GNUNET_free (auditor_url); |
175 | 171 | ||
176 | qs = TEH_plugin->insert_auditor_denom_sig (TEH_plugin->cls, | 172 | qs = TEH_plugin->insert_auditor_denom_sig (TEH_plugin->cls, |
177 | session, | ||
178 | awc->h_denom_pub, | 173 | awc->h_denom_pub, |
179 | awc->auditor_pub, | 174 | awc->auditor_pub, |
180 | &awc->auditor_sig); | 175 | &awc->auditor_sig); |
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 8574224af..3c6936497 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c | |||
@@ -45,21 +45,18 @@ | |||
45 | * | 45 | * |
46 | * @param coin the coin to make known | 46 | * @param coin the coin to make known |
47 | * @param connection MHD request context | 47 | * @param connection MHD request context |
48 | * @param session database session and transaction to use | ||
49 | * @param[out] mhd_ret set to MHD status on error | 48 | * @param[out] mhd_ret set to MHD status on error |
50 | * @return transaction status, negative on error (@a mhd_ret will be set in this case) | 49 | * @return transaction status, negative on error (@a mhd_ret will be set in this case) |
51 | */ | 50 | */ |
52 | enum GNUNET_DB_QueryStatus | 51 | enum GNUNET_DB_QueryStatus |
53 | TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, | 52 | TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, |
54 | struct MHD_Connection *connection, | 53 | struct MHD_Connection *connection, |
55 | struct TALER_EXCHANGEDB_Session *session, | ||
56 | MHD_RESULT *mhd_ret) | 54 | MHD_RESULT *mhd_ret) |
57 | { | 55 | { |
58 | enum TALER_EXCHANGEDB_CoinKnownStatus cks; | 56 | enum TALER_EXCHANGEDB_CoinKnownStatus cks; |
59 | 57 | ||
60 | /* make sure coin is 'known' in database */ | 58 | /* make sure coin is 'known' in database */ |
61 | cks = TEH_plugin->ensure_coin_known (TEH_plugin->cls, | 59 | cks = TEH_plugin->ensure_coin_known (TEH_plugin->cls, |
62 | session, | ||
63 | coin); | 60 | coin); |
64 | switch (cks) | 61 | switch (cks) |
65 | { | 62 | { |
@@ -85,7 +82,6 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, | |||
85 | enum GNUNET_DB_QueryStatus qs; | 82 | enum GNUNET_DB_QueryStatus qs; |
86 | 83 | ||
87 | qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, | 84 | qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, |
88 | session, | ||
89 | &coin->coin_pub, | 85 | &coin->coin_pub, |
90 | GNUNET_NO, | 86 | GNUNET_NO, |
91 | &tl); | 87 | &tl); |
@@ -135,11 +131,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, | |||
135 | TEH_DB_TransactionCallback cb, | 131 | TEH_DB_TransactionCallback cb, |
136 | void *cb_cls) | 132 | void *cb_cls) |
137 | { | 133 | { |
138 | struct TALER_EXCHANGEDB_Session *session; | ||
139 | |||
140 | if (NULL != mhd_ret) | 134 | if (NULL != mhd_ret) |
141 | *mhd_ret = -1; /* set to invalid value, to help detect bugs */ | 135 | *mhd_ret = -1; /* set to invalid value, to help detect bugs */ |
142 | if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls))) | 136 | if (GNUNET_OK != |
137 | TEH_plugin->preflight (TEH_plugin->cls)) | ||
143 | { | 138 | { |
144 | GNUNET_break (0); | 139 | GNUNET_break (0); |
145 | if (NULL != mhd_ret) | 140 | if (NULL != mhd_ret) |
@@ -157,7 +152,6 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, | |||
157 | 152 | ||
158 | if (GNUNET_OK != | 153 | if (GNUNET_OK != |
159 | TEH_plugin->start (TEH_plugin->cls, | 154 | TEH_plugin->start (TEH_plugin->cls, |
160 | session, | ||
161 | name)) | 155 | name)) |
162 | { | 156 | { |
163 | GNUNET_break (0); | 157 | GNUNET_break (0); |
@@ -170,16 +164,13 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, | |||
170 | } | 164 | } |
171 | qs = cb (cb_cls, | 165 | qs = cb (cb_cls, |
172 | connection, | 166 | connection, |
173 | session, | ||
174 | mhd_ret); | 167 | mhd_ret); |
175 | if (0 > qs) | 168 | if (0 > qs) |
176 | TEH_plugin->rollback (TEH_plugin->cls, | 169 | TEH_plugin->rollback (TEH_plugin->cls); |
177 | session); | ||
178 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | 170 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) |
179 | return GNUNET_SYSERR; | 171 | return GNUNET_SYSERR; |
180 | if (0 <= qs) | 172 | if (0 <= qs) |
181 | qs = TEH_plugin->commit (TEH_plugin->cls, | 173 | qs = TEH_plugin->commit (TEH_plugin->cls); |
182 | session); | ||
183 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | 174 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) |
184 | { | 175 | { |
185 | if (NULL != mhd_ret) | 176 | if (NULL != mhd_ret) |
diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h index 7e73340b7..c115981d3 100644 --- a/src/exchange/taler-exchange-httpd_db.h +++ b/src/exchange/taler-exchange-httpd_db.h | |||
@@ -31,14 +31,12 @@ | |||
31 | * | 31 | * |
32 | * @param coin the coin to make known | 32 | * @param coin the coin to make known |
33 | * @param connection MHD request context | 33 | * @param connection MHD request context |
34 | * @param session database session and transaction to use | ||
35 | * @param[out] mhd_ret set to MHD status on error | 34 | * @param[out] mhd_ret set to MHD status on error |
36 | * @return transaction status, negative on error (@a mhd_ret will be set in this case) | 35 | * @return transaction status, negative on error (@a mhd_ret will be set in this case) |
37 | */ | 36 | */ |
38 | enum GNUNET_DB_QueryStatus | 37 | enum GNUNET_DB_QueryStatus |
39 | TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, | 38 | TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, |
40 | struct MHD_Connection *connection, | 39 | struct MHD_Connection *connection, |
41 | struct TALER_EXCHANGEDB_Session *session, | ||
42 | MHD_RESULT *mhd_ret); | 40 | MHD_RESULT *mhd_ret); |
43 | 41 | ||
44 | 42 | ||
@@ -52,7 +50,6 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, | |||
52 | * | 50 | * |
53 | * @param cls closure | 51 | * @param cls closure |
54 | * @param connection MHD request which triggered the transaction | 52 | * @param connection MHD request which triggered the transaction |
55 | * @param session database session to use | ||
56 | * @param[out] mhd_ret set to MHD response status for @a connection, | 53 | * @param[out] mhd_ret set to MHD response status for @a connection, |
57 | * if transaction failed (!) | 54 | * if transaction failed (!) |
58 | * @return transaction status | 55 | * @return transaction status |
@@ -60,7 +57,6 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, | |||
60 | typedef enum GNUNET_DB_QueryStatus | 57 | typedef enum GNUNET_DB_QueryStatus |
61 | (*TEH_DB_TransactionCallback)(void *cls, | 58 | (*TEH_DB_TransactionCallback)(void *cls, |
62 | struct MHD_Connection *connection, | 59 | struct MHD_Connection *connection, |
63 | struct TALER_EXCHANGEDB_Session *session, | ||
64 | MHD_RESULT *mhd_ret); | 60 | MHD_RESULT *mhd_ret); |
65 | 61 | ||
66 | 62 | ||
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 5ea48c20c..9c4cfdc7e 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c | |||
@@ -133,14 +133,12 @@ struct DepositContext | |||
133 | * | 133 | * |
134 | * @param cls a `struct DepositContext` | 134 | * @param cls a `struct DepositContext` |
135 | * @param connection MHD request context | 135 | * @param connection MHD request context |
136 | * @param session database session and transaction to use | ||
137 | * @param[out] mhd_ret set to MHD status on error | 136 | * @param[out] mhd_ret set to MHD status on error |
138 | * @return transaction status | 137 | * @return transaction status |
139 | */ | 138 | */ |
140 | static enum GNUNET_DB_QueryStatus | 139 | static enum GNUNET_DB_QueryStatus |
141 | deposit_precheck (void *cls, | 140 | deposit_precheck (void *cls, |
142 | struct MHD_Connection *connection, | 141 | struct MHD_Connection *connection, |
143 | struct TALER_EXCHANGEDB_Session *session, | ||
144 | MHD_RESULT *mhd_ret) | 142 | MHD_RESULT *mhd_ret) |
145 | { | 143 | { |
146 | struct DepositContext *dc = cls; | 144 | struct DepositContext *dc = cls; |
@@ -149,7 +147,6 @@ deposit_precheck (void *cls, | |||
149 | enum GNUNET_DB_QueryStatus qs; | 147 | enum GNUNET_DB_QueryStatus qs; |
150 | 148 | ||
151 | qs = TEH_plugin->have_deposit (TEH_plugin->cls, | 149 | qs = TEH_plugin->have_deposit (TEH_plugin->cls, |
152 | session, | ||
153 | deposit, | 150 | deposit, |
154 | GNUNET_YES /* check refund deadline */, | 151 | GNUNET_YES /* check refund deadline */, |
155 | &deposit_fee, | 152 | &deposit_fee, |
@@ -202,14 +199,12 @@ deposit_precheck (void *cls, | |||
202 | * | 199 | * |
203 | * @param cls a `struct DepositContext` | 200 | * @param cls a `struct DepositContext` |
204 | * @param connection MHD request context | 201 | * @param connection MHD request context |
205 | * @param session database session and transaction to use | ||
206 | * @param[out] mhd_ret set to MHD status on error | 202 | * @param[out] mhd_ret set to MHD status on error |
207 | * @return transaction status | 203 | * @return transaction status |
208 | */ | 204 | */ |
209 | static enum GNUNET_DB_QueryStatus | 205 | static enum GNUNET_DB_QueryStatus |
210 | deposit_transaction (void *cls, | 206 | deposit_transaction (void *cls, |
211 | struct MHD_Connection *connection, | 207 | struct MHD_Connection *connection, |
212 | struct TALER_EXCHANGEDB_Session *session, | ||
213 | MHD_RESULT *mhd_ret) | 208 | MHD_RESULT *mhd_ret) |
214 | { | 209 | { |
215 | struct DepositContext *dc = cls; | 210 | struct DepositContext *dc = cls; |
@@ -220,7 +215,6 @@ deposit_transaction (void *cls, | |||
220 | /* make sure coin is 'known' in database */ | 215 | /* make sure coin is 'known' in database */ |
221 | qs = TEH_make_coin_known (&deposit->coin, | 216 | qs = TEH_make_coin_known (&deposit->coin, |
222 | connection, | 217 | connection, |
223 | session, | ||
224 | mhd_ret); | 218 | mhd_ret); |
225 | if (qs < 0) | 219 | if (qs < 0) |
226 | return qs; | 220 | return qs; |
@@ -230,7 +224,6 @@ deposit_transaction (void *cls, | |||
230 | that we are in the transaction scope. */ | 224 | that we are in the transaction scope. */ |
231 | qs = deposit_precheck (cls, | 225 | qs = deposit_precheck (cls, |
232 | connection, | 226 | connection, |
233 | session, | ||
234 | mhd_ret); | 227 | mhd_ret); |
235 | if (qs < 0) | 228 | if (qs < 0) |
236 | return qs; | 229 | return qs; |
@@ -244,7 +237,6 @@ deposit_transaction (void *cls, | |||
244 | struct TALER_EXCHANGEDB_TransactionList *tl; | 237 | struct TALER_EXCHANGEDB_TransactionList *tl; |
245 | 238 | ||
246 | qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, | 239 | qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls, |
247 | session, | ||
248 | &deposit->coin.coin_pub, | 240 | &deposit->coin.coin_pub, |
249 | GNUNET_NO, | 241 | GNUNET_NO, |
250 | &tl); | 242 | &tl); |
@@ -292,7 +284,6 @@ deposit_transaction (void *cls, | |||
292 | tl); | 284 | tl); |
293 | } | 285 | } |
294 | qs = TEH_plugin->insert_deposit (TEH_plugin->cls, | 286 | qs = TEH_plugin->insert_deposit (TEH_plugin->cls, |
295 | session, | ||
296 | dc->exchange_timestamp, | 287 | dc->exchange_timestamp, |
297 | deposit); | 288 | deposit); |
298 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) | 289 | if (GNUNET_DB_STATUS_HARD_ERROR == qs) |
diff --git a/src/exchange/taler-exchange-httpd_deposits_get.c b/src/exchange/taler-exchange-httpd_deposits_get.c index f32b88b6d..04e2acb02 100644 --- a/src/exchange/taler-exchange-httpd_deposits_get.c +++ b/src/exchange/taler-exchange-httpd_deposits_get.c | |||
@@ -203,7 +203,6 @@ handle_wtid_data (void *cls, | |||
203 | * | 203 | * |
204 | * @param cls closure of type `struct DepositWtidContext *` | 204 | * @param cls closure of type `struct DepositWtidContext *` |
205 | * @param connection MHD request which triggered the transaction | 205 | * @param connection MHD request which triggered the transaction |
206 | * @param session database session to use | ||
207 | * @param[out] mhd_ret set to MHD response status for @a connection, | 206 | * @param[out] mhd_ret set to MHD response status for @a connection, |
208 | * if transaction failed (!) | 207 | * if transaction failed (!) |
209 | * @return transaction status | 208 | * @return transaction status |
@@ -211,14 +210,12 @@ handle_wtid_data (void *cls, | |||
211 | static enum GNUNET_DB_QueryStatus | 210 | static enum GNUNET_DB_QueryStatus |
212 | deposits_get_transaction (void *cls, | 211 | deposits_get_transaction (void *cls, |
213 | struct MHD_Connection *connection, | 212 | struct MHD_Connection *connection, |
214 | struct TALER_EXCHANGEDB_Session *session, | ||
215 | MHD_RESULT *mhd_ret) | 213 | MHD_RESULT *mhd_ret) |
216 | { | 214 | { |
217 | struct DepositWtidContext *ctx = cls; | 215 | struct DepositWtidContext *ctx = cls; |
218 | enum GNUNET_DB_QueryStatus qs; | 216 | enum GNUNET_DB_QueryStatus qs; |
219 | 217 | ||
220 | qs = TEH_plugin->lookup_transfer_by_deposit (TEH_plugin->cls, | 218 | qs = TEH_plugin->lookup_transfer_by_deposit (TEH_plugin->cls, |
221 | session, | ||
222 | &ctx->tps->h_contract_terms, | 219 | &ctx->tps->h_contract_terms, |
223 | &ctx->tps->h_wire, | 220 | &ctx->tps->h_wire, |
224 | &ctx->tps->coin_pub, | 221 | &ctx->tps->coin_pub, |
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index 216afd7c5..f37aafbd1 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * @author Christian Grothoff | 19 | * @author Christian Grothoff |
20 | */ | 20 | */ |
21 | #include "platform.h" | 21 | #include "platform.h" |
22 | #include <pthread.h> | ||
23 | #include "taler_json_lib.h" | 22 | #include "taler_json_lib.h" |
24 | #include "taler_mhd_lib.h" | 23 | #include "taler_mhd_lib.h" |
25 | #include "taler-exchange-httpd.h" | 24 | #include "taler-exchange-httpd.h" |
@@ -339,10 +338,9 @@ struct SuspendedKeysRequests | |||
339 | 338 | ||
340 | 339 | ||
341 | /** | 340 | /** |
342 | * Thread-local. Contains a pointer to `struct TEH_KeyStateHandle` or NULL. | 341 | * Stores the latest generation of our key state. |
343 | * Stores the per-thread latest generation of our key state. | ||
344 | */ | 342 | */ |
345 | static pthread_key_t key_state; | 343 | static struct TEH_KeyStateHandle *key_state; |
346 | 344 | ||
347 | /** | 345 | /** |
348 | * Counter incremented whenever we have a reason to re-build the keys because | 346 | * Counter incremented whenever we have a reason to re-build the keys because |
@@ -351,7 +349,7 @@ static pthread_key_t key_state; | |||
351 | * changes, the variable MUST be volatile. See #TEH_keys_get_state() and | 349 | * changes, the variable MUST be volatile. See #TEH_keys_get_state() and |
352 | * #TEH_keys_update_states() for uses of this variable. | 350 | * #TEH_keys_update_states() for uses of this variable. |
353 | */ | 351 | */ |
354 | static volatile uint64_t key_generation; | 352 | static uint64_t key_generation; |
355 | 353 | ||
356 | /** | 354 | /** |
357 | * Head of DLL of suspended /keys requests. | 355 | * Head of DLL of suspended /keys requests. |
@@ -392,29 +390,11 @@ static struct TALER_SecurityModulePublicKeyP denom_sm_pub; | |||
392 | static struct TALER_SecurityModulePublicKeyP esign_sm_pub; | 390 | static struct TALER_SecurityModulePublicKeyP esign_sm_pub; |
393 | 391 | ||
394 | /** | 392 | /** |
395 | * Mutex protecting access to #denom_sm_pub and #esign_sm_pub. | ||
396 | * (Could be split into two locks if ever needed.) | ||
397 | */ | ||
398 | static pthread_mutex_t sm_pub_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
399 | |||
400 | /** | ||
401 | * Mutex protecting access to #skr_head and #skr_tail. | ||
402 | * (Could be split into two locks if ever needed.) | ||
403 | */ | ||
404 | static pthread_mutex_t skr_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
405 | |||
406 | /** | ||
407 | * Are we shutting down? | 393 | * Are we shutting down? |
408 | */ | 394 | */ |
409 | static bool terminating; | 395 | static bool terminating; |
410 | 396 | ||
411 | /** | 397 | /** |
412 | * Did we ever initialize #key_state? | ||
413 | */ | ||
414 | static bool key_state_available; | ||
415 | |||
416 | |||
417 | /** | ||
418 | * Suspend /keys request while we (hopefully) are waiting to be | 398 | * Suspend /keys request while we (hopefully) are waiting to be |
419 | * provisioned with key material. | 399 | * provisioned with key material. |
420 | * | 400 | * |
@@ -427,10 +407,8 @@ suspend_request (struct MHD_Connection *connection) | |||
427 | 407 | ||
428 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 408 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
429 | "Suspending /keys request until key material changes\n"); | 409 | "Suspending /keys request until key material changes\n"); |
430 | GNUNET_assert (0 == pthread_mutex_lock (&skr_mutex)); | ||
431 | if (terminating) | 410 | if (terminating) |
432 | { | 411 | { |
433 | GNUNET_assert (0 == pthread_mutex_unlock (&skr_mutex)); | ||
434 | return TALER_MHD_reply_with_error (connection, | 412 | return TALER_MHD_reply_with_error (connection, |
435 | MHD_HTTP_INTERNAL_SERVER_ERROR, | 413 | MHD_HTTP_INTERNAL_SERVER_ERROR, |
436 | TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING, | 414 | TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING, |
@@ -452,9 +430,9 @@ suspend_request (struct MHD_Connection *connection) | |||
452 | skr_size--; | 430 | skr_size--; |
453 | skr_connection = skr->connection; | 431 | skr_connection = skr->connection; |
454 | MHD_resume_connection (skr->connection); | 432 | MHD_resume_connection (skr->connection); |
433 | TALER_MHD_daemon_trigger (); | ||
455 | GNUNET_free (skr); | 434 | GNUNET_free (skr); |
456 | } | 435 | } |
457 | GNUNET_assert (0 == pthread_mutex_unlock (&skr_mutex)); | ||
458 | return MHD_YES; | 436 | return MHD_YES; |
459 | } | 437 | } |
460 | 438 | ||
@@ -464,7 +442,6 @@ TEH_resume_keys_requests (bool do_shutdown) | |||
464 | { | 442 | { |
465 | struct SuspendedKeysRequests *skr; | 443 | struct SuspendedKeysRequests *skr; |
466 | 444 | ||
467 | GNUNET_assert (0 == pthread_mutex_lock (&skr_mutex)); | ||
468 | if (do_shutdown) | 445 | if (do_shutdown) |
469 | terminating = true; | 446 | terminating = true; |
470 | while (NULL != (skr = skr_head)) | 447 | while (NULL != (skr = skr_head)) |
@@ -474,9 +451,9 @@ TEH_resume_keys_requests (bool do_shutdown) | |||
474 | skr); | 451 | skr); |
475 | skr_size--; | 452 | skr_size--; |
476 | MHD_resume_connection (skr->connection); | 453 | MHD_resume_connection (skr->connection); |
454 | TALER_MHD_daemon_trigger (); | ||
477 | GNUNET_free (skr); | 455 | GNUNET_free (skr); |
478 | } | 456 | } |
479 | GNUNET_assert (0 == pthread_mutex_unlock (&skr_mutex)); | ||
480 | } | 457 | } |
481 | 458 | ||
482 | 459 | ||
@@ -510,7 +487,6 @@ clear_response_cache (struct TEH_KeyStateHandle *ksh) | |||
510 | static void | 487 | static void |
511 | check_denom_sm_pub (const struct TALER_SecurityModulePublicKeyP *sm_pub) | 488 | check_denom_sm_pub (const struct TALER_SecurityModulePublicKeyP *sm_pub) |
512 | { | 489 | { |
513 | GNUNET_assert (0 == pthread_mutex_lock (&sm_pub_mutex)); | ||
514 | if (0 != | 490 | if (0 != |
515 | GNUNET_memcmp (sm_pub, | 491 | GNUNET_memcmp (sm_pub, |
516 | &denom_sm_pub)) | 492 | &denom_sm_pub)) |
@@ -523,7 +499,6 @@ check_denom_sm_pub (const struct TALER_SecurityModulePublicKeyP *sm_pub) | |||
523 | } | 499 | } |
524 | denom_sm_pub = *sm_pub; /* TOFU ;-) */ | 500 | denom_sm_pub = *sm_pub; /* TOFU ;-) */ |
525 | } | 501 | } |
526 | GNUNET_assert (0 == pthread_mutex_unlock (&sm_pub_mutex)); | ||
527 | } | 502 | } |
528 | 503 | ||
529 | 504 | ||
@@ -536,7 +511,6 @@ check_denom_sm_pub (const struct TALER_SecurityModulePublicKeyP *sm_pub) | |||
536 | static void | 511 | static void |
537 | check_esign_sm_pub (const struct TALER_SecurityModulePublicKeyP *sm_pub) | 512 | check_esign_sm_pub (const struct TALER_SecurityModulePublicKeyP *sm_pub) |
538 | { | 513 | { |
539 | GNUNET_assert (0 == pthread_mutex_lock (&sm_pub_mutex)); | ||
540 | if (0 != | 514 | if (0 != |
541 | GNUNET_memcmp (sm_pub, | 515 | GNUNET_memcmp (sm_pub, |
542 | &esign_sm_pub)) | 516 | &esign_sm_pub)) |
@@ -549,7 +523,6 @@ check_esign_sm_pub (const struct TALER_SecurityModulePublicKeyP *sm_pub) | |||
549 | } | 523 | } |
550 | esign_sm_pub = *sm_pub; /* TOFU ;-) */ | 524 | esign_sm_pub = *sm_pub; /* TOFU ;-) */ |
551 | } | 525 | } |
552 | GNUNET_assert (0 == pthread_mutex_unlock (&sm_pub_mutex)); | ||
553 | } | 526 | } |
554 | 527 | ||
555 | 528 | ||
@@ -896,38 +869,9 @@ destroy_key_state (struct TEH_KeyStateHandle *ksh, | |||
896 | } | 869 | } |
897 | 870 | ||
898 | 871 | ||
899 | /** | ||
900 | * Free all resources associated with @a cls. Called when | ||
901 | * the respective pthread is destroyed. | ||
902 | * | ||
903 | * @param[in] cls a `struct TEH_KeyStateHandle`. | ||
904 | */ | ||
905 | static void | ||
906 | destroy_key_state_cb (void *cls) | ||
907 | { | ||
908 | struct TEH_KeyStateHandle *ksh = cls; | ||
909 | |||
910 | destroy_key_state (ksh, | ||
911 | true); | ||
912 | } | ||
913 | |||
914 | |||
915 | /** | ||
916 | * Initialize keys submodule. | ||
917 | * | ||
918 | * @return #GNUNET_OK on success | ||
919 | */ | ||
920 | int | 872 | int |
921 | TEH_keys_init () | 873 | TEH_keys_init () |
922 | { | 874 | { |
923 | if (0 != | ||
924 | pthread_key_create (&key_state, | ||
925 | &destroy_key_state_cb)) | ||
926 | { | ||
927 | GNUNET_break (0); | ||
928 | return GNUNET_SYSERR; | ||
929 | } | ||
930 | key_state_available = true; | ||
931 | if (GNUNET_OK != | 875 | if (GNUNET_OK != |
932 | GNUNET_CONFIGURATION_get_value_time (TEH_cfg, | 876 | GNUNET_CONFIGURATION_get_value_time (TEH_cfg, |
933 | "exchange", | 877 | "exchange", |
@@ -949,11 +893,9 @@ TEH_keys_init () | |||
949 | void __attribute__ ((destructor)) | 893 | void __attribute__ ((destructor)) |
950 | TEH_keys_finished () | 894 | TEH_keys_finished () |
951 | { | 895 | { |
952 | if (key_state_available) | 896 | if (NULL != key_state) |
953 | { | 897 | destroy_key_state (key_state, |
954 | GNUNET_assert (0 == | 898 | true); |
955 | pthread_key_delete (key_state)); | ||
956 | } | ||
957 | } | 899 | } |
958 | 900 | ||
959 | 901 | ||
@@ -1799,22 +1741,14 @@ get_key_state (bool management_only) | |||
1799 | struct TEH_KeyStateHandle *old_ksh; | 1741 | struct TEH_KeyStateHandle *old_ksh; |
1800 | struct TEH_KeyStateHandle *ksh; | 1742 | struct TEH_KeyStateHandle *ksh; |
1801 | 1743 | ||
1802 | GNUNET_assert (key_state_available); | 1744 | old_ksh = key_state; |
1803 | old_ksh = pthread_getspecific (key_state); | ||
1804 | if (NULL == old_ksh) | 1745 | if (NULL == old_ksh) |
1805 | { | 1746 | { |
1806 | ksh = build_key_state (NULL, | 1747 | ksh = build_key_state (NULL, |
1807 | management_only); | 1748 | management_only); |
1808 | if (NULL == ksh) | 1749 | if (NULL == ksh) |
1809 | return NULL; | 1750 | return NULL; |
1810 | if (0 != pthread_setspecific (key_state, | 1751 | key_state = ksh; |
1811 | ksh)) | ||
1812 | { | ||
1813 | GNUNET_break (0); | ||
1814 | destroy_key_state (ksh, | ||
1815 | true); | ||
1816 | return NULL; | ||
1817 | } | ||
1818 | return ksh; | 1752 | return ksh; |
1819 | } | 1753 | } |
1820 | if ( (old_ksh->key_generation < key_generation) || | 1754 | if ( (old_ksh->key_generation < key_generation) || |
@@ -1826,15 +1760,7 @@ get_key_state (bool management_only) | |||
1826 | (unsigned long long) key_generation); | 1760 | (unsigned long long) key_generation); |
1827 | ksh = build_key_state (old_ksh->helpers, | 1761 | ksh = build_key_state (old_ksh->helpers, |
1828 | management_only); | 1762 | management_only); |
1829 | if (0 != pthread_setspecific (key_state, | 1763 | key_state = ksh; |
1830 | ksh)) | ||
1831 | { | ||
1832 | GNUNET_break (0); | ||
1833 | if (NULL != ksh) | ||
1834 | destroy_key_state (ksh, | ||
1835 | false); | ||
1836 | return NULL; | ||
1837 | } | ||
1838 | old_ksh->helpers = NULL; | 1764 | old_ksh->helpers = NULL; |
1839 | destroy_key_state (old_ksh, | 1765 | destroy_key_state (old_ksh, |
1840 | false); | 1766 | false); |
@@ -2099,17 +2025,14 @@ TEH_keys_get_handler (struct TEH_RequestContext *rc, | |||
2099 | ksh = TEH_keys_get_state (); | 2025 | ksh = TEH_keys_get_state (); |
2100 | if (NULL == ksh) | 2026 | if (NULL == ksh) |
2101 | { | 2027 | { |
2102 | GNUNET_assert (0 == pthread_mutex_lock (&skr_mutex)); | ||
2103 | if ( (SKR_LIMIT == skr_size) && | 2028 | if ( (SKR_LIMIT == skr_size) && |
2104 | (rc->connection == skr_connection) ) | 2029 | (rc->connection == skr_connection) ) |
2105 | { | 2030 | { |
2106 | GNUNET_assert (0 == pthread_mutex_unlock (&skr_mutex)); | ||
2107 | return TALER_MHD_reply_with_error (rc->connection, | 2031 | return TALER_MHD_reply_with_error (rc->connection, |
2108 | MHD_HTTP_INTERNAL_SERVER_ERROR, | 2032 | MHD_HTTP_INTERNAL_SERVER_ERROR, |
2109 | TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING, | 2033 | TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING, |
2110 | "too many connections suspended on /keys"); | 2034 | "too many connections suspended on /keys"); |
2111 | } | 2035 | } |
2112 | GNUNET_assert (0 == pthread_mutex_unlock (&skr_mutex)); | ||
2113 | return suspend_request (rc->connection); | 2036 | return suspend_request (rc->connection); |
2114 | } | 2037 | } |
2115 | krd = bsearch (&last_issue_date, | 2038 | krd = bsearch (&last_issue_date, |
diff --git a/src/exchange/taler-exchange-httpd_link.c b/src/exchange/taler-exchange-httpd_link.c index bbb027522..75d32e562 100644 --- a/src/exchange/taler-exchange-httpd_link.c +++ b/src/exchange/taler-exchange-httpd_link.c | |||
@@ -130,7 +130,6 @@ fail: | |||
130 | * | 130 | * |
131 | * @param cls closure | 131 | * @param cls closure |
132 | * @param connection MHD request which triggered the transaction | 132 | * @param connection MHD request which triggered the transaction |
133 | * @param session database session to use | ||
134 | * @param[out] mhd_ret set to MHD response status for @a connection, | 133 | * @param[out] mhd_ret set to MHD response status for @a connection, |
135 | * if transaction failed (!) | 134 | * if transaction failed (!) |
136 | * @return transaction status | 135 | * @return transaction status |
@@ -138,14 +137,12 @@ fail: | |||
138 | static enum GNUNET_DB_QueryStatus | 137 | static enum GNUNET_DB_QueryStatus |
139 | link_transaction (void *cls, | 138 | link_transaction (void *cls, |
140 | struct MHD_Connection *connection, | 139 | struct MHD_Connection *connection, |
141 | struct TALER_EXCHANGEDB_Session *session, | ||
142 | MHD_RESULT *mhd_ret) | 140 | MHD_RESULT *mhd_ret) |
143 | { | 141 | { |
144 | struct HTD_Context *ctx = cls; | 142 | struct HTD_Context *ctx = cls; |
145 | enum GNUNET_DB_QueryStatus qs; | 143 | enum GNUNET_DB_QueryStatus qs; |
146 | 144 | ||
147 | qs = TEH_plugin->get_link_data (TEH_plugin->cls, | 145 | qs = TEH_plugin->get_link_data (TEH_plugin->cls, |
148 | session, | ||
149 | &ctx->coin_pub, | 146 | &ctx->coin_pub, |
150 | &handle_link_data, | 147 | &handle_link_data, |
151 | ctx); | 148 | ctx); |
diff --git a/src/exchange/taler-exchange-httpd_loop.c b/src/exchange/taler-exchange-httpd_loop.c deleted file mode 100644 index 086fbc874..000000000 --- a/src/exchange/taler-exchange-httpd_loop.c +++ /dev/null | |||
@@ -1,209 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2014--2020 Taler Systems SA | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU Affero General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU Affero General Public License along with | ||
14 | TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file taler-exchange-httpd_loop.c | ||
18 | * @brief management of our main loop | ||
19 | * @author Florian Dold | ||
20 | * @author Benedikt Mueller | ||
21 | * @author Christian Grothoff | ||
22 | */ | ||
23 | #include "platform.h" | ||
24 | #include <pthread.h> | ||
25 | #include "taler-exchange-httpd_loop.h" | ||
26 | |||
27 | |||
28 | /* ************************* Signal logic ************************** */ | ||
29 | |||
30 | /** | ||
31 | * Pipe used for signaling reloading of our key state. | ||
32 | */ | ||
33 | static int reload_pipe[2] = { -1, -1 }; | ||
34 | |||
35 | |||
36 | /** | ||
37 | * Handle a signal, writing relevant signal numbers to the pipe. | ||
38 | * | ||
39 | * @param signal_number the signal number | ||
40 | */ | ||
41 | static void | ||
42 | handle_signal (int signal_number) | ||
43 | { | ||
44 | char c = (char) signal_number; /* never seen a signal_number > 127 on any platform */ | ||
45 | |||
46 | (void) ! write (reload_pipe[1], | ||
47 | &c, | ||
48 | 1); | ||
49 | /* While one might like to "handle errors" here, even logging via fprintf() | ||
50 | isn't safe inside of a signal handler. So there is nothing we safely CAN | ||
51 | do. OTOH, also very little that can go wrong in practice. Calling _exit() | ||
52 | on errors might be a possibility, but that might do more harm than good. */// | ||
53 | } | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Call #handle_signal() to pass the received signal via | ||
58 | * the control pipe. | ||
59 | */ | ||
60 | static void | ||
61 | handle_sigint (void) | ||
62 | { | ||
63 | handle_signal (SIGINT); | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * Call #handle_signal() to pass the received signal via | ||
69 | * the control pipe. | ||
70 | */ | ||
71 | static void | ||
72 | handle_sigterm (void) | ||
73 | { | ||
74 | handle_signal (SIGTERM); | ||
75 | } | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Call #handle_signal() to pass the received signal via | ||
80 | * the control pipe. | ||
81 | */ | ||
82 | static void | ||
83 | handle_sighup (void) | ||
84 | { | ||
85 | handle_signal (SIGHUP); | ||
86 | } | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Call #handle_signal() to pass the received signal via | ||
91 | * the control pipe. | ||
92 | */ | ||
93 | static void | ||
94 | handle_sigchld (void) | ||
95 | { | ||
96 | handle_signal (SIGCHLD); | ||
97 | } | ||
98 | |||
99 | |||
100 | int | ||
101 | TEH_loop_run (void) | ||
102 | { | ||
103 | int ret; | ||
104 | |||
105 | ret = 2; | ||
106 | while (2 == ret) | ||
107 | { | ||
108 | char c; | ||
109 | ssize_t res; | ||
110 | |||
111 | errno = 0; | ||
112 | res = read (reload_pipe[0], | ||
113 | &c, | ||
114 | 1); | ||
115 | if ((res < 0) && (EINTR != errno)) | ||
116 | { | ||
117 | GNUNET_break (0); | ||
118 | ret = GNUNET_SYSERR; | ||
119 | break; | ||
120 | } | ||
121 | if (EINTR == errno) | ||
122 | continue; | ||
123 | switch (c) | ||
124 | { | ||
125 | case SIGTERM: | ||
126 | case SIGINT: | ||
127 | /* terminate */ | ||
128 | ret = GNUNET_OK; | ||
129 | break; | ||
130 | case SIGHUP: | ||
131 | /* restart updated binary */ | ||
132 | ret = GNUNET_NO; | ||
133 | break; | ||
134 | #if HAVE_DEVELOPER | ||
135 | case SIGCHLD: | ||
136 | /* running in test-mode, test finished, terminate */ | ||
137 | ret = GNUNET_OK; | ||
138 | break; | ||
139 | #endif | ||
140 | default: | ||
141 | /* unexpected character */ | ||
142 | GNUNET_break (0); | ||
143 | break; | ||
144 | } | ||
145 | } | ||
146 | return ret; | ||
147 | } | ||
148 | |||
149 | |||
150 | static struct GNUNET_SIGNAL_Context *sigterm; | ||
151 | static struct GNUNET_SIGNAL_Context *sigint; | ||
152 | static struct GNUNET_SIGNAL_Context *sighup; | ||
153 | static struct GNUNET_SIGNAL_Context *sigchld; | ||
154 | |||
155 | |||
156 | int | ||
157 | TEH_loop_init (void) | ||
158 | { | ||
159 | if (0 != pipe (reload_pipe)) | ||
160 | { | ||
161 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
162 | "pipe"); | ||
163 | return GNUNET_SYSERR; | ||
164 | } | ||
165 | sigterm = GNUNET_SIGNAL_handler_install (SIGTERM, | ||
166 | &handle_sigterm); | ||
167 | sigint = GNUNET_SIGNAL_handler_install (SIGINT, | ||
168 | &handle_sigint); | ||
169 | sighup = GNUNET_SIGNAL_handler_install (SIGHUP, | ||
170 | &handle_sighup); | ||
171 | sigchld = GNUNET_SIGNAL_handler_install (SIGCHLD, | ||
172 | &handle_sigchld); | ||
173 | return GNUNET_OK; | ||
174 | } | ||
175 | |||
176 | |||
177 | void | ||
178 | TEH_loop_done (void) | ||
179 | { | ||
180 | if (NULL != sigterm) | ||
181 | { | ||
182 | GNUNET_SIGNAL_handler_uninstall (sigterm); | ||
183 | sigterm = NULL; | ||
184 | } | ||
185 | if (NULL != sigint) | ||
186 | { | ||
187 | GNUNET_SIGNAL_handler_uninstall (sigint); | ||
188 | sigint = NULL; | ||
189 | } | ||
190 | if (NULL != sighup) | ||
191 | { | ||
192 | GNUNET_SIGNAL_handler_uninstall (sighup); | ||
193 | sighup = NULL; | ||
194 | } | ||
195 | if (NULL != sigchld) | ||
196 | { | ||
197 | GNUNET_SIGNAL_handler_uninstall (sigchld); | ||
198 | sigchld = NULL; | ||
199 | } | ||
200 | if (-1 != reload_pipe[0]) | ||
201 | { | ||
202 | GNUNET_break (0 == close (reload_pipe[0])); | ||
203 | GNUNET_break (0 == close (reload_pipe[1])); | ||
204 | reload_pipe[0] = reload_pipe[1] = -1; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | |||
209 | /* end of taler-exchange-httpd_loop.c */ | ||
diff --git a/src/exchange/taler-exchange-httpd_loop.h b/src/exchange/taler-exchange-httpd_loop.h deleted file mode 100644 index 700f56776..000000000 --- a/src/exchange/taler-exchange-httpd_loop.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | Copyright (C) 2014, 2015 Taler Systems SA | ||
4 | |||
5 | TALER is free software; you can redistribute it and/or modify it under the | ||
6 | terms of the GNU Affero General Public License as published by the Free Software | ||
7 | Foundation; either version 3, or (at your option) any later version. | ||
8 | |||
9 | TALER is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
11 | A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU Affero General Public License along with | ||
14 | TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | /** | ||
17 | * @file exchange/taler-exchange-httpd_loop.h | ||
18 | * @brief management of our main loop | ||
19 | * @author Florian Dold | ||
20 | * @author Benedikt Mueller | ||
21 | * @author Christian Grothoff | ||
22 | */ | ||
23 | #ifndef TALER_EXCHANGE_HTTPD_LOOP_H | ||
24 | #define TALER_EXCHANGE_HTTPD_LOOP_H | ||
25 | |||
26 | #include <gnunet/gnunet_util_lib.h> | ||
27 | #include <microhttpd.h> | ||
28 | #include "taler-exchange-httpd.h" | ||
29 | |||
30 | |||
31 | /** | ||
32 | * Setup our signal handlers. | ||
33 | * | ||
34 | * @return #GNUNET_OK on success | ||
35 | */ | ||
36 | int | ||
37 | TEH_loop_init (void); | ||
38 | |||
39 | |||
40 | /** | ||
41 | * Finally, tear down our signal handlers. | ||
42 | */ | ||
43 | void | ||
44 | TEH_loop_done (void); | ||
45 | |||
46 | |||
47 | /** | ||
48 | * Read signals from a pipe in a loop, and reload keys from disk if | ||
49 | * SIGUSR1 is received, terminate if SIGTERM/SIGINT is received, and | ||
50 | * restart if SIGHUP is received. | ||
51 | * | ||
52 | * @return #GNUNET_SYSERR on errors, | ||
53 | * #GNUNET_OK to terminate normally | ||
54 | * #GNUNET_NO to restart an update version of the binary | ||
55 | */ | ||
56 | int | ||
57 | TEH_loop_run (void); | ||
58 | |||
59 | |||
60 | #endif | ||
diff --git a/src/exchange/taler-exchange-httpd_management_auditors.c b/src/exchange/taler-exchange-httpd_management_auditors.c index 77e7d8657..d782618f1 100644 --- a/src/exchange/taler-exchange-httpd_management_auditors.c +++ b/src/exchange/taler-exchange-httpd_management_auditors.c | |||
@@ -74,7 +74,6 @@ struct AddAuditorContext | |||
74 | * | 74 | * |
75 | * @param cls closure with a `struct AddAuditorContext` | 75 | * @param cls closure with a `struct AddAuditorContext` |
76 | * @param connection MHD request which triggered the transaction | 76 | * @param connection MHD request which triggered the transaction |
77 | * @param session database session to use | ||
78 | * @param[out] mhd_ret set to MHD response status for @a connection, | 77 | * @param[out] mhd_ret set to MHD response status for @a connection, |
79 | * if transaction failed (!) | 78 | * if transaction failed (!) |
80 | * @return transaction status | 79 | * @return transaction status |
@@ -82,7 +81,6 @@ struct AddAuditorContext | |||
82 | static enum GNUNET_DB_QueryStatus | 81 | static enum GNUNET_DB_QueryStatus |
83 | add_auditor (void *cls, | 82 | add_auditor (void *cls, |
84 | struct MHD_Connection *connection, | 83 | struct MHD_Connection *connection, |
85 | struct TALER_EXCHANGEDB_Session *session, | ||
86 | MHD_RESULT *mhd_ret) | 84 | MHD_RESULT *mhd_ret) |
87 | { | 85 | { |
88 | struct AddAuditorContext *aac = cls; | 86 | struct AddAuditorContext *aac = cls; |
@@ -90,7 +88,6 @@ add_auditor (void *cls, | |||
90 | enum GNUNET_DB_QueryStatus qs; | 88 | enum GNUNET_DB_QueryStatus qs; |
91 | 89 | ||
92 | qs = TEH_plugin->lookup_auditor_timestamp (TEH_plugin->cls, | 90 | qs = TEH_plugin->lookup_auditor_timestamp (TEH_plugin->cls, |
93 | session, | ||
94 | &aac->auditor_pub, | 91 | &aac->auditor_pub, |
95 | &last_date); | 92 | &last_date); |
96 | if (qs < 0) | 93 | if (qs < 0) |
@@ -116,14 +113,12 @@ add_auditor (void *cls, | |||
116 | } | 113 | } |
117 | if (0 == qs) | 114 | if (0 == qs) |
118 | qs = TEH_plugin->insert_auditor (TEH_plugin->cls, | 115 | qs = TEH_plugin->insert_auditor (TEH_plugin->cls, |
119 | session, | ||
120 | &aac->auditor_pub, | 116 | &aac->auditor_pub, |
121 | aac->auditor_url, | 117 | aac->auditor_url, |
122 | aac->auditor_name, | 118 | aac->auditor_name, |
123 | aac->validity_start); | 119 | aac->validity_start); |
124 | else | 120 | else |
125 | qs = TEH_plugin->update_auditor (TEH_plugin->cls, | 121 | qs = TEH_plugin->update_auditor (TEH_plugin->cls, |
126 | session, | ||
127 | &aac->auditor_pub, | 122 | &aac->auditor_pub, |
128 | aac->auditor_url, | 123 | aac->auditor_url, |
129 | aac->auditor_name, | 124 | aac->auditor_name, |
diff --git a/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c b/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c index 382b0f6b4..7bf191f47 100644 --- a/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c +++ b/src/exchange/taler-exchange-httpd_management_auditors_AP_disable.c | |||
@@ -65,7 +65,6 @@ struct DelAuditorContext | |||
65 | * | 65 | * |
66 | * @param cls closure with a `struct DelAuditorContext` | 66 | * @param cls closure with a `struct DelAuditorContext` |
67 | * @param connection MHD request which triggered the transaction | 67 | * @param connection MHD request which triggered the transaction |
68 | * @param session database session to use | ||
69 | * @param[out] mhd_ret set to MHD response status for @a connection, | 68 | * @param[out] mhd_ret set to MHD response status for @a connection, |
70 | * if transaction failed (!) | 69 | * if transaction failed (!) |
71 | * @return transaction status | 70 | * @return transaction status |
@@ -73,7 +72,6 @@ struct DelAuditorContext | |||
73 | static enum GNUNET_DB_QueryStatus | 72 | static enum GNUNET_DB_QueryStatus |
74 | del_auditor (void *cls, | 73 | del_auditor (void *cls, |
75 | struct MHD_Connection *connection, | 74 | struct MHD_Connection *connection, |
76 | struct TALER_EXCHANGEDB_Session *session, | ||
77 | MHD_RESULT *mhd_ret) | 75 | MHD_RESULT *mhd_ret) |
78 | { | 76 | { |
79 | struct DelAuditorContext *dac = cls; | 77 | struct DelAuditorContext *dac = cls; |
@@ -81,7 +79,6 @@ del_auditor (void *cls, | |||
81 | enum GNUNET_DB_QueryStatus qs; | 79 | enum GNUNET_DB_QueryStatus qs; |
82 | 80 | ||
83 | qs = TEH_plugin->lookup_auditor_timestamp (TEH_plugin->cls, | 81 | qs = TEH_plugin->lookup_auditor_timestamp (TEH_plugin->cls, |
84 | session, | ||
85 | &dac->auditor_pub, | 82 | &dac->auditor_pub, |
86 | &last_date); | 83 | &last_date); |
87 | if (qs < 0) | 84 | if (qs < 0) |
@@ -114,7 +111,6 @@ del_auditor (void *cls, | |||
114 | return GNUNET_DB_STATUS_HARD_ERROR; | 111 | return GNUNET_DB_STATUS_HARD_ERROR; |
115 | } | 112 | } |
116 | qs = TEH_plugin->update_auditor (TEH_plugin->cls, | 113 | qs = TEH_plugin->update_auditor (TEH_plugin->cls, |
117 | session, | ||
118 | &dac->auditor_pub, | 114 | &dac->auditor_pub, |
119 | "", /* auditor URL */ | 115 | "", /* auditor URL */ |
120 | "", /* auditor name */ | 116 | "", /* auditor name */ |
diff --git a/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c b/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c index 1a89652e8..6519404df 100644 --- a/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c +++ b/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c | |||
@@ -70,7 +70,6 @@ TEH_handler_management_denominations_HDP_revoke ( | |||
70 | NULL); | 70 | NULL); |
71 | } | 71 | } |
72 | qs = TEH_plugin->insert_denomination_revocation (TEH_plugin->cls, | 72 | qs = TEH_plugin->insert_denomination_revocation (TEH_plugin->cls, |
73 | NULL, | ||
74 | h_denom_pub, | 73 | h_denom_pub, |
75 | &master_sig); | 74 | &master_sig); |
76 | if (qs < 0) | 75 | if (qs < 0) |
diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c b/src/exchange/taler-exchange-httpd_management_post_keys.c index 0e4eb9894..311fff781 100644 --- a/src/exchange/taler-exchange-httpd_management_post_keys.c +++ b/src/exchange/taler-exchange-httpd_management_post_keys.c | |||
@@ -107,7 +107,6 @@ struct AddKeysContext | |||
107 | * | 107 | * |
108 | * @param cls closure with a `struct AddKeysContext` | 108 | * @param cls closure with a `struct AddKeysContext` |
109 | * @param connection MHD request which triggered the transaction | 109 | * @param connection MHD request which triggered the transaction |
110 | * @param session database session to use | ||
111 | * @param[out] mhd_ret set to MHD response status for @a connection, | 110 | * @param[out] mhd_ret set to MHD response status for @a connection, |
112 | * if transaction failed (!) | 111 | * if transaction failed (!) |
113 | * @return transaction status | 112 | * @return transaction status |
@@ -115,7 +114,6 @@ struct AddKeysContext | |||
115 | static enum GNUNET_DB_QueryStatus | 114 | static enum GNUNET_DB_QueryStatus |
116 | add_keys (void *cls, | 115 | add_keys (void *cls, |
117 | struct MHD_Connection *connection, | 116 | struct MHD_Connection *connection, |
118 | struct TALER_EXCHANGEDB_Session *session, | ||
119 | MHD_RESULT *mhd_ret) | 117 | MHD_RESULT *mhd_ret) |
120 | { | 118 | { |
121 | struct AddKeysContext *akc = cls; | 119 | struct AddKeysContext *akc = cls; |
@@ -131,7 +129,6 @@ add_keys (void *cls, | |||
131 | /* For idempotency, check if the key is already active */ | 129 | /* For idempotency, check if the key is already active */ |
132 | qs = TEH_plugin->lookup_denomination_key ( | 130 | qs = TEH_plugin->lookup_denomination_key ( |
133 | TEH_plugin->cls, | 131 | TEH_plugin->cls, |
134 | session, | ||
135 | &akc->d_sigs[i].h_denom_pub, | 132 | &akc->d_sigs[i].h_denom_pub, |
136 | &meta); | 133 | &meta); |
137 | if (qs < 0) | 134 | if (qs < 0) |
@@ -207,7 +204,6 @@ add_keys (void *cls, | |||
207 | continue; /* skip, already known */ | 204 | continue; /* skip, already known */ |
208 | qs = TEH_plugin->add_denomination_key ( | 205 | qs = TEH_plugin->add_denomination_key ( |
209 | TEH_plugin->cls, | 206 | TEH_plugin-> |