commit 9f27b2bb79d177329317438c7b983801de38da00
parent c528a4ceda11a6f4c10100b122057d2ee45a7613
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 6 Sep 2020 13:03:05 +0200
properly implement shutdown of /refund request
Diffstat:
1 file 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
@@ -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;