From 9f27b2bb79d177329317438c7b983801de38da00 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 6 Sep 2020 13:03:05 +0200 Subject: properly implement shutdown of /refund request --- .../taler-merchant-httpd_post-orders-ID-refund.c | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src') 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 @@ -253,6 +253,44 @@ static struct PostRefundData *prd_head; 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. */ @@ -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; -- cgit v1.2.3