summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-09-06 13:03:05 +0200
committerChristian Grothoff <christian@grothoff.org>2020-09-06 13:03:05 +0200
commit9f27b2bb79d177329317438c7b983801de38da00 (patch)
treec3703a10737724104627b79b306d55a55af75c88 /src
parentc528a4ceda11a6f4c10100b122057d2ee45a7613 (diff)
downloadmerchant-9f27b2bb79d177329317438c7b983801de38da00.tar.gz
merchant-9f27b2bb79d177329317438c7b983801de38da00.tar.bz2
merchant-9f27b2bb79d177329317438c7b983801de38da00.zip
properly implement shutdown of /refund request
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_post-orders-ID-refund.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
index 31d0a86c..86b62c9e 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
@@ -254,6 +254,44 @@ static struct PostRefundData *prd_tail;
/**
+ * Function called when we are done processing a refund request.
+ * Frees memory associated with @a ctx.
+ *
+ * @param ctx a `struct PostRefundData`
+ */
+static void
+refund_cleanup (void *ctx)
+{
+ struct PostRefundData *prd = ctx;
+ struct CoinRefund *cr;
+
+ while (NULL != (cr = prd->cr_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (prd->cr_head,
+ prd->cr_tail,
+ cr);
+ json_decref (cr->exchange_reply);
+ GNUNET_free (cr->exchange_url);
+ if (NULL != cr->fo)
+ {
+ TMH_EXCHANGES_find_exchange_cancel (cr->fo);
+ cr->fo = NULL;
+ }
+ if (NULL != cr->rh)
+ {
+ TALER_EXCHANGE_refund_cancel (cr->rh);
+ cr->rh = NULL;
+ }
+ GNUNET_free (cr);
+ }
+
+ json_decref (prd->contract_terms);
+
+ GNUNET_free (prd);
+}
+
+
+/**
* Force resuming all suspended order lookups, needed during shutdown.
*/
void
@@ -495,6 +533,8 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh,
prd->sc.con = connection;
prd->hc = hc;
prd->order_id = hc->infix;
+ hc->ctx = prd;
+ hc->cc = &refund_cleanup;
{
enum GNUNET_GenericReturnValue res;