summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_post-orders-ID-refund.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-refund.c')
-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;