From 6bca914c824a5f9b42b8f90094d62da1f25c88b0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 25 Jun 2020 10:42:37 +0200 Subject: minor style improvements --- src/backend/taler-merchant-httpd_get-orders-ID.c | 59 ++++++++-------------- ...-merchant-httpd_private-post-orders-ID-refund.c | 2 +- 2 files changed, 23 insertions(+), 38 deletions(-) (limited to 'src/backend') diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c index 1a7c16a4..40c50de2 100644 --- a/src/backend/taler-merchant-httpd_get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_get-orders-ID.c @@ -207,7 +207,7 @@ struct GetOrderData /** * Did we suspend @a connection? */ - int suspended; + bool suspended; /** * Return code: #TALER_EC_NONE if successful. @@ -248,7 +248,7 @@ TMH_force_wallet_get_order_resume (void) god_tail, god); GNUNET_assert (god->suspended); - god->suspended = GNUNET_NO; + god->suspended = false; MHD_resume_connection (god->sc.con); } } @@ -422,7 +422,7 @@ check_resume_god (struct GetOrderData *god) god_tail, god); GNUNET_assert (god->suspended); - god->suspended = GNUNET_NO; + god->suspended = false; MHD_resume_connection (god->sc.con); TMH_trigger_daemon (); } @@ -580,14 +580,13 @@ process_refunds_cb (void *cls, /** - * Clean up the session state for a GET /orders/$ID request. + * Clean up refund processing. * - * @param cls must be a `struct GetOrderData *` + * @param god handle to clean up refund processing for */ static void -god_cleanup (void *cls) +rf_cleanup (struct GetOrderData *god) { - struct GetOrderData *god = cls; struct CoinRefund *cr; while (NULL != (cr = god->cr_head)) @@ -613,7 +612,20 @@ god_cleanup (void *cls) GNUNET_free (cr->exchange_url); GNUNET_free (cr); } +} + + +/** + * Clean up the session state for a GET /orders/$ID request. + * + * @param cls must be a `struct GetOrderData *` + */ +static void +god_cleanup (void *cls) +{ + struct GetOrderData *god = cls; + rf_cleanup (god); if (NULL != god->contract_terms) json_decref (god->contract_terms); GNUNET_free (god); @@ -643,10 +655,8 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, hc->ctx = god; hc->cc = &god_cleanup; god->sc.con = connection; - god->ec = TALER_EC_NONE; god->hc = hc; god->order_id = order_id; - god->cr_head = NULL; { const char *cts; @@ -889,33 +899,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, /* At this point, we know the contract was paid. Let's check for refunds. First, clear away refunds found from previous invocations. */ - { - struct CoinRefund *cr; - - while (NULL != (cr = god->cr_head)) - { - GNUNET_CONTAINER_DLL_remove (god->cr_head, - god->cr_tail, - cr); - 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; - } - if (NULL != cr->exchange_reply) - { - json_decref (cr->exchange_reply); - cr->exchange_reply = NULL; - } - GNUNET_free (cr->exchange_url); - GNUNET_free (cr); - } - } + rf_cleanup (); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (TMH_currency, &god->refund_amount)); qs = TMH_db->lookup_refunds_detailed (TMH_db->cls, @@ -993,7 +977,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, { if (! god->suspended) { - god->suspended = GNUNET_YES; + god->suspended = true; MHD_suspend_connection (connection); GNUNET_CONTAINER_DLL_insert (god_head, god_tail, @@ -1013,6 +997,7 @@ TMH_get_orders_ID (const struct TMH_RequestHandler *rh, cr = cr->next) { json_t *refund; + if (MHD_HTTP_OK != cr->exchange_status) { if (NULL == cr->exchange_reply) diff --git a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c index 942892f9..d585b10f 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c +++ b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c @@ -203,7 +203,7 @@ TMH_private_post_orders_ID_refund (const struct TMH_RequestHandler *rh, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, - TALER_EC_REFUND_ORDER_ID_UNKNOWN, + TALER_EC_REFUND_ORDER_ID_UNPAID, "Order never paid"); } else -- cgit v1.2.3