From b77ef665b0f3876f2c27db2d5a9b154fa1a9ba0d Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Wed, 19 Aug 2020 03:28:38 -0400 Subject: long poll for pending refunds --- .../taler-merchant-httpd_post-orders-ID-refund.c | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/backend/taler-merchant-httpd_post-orders-ID-refund.c') 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 bfdb6ca2..7fafdd5e 100644 --- a/src/backend/taler-merchant-httpd_post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_post-orders-ID-refund.c @@ -253,7 +253,24 @@ static struct PostRefundData *prd_head; static struct PostRefundData *prd_tail; -/* FIXME: Handle shutdown and other events that require ending all requests */ +/** + * Force resuming all suspended order lookups, needed during shutdown. + */ +void +TMH_force_wallet_refund_order_resume (void) +{ + struct PostRefundData *prd; + + while (NULL != (prd = prd_head)) + { + GNUNET_CONTAINER_DLL_remove (prd_head, + prd_tail, + prd); + GNUNET_assert (prd->suspended); + prd->suspended = false; + MHD_resume_connection (prd->sc.con); + } +} /** @@ -581,7 +598,11 @@ TMH_post_orders_ID_refund (const struct TMH_RequestHandler *rh, "Merchant database error"); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: /* We need to talk to the exchange */ - /* FIXME: notify clients polling for this to happen */ + /* Notify clients waiting for the refund to be obtained. */ + TMH_long_poll_resume (hc->infix, + hc->instance, + &prd->refund_amount, + true); cr->fo = TMH_EXCHANGES_find_exchange (cr->exchange_url, NULL, GNUNET_NO, -- cgit v1.2.3