diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-orders-ID.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-orders-ID.c | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c index 3688bb87..b272e4c0 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c @@ -167,7 +167,7 @@ struct GetOrderRequestContext * Database event we are waiting on to be resuming * for session capture. */ - struct GNUNET_DB_EventHandler *seh; + struct GNUNET_DB_EventHandler *session_eh; /** * Contract terms of the payment we are checking. NULL when they @@ -305,7 +305,6 @@ gorc_resume (struct GetOrderRequestContext *gorc, { struct TransferQuery *tq; - GNUNET_assert (gorc->suspended); if (NULL != gorc->tt) { GNUNET_SCHEDULER_cancel (gorc->tt); @@ -326,6 +325,7 @@ gorc_resume (struct GetOrderRequestContext *gorc, } gorc->wire_hc = http_status; gorc->wire_ec = ec; + GNUNET_assert (gorc->suspended); GNUNET_CONTAINER_DLL_remove (gorc_head, gorc_tail, gorc); @@ -355,7 +355,7 @@ resume_by_event (void *cls, if (! gorc->suspended) return; /* duplicate event is possible */ gorc->suspended = false; - GNUNET_CONTAINER_DLL_insert (gorc_head, + GNUNET_CONTAINER_DLL_remove (gorc_head, gorc_tail, gorc); MHD_resume_connection (gorc->sc.con); @@ -663,10 +663,10 @@ gorc_cleanup (void *cls) TMH_db->event_listen_cancel (gorc->eh); gorc->eh = NULL; } - if (NULL != gorc->seh) + if (NULL != gorc->session_eh) { - TMH_db->event_listen_cancel (gorc->seh); - gorc->seh = NULL; + TMH_db->event_listen_cancel (gorc->session_eh); + gorc->session_eh = NULL; } GNUNET_free (gorc); } @@ -869,9 +869,10 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, = GNUNET_TIME_relative_to_absolute (timeout); if (! GNUNET_TIME_relative_is_zero (timeout)) { - struct TMH_OrderPayEvent pay_eh = { + struct TMH_OrderPayEventP pay_eh = { .header.size = htons (sizeof (pay_eh)), - .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_PAID) + .header.type = htons (TALER_DBEVENT_MERCHANT_ORDER_PAID), + .merchant_pub = hc->instance->merchant_pub }; GNUNET_CRYPTO_hash (hc->infix, @@ -885,12 +886,10 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, if ( (NULL != gorc->session_id) && (NULL != gorc->fulfillment_url) ) { -#ifndef TALER_API_VERSION -#define TALER_DBEVENT_MERCHANT_SESSION_CAPTURED 1103 -#endif - struct TMH_SessionEvent session_eh = { + struct TMH_SessionEventP session_eh = { .header.size = htons (sizeof (session_eh)), - .header.type = htons (TALER_DBEVENT_MERCHANT_SESSION_CAPTURED) + .header.type = htons (TALER_DBEVENT_MERCHANT_SESSION_CAPTURED), + .merchant_pub = hc->instance->merchant_pub }; GNUNET_CRYPTO_hash (gorc->session_id, @@ -899,11 +898,11 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_CRYPTO_hash (gorc->fulfillment_url, strlen (gorc->fulfillment_url), &session_eh.h_fulfillment_url); - gorc->seh = TMH_db->event_listen (TMH_db->cls, - &session_eh.header, - timeout, - &resume_by_event, - gorc); + gorc->session_eh = TMH_db->event_listen (TMH_db->cls, + &session_eh.header, + timeout, + &resume_by_event, + gorc); } } } @@ -916,7 +915,7 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, } /* end first-time per-request initialization */ - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting GET /private/orders/%s processing with timeout %s\n", hc->infix, GNUNET_STRINGS_absolute_time_to_string ( @@ -1170,16 +1169,14 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, { if (GNUNET_TIME_absolute_is_future (gorc->sc.long_poll_timeout)) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending GET /private/orders/%s\n", hc->infix); + GNUNET_CONTAINER_DLL_insert (gorc_head, + gorc_tail, + gorc); gorc->suspended = true; - TMH_long_poll_suspend (hc->infix, - gorc->session_id, - gorc->fulfillment_url, - hc->instance, - &gorc->sc, - NULL); + MHD_suspend_connection (gorc->sc.con); return MHD_YES; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1214,11 +1211,11 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, GNUNET_CONTAINER_DLL_insert (gorc_head, gorc_tail, gorc); + gorc->suspended = true; + MHD_suspend_connection (connection); gorc->tt = GNUNET_SCHEDULER_add_delayed (EXCHANGE_TIMEOUT, &exchange_timeout_cb, gorc); - gorc->suspended = true; - MHD_suspend_connection (connection); return MHD_YES; } } @@ -1226,16 +1223,15 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, if ( (! paid) && (GNUNET_TIME_absolute_is_future (gorc->sc.long_poll_timeout)) ) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending GET /private/orders/%s\n", hc->infix); + GNUNET_assert (! gorc->suspended); + GNUNET_CONTAINER_DLL_insert (gorc_head, + gorc_tail, + gorc); gorc->suspended = true; - TMH_long_poll_suspend (hc->infix, - gorc->session_id, - gorc->fulfillment_url, - hc->instance, - &gorc->sc, - NULL); + MHD_suspend_connection (gorc->sc.con); return MHD_YES; } @@ -1364,10 +1360,8 @@ TMH_private_get_orders_ID (const struct TMH_RequestHandler *rh, gorc->order_serial); GNUNET_break (qs >= 0); /* just warn if transaction failed */ TMH_notify_order_change (hc->instance, - hc->infix, - true, /* paid */ - false, /* technically unknown, but OK here */ - true, /* wired */ + TMH_OSF_PAID + | TMH_OSF_WIRED, timestamp, gorc->order_serial); } |