aboutsummaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-wirewatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/taler-exchange-wirewatch.c')
-rw-r--r--src/exchange/taler-exchange-wirewatch.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c
index 2993999a8..fb1fde31d 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -63,11 +63,6 @@ struct WireAccount
63 const struct TALER_EXCHANGEDB_AccountInfo *ai; 63 const struct TALER_EXCHANGEDB_AccountInfo *ai;
64 64
65 /** 65 /**
66 * Database session we are using for the current transaction.
67 */
68 struct TALER_EXCHANGEDB_Session *session;
69
70 /**
71 * Active request for history. 66 * Active request for history.
72 */ 67 */
73 struct TALER_BANK_CreditHistoryHandle *hh; 68 struct TALER_BANK_CreditHistoryHandle *hh;
@@ -355,8 +350,7 @@ find_transfers (void *cls);
355static void 350static void
356handle_soft_error (struct WireAccount *wa) 351handle_soft_error (struct WireAccount *wa)
357{ 352{
358 db_plugin->rollback (db_plugin->cls, 353 db_plugin->rollback (db_plugin->cls);
359 wa->session);
360 if (1 < wa->batch_size) 354 if (1 < wa->batch_size)
361 { 355 {
362 wa->batch_thresh = wa->batch_size; 356 wa->batch_thresh = wa->batch_size;
@@ -386,7 +380,6 @@ do_commit (struct WireAccount *wa)
386 { 380 {
387 /* shard is complete, mark this as well */ 381 /* shard is complete, mark this as well */
388 qs = db_plugin->complete_shard (db_plugin->cls, 382 qs = db_plugin->complete_shard (db_plugin->cls,
389 wa->session,
390 wa->job_name, 383 wa->job_name,
391 wa->shard_start, 384 wa->shard_start,
392 wa->shard_end); 385 wa->shard_end);
@@ -394,8 +387,7 @@ do_commit (struct WireAccount *wa)
394 { 387 {
395 case GNUNET_DB_STATUS_HARD_ERROR: 388 case GNUNET_DB_STATUS_HARD_ERROR:
396 GNUNET_break (0); 389 GNUNET_break (0);
397 db_plugin->rollback (db_plugin->cls, 390 db_plugin->rollback (db_plugin->cls);
398 wa->session);
399 GNUNET_SCHEDULER_shutdown (); 391 GNUNET_SCHEDULER_shutdown ();
400 return; 392 return;
401 case GNUNET_DB_STATUS_SOFT_ERROR: 393 case GNUNET_DB_STATUS_SOFT_ERROR:
@@ -413,8 +405,7 @@ do_commit (struct WireAccount *wa)
413 break; 405 break;
414 } 406 }
415 } 407 }
416 qs = db_plugin->commit (db_plugin->cls, 408 qs = db_plugin->commit (db_plugin->cls);
417 wa->session);
418 switch (qs) 409 switch (qs)
419 { 410 {
420 case GNUNET_DB_STATUS_HARD_ERROR: 411 case GNUNET_DB_STATUS_HARD_ERROR:
@@ -432,7 +423,6 @@ do_commit (struct WireAccount *wa)
432 } 423 }
433 /* transaction success, update #last_row_off */ 424 /* transaction success, update #last_row_off */
434 wa->batch_start = wa->latest_row_off; 425 wa->batch_start = wa->latest_row_off;
435 wa->session = NULL; /* should not be needed */
436 if (wa->batch_size < MAXIMUM_BATCH_SIZE) 426 if (wa->batch_size < MAXIMUM_BATCH_SIZE)
437 { 427 {
438 int delta; 428 int delta;
@@ -492,7 +482,6 @@ history_cb (void *cls,
492 const json_t *json) 482 const json_t *json)
493{ 483{
494 struct WireAccount *wa = cls; 484 struct WireAccount *wa = cls;
495 struct TALER_EXCHANGEDB_Session *session = wa->session;
496 enum GNUNET_DB_QueryStatus qs; 485 enum GNUNET_DB_QueryStatus qs;
497 486
498 (void) json; 487 (void) json;
@@ -518,8 +507,7 @@ history_cb (void *cls,
518 "Serial ID %llu not monotonic (got %llu before). Failing!\n", 507 "Serial ID %llu not monotonic (got %llu before). Failing!\n",
519 (unsigned long long) serial_id, 508 (unsigned long long) serial_id,
520 (unsigned long long) wa->latest_row_off); 509 (unsigned long long) wa->latest_row_off);
521 db_plugin->rollback (db_plugin->cls, 510 db_plugin->rollback (db_plugin->cls);
522 session);
523 GNUNET_SCHEDULER_shutdown (); 511 GNUNET_SCHEDULER_shutdown ();
524 wa->hh = NULL; 512 wa->hh = NULL;
525 return GNUNET_SYSERR; 513 return GNUNET_SYSERR;
@@ -547,7 +535,6 @@ history_cb (void *cls,
547 (Note: this may require changing both the 535 (Note: this may require changing both the
548 plugin API as well as modifying how this function is called.) */ 536 plugin API as well as modifying how this function is called.) */
549 qs = db_plugin->reserves_in_insert (db_plugin->cls, 537 qs = db_plugin->reserves_in_insert (db_plugin->cls,
550 session,
551 &details->reserve_pub, 538 &details->reserve_pub,
552 &details->amount, 539 &details->amount,
553 details->execution_date, 540 details->execution_date,
@@ -558,8 +545,7 @@ history_cb (void *cls,
558 { 545 {
559 case GNUNET_DB_STATUS_HARD_ERROR: 546 case GNUNET_DB_STATUS_HARD_ERROR:
560 GNUNET_break (0); 547 GNUNET_break (0);
561 db_plugin->rollback (db_plugin->cls, 548 db_plugin->rollback (db_plugin->cls);
562 session);
563 GNUNET_SCHEDULER_shutdown (); 549 GNUNET_SCHEDULER_shutdown ();
564 wa->hh = NULL; 550 wa->hh = NULL;
565 return GNUNET_SYSERR; 551 return GNUNET_SYSERR;
@@ -590,23 +576,22 @@ history_cb (void *cls,
590static void 576static void
591find_transfers (void *cls) 577find_transfers (void *cls)
592{ 578{
593 struct TALER_EXCHANGEDB_Session *session;
594 enum GNUNET_DB_QueryStatus qs; 579 enum GNUNET_DB_QueryStatus qs;
595 unsigned int limit; 580 unsigned int limit;
596 581
597 (void) cls; 582 (void) cls;
598 task = NULL; 583 task = NULL;
599 if (NULL == (session = db_plugin->get_session (db_plugin->cls))) 584 if (GNUNET_SYSERR ==
585 db_plugin->preflight (db_plugin->cls))
600 { 586 {
601 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 587 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
602 "Failed to obtain database session!\n"); 588 "Failed to obtain database connection!\n");
603 global_ret = EXIT_FAILURE; 589 global_ret = EXIT_FAILURE;
604 GNUNET_SCHEDULER_shutdown (); 590 GNUNET_SCHEDULER_shutdown ();
605 return; 591 return;
606 } 592 }
607 wa_pos->delay = true; 593 wa_pos->delay = true;
608 wa_pos->current_batch_size = 0; /* reset counter */ 594 wa_pos->current_batch_size = 0; /* reset counter */
609 wa_pos->session = session;
610 if (wa_pos->shard_end <= wa_pos->batch_start) 595 if (wa_pos->shard_end <= wa_pos->batch_start)
611 { 596 {
612 uint64_t start; 597 uint64_t start;
@@ -662,7 +647,6 @@ find_transfers (void *cls)
662 } 647 }
663 if (GNUNET_OK != 648 if (GNUNET_OK !=
664 db_plugin->start_read_committed (db_plugin->cls, 649 db_plugin->start_read_committed (db_plugin->cls,
665 session,
666 "wirewatch check for incoming wire transfers")) 650 "wirewatch check for incoming wire transfers"))
667 { 651 {
668 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 652 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -689,8 +673,7 @@ find_transfers (void *cls)
689 { 673 {
690 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 674 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
691 "Failed to start request for account history!\n"); 675 "Failed to start request for account history!\n");
692 db_plugin->rollback (db_plugin->cls, 676 db_plugin->rollback (db_plugin->cls);
693 session);
694 global_ret = EXIT_FAILURE; 677 global_ret = EXIT_FAILURE;
695 GNUNET_SCHEDULER_shutdown (); 678 GNUNET_SCHEDULER_shutdown ();
696 return; 679 return;