diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-05-04 00:01:23 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-05-04 00:01:23 +0200 |
commit | 5f4f6262b4e3b1a1b6a88d5dd12c588084e703ad (patch) | |
tree | 6632d41ad09e3b643e83618c373b2e8760be0b9c /src/backend/taler-merchant-exchange.c | |
parent | 8535f1e81939e87258ad9d2503ad25df9cfb021d (diff) | |
download | merchant-5f4f6262b4e3b1a1b6a88d5dd12c588084e703ad.tar.gz merchant-5f4f6262b4e3b1a1b6a88d5dd12c588084e703ad.tar.bz2 merchant-5f4f6262b4e3b1a1b6a88d5dd12c588084e703ad.zip |
misc bugfixes in taler-merchant-exchange
Diffstat (limited to 'src/backend/taler-merchant-exchange.c')
-rw-r--r-- | src/backend/taler-merchant-exchange.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/src/backend/taler-merchant-exchange.c b/src/backend/taler-merchant-exchange.c index ff480ca9..74e9dce0 100644 --- a/src/backend/taler-merchant-exchange.c +++ b/src/backend/taler-merchant-exchange.c @@ -166,7 +166,7 @@ struct Inquiry /** * When did the transfer happen? */ - struct GNUNET_TIME_Absolute execution_time; + struct GNUNET_TIME_Timestamp execution_time; /** * Argument for the /wire/transfers request. @@ -477,6 +477,16 @@ end_inquiry (struct Inquiry *w) task = GNUNET_SCHEDULER_add_now (&find_work, NULL); } + if ( (NULL == task) && + (! at_limit) && + (0 == active_inquiries) && + (test_mode) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "No more open inquiries and in test mode. Existing.\n"); + GNUNET_SCHEDULER_shutdown (); + return; + } } @@ -503,6 +513,11 @@ shutdown_task (void *cls) } GNUNET_free (e->exchange_url); TALER_EXCHANGE_disconnect (e->conn); + if (NULL != e->retry_task) + { + GNUNET_SCHEDULER_cancel (e->retry_task); + e->retry_task = NULL; + } GNUNET_CONTAINER_DLL_remove (e_head, e_tail, e); @@ -724,6 +739,7 @@ wire_transfer_cb (void *cls, { case MHD_HTTP_OK: td = &tgr->details.ok.td; + w->execution_time = td->execution_time; e->transfer_delay = GNUNET_TIME_UNIT_ZERO; break; case MHD_HTTP_BAD_REQUEST: @@ -733,6 +749,7 @@ wire_transfer_cb (void *cls, TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_HARD_FAILURE, true, false); + end_inquiry (w); return; case MHD_HTTP_NOT_FOUND: update_transaction_status (w, @@ -740,6 +757,7 @@ wire_transfer_cb (void *cls, TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_FATAL_NOT_FOUND, true, false); + end_inquiry (w); return; case MHD_HTTP_INTERNAL_SERVER_ERROR: case MHD_HTTP_BAD_GATEWAY: @@ -751,6 +769,7 @@ wire_transfer_cb (void *cls, TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE, false, false); + end_inquiry (w); return; default: e->transfer_delay = GNUNET_TIME_STD_BACKOFF (e->transfer_delay); @@ -763,6 +782,7 @@ wire_transfer_cb (void *cls, TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE, false, false); + end_inquiry (w); return; } db_plugin->preflight (db_plugin->cls); @@ -847,7 +867,7 @@ wire_transfer_cb (void *cls, /* #check_transfer() failed, report conflict! */ GNUNET_break_op (0); GNUNET_assert (TALER_EC_NONE != ctc.ec); - return; + break; case GNUNET_OK: break; } @@ -863,6 +883,7 @@ wire_transfer_cb (void *cls, ctc.ec, ctc.failure, false); + end_inquiry (w); return; } } @@ -878,6 +899,7 @@ wire_transfer_cb (void *cls, TALER_EC_MERCHANT_PRIVATE_POST_TRANSFERS_BAD_WIRE_FEE, true, false); + end_inquiry (w); return; } @@ -891,6 +913,7 @@ wire_transfer_cb (void *cls, TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_CONFLICTING_TRANSFERS, true, false); + end_inquiry (w); return; } /* set transaction to successful */ @@ -899,6 +922,7 @@ wire_transfer_cb (void *cls, TALER_EC_NONE, false, true); + end_inquiry (w); } @@ -913,6 +937,7 @@ exchange_request (void *cls) struct Inquiry *w = cls; struct Exchange *e = w->exchange; + w->task = NULL; GNUNET_assert (e->ready); w->wdh = TALER_EXCHANGE_transfers_get (e->conn, &w->wtid, @@ -929,6 +954,7 @@ exchange_request (void *cls) TALER_EC_MERCHANT_EXCHANGE_TRANSFERS_TRANSIENT_FAILURE, false, false); + end_inquiry (w); return; } /* Wait at least 1m for the network transfer */ @@ -969,7 +995,27 @@ start_inquiry ( struct Inquiry *w; (void) cls; + if (GNUNET_TIME_absolute_is_future (next_attempt)) + { + if (NULL == task) + task = GNUNET_SCHEDULER_add_at (next_attempt, + &find_work, + NULL); + return; + } e = find_exchange (exchange_url); + for (w = e->w_head; NULL != w; w = w->next) + { + if (0 == GNUNET_memcmp (&w->wtid, + wtid)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Already processing inquiry. Aborting ongoing inquiry\n"); + end_inquiry (w); + break; + } + } + active_inquiries++; w = GNUNET_new (struct Inquiry); w->payto_uri = GNUNET_strdup (payto_uri); @@ -1011,6 +1057,7 @@ find_work (void *cls) at_limit = true; return; } + at_limit = false; qs = db_plugin->select_open_transfers (db_plugin->cls, limit, &start_inquiry, |