commit 31612ee389aef7e04814053a1b9590f8ad3acd86
parent 277301d45e96b36b749e66e6018d535ec06e67c9
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 31 Jan 2026 12:38:04 +0100
remove long-poll only forwards constraint for #9955
Diffstat:
2 files changed, 34 insertions(+), 36 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
@@ -1101,7 +1101,8 @@ phase_unpaid_finish (struct GetOrderRequestContext *gorc)
}
/* User never paid for this order, suspend waiting
on payment or return details. */
- if (GNUNET_TIME_absolute_is_future (gorc->sc.long_poll_timeout))
+ if (GNUNET_TIME_absolute_is_future (gorc->sc.long_poll_timeout) &&
+ (! gorc->have_lp_not_etag) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Suspending GET /private/orders/%s\n",
@@ -1142,14 +1143,13 @@ phase_unpaid_finish (struct GetOrderRequestContext *gorc)
}
{
char *taler_pay_uri;
+ json_t *reply;
taler_pay_uri = TMH_make_taler_pay_uri (gorc->sc.con,
hc->infix,
gorc->session_id,
hc->instance->settings.id,
&gorc->claim_token);
- json_t *reply;
-
reply = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("taler_pay_uri",
taler_pay_uri),
diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2019--2025 Taler Systems SA
+ (C) 2019--2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -17,6 +17,8 @@
* @file taler-merchant-httpd_private-get-orders.c
* @brief implement GET /orders
* @author Christian Grothoff
+ *
+ * FIXME-cleanup: consider introducing phases / state machine
*/
#include "platform.h"
#include "taler-merchant-httpd_private-get-orders.h"
@@ -101,6 +103,10 @@ struct TMH_PendingOrder
};
+// FIXME-cleanup: should probably replace the heap with
+// a DLL and keep a per-entry task as we do elsewhere.
+// The heap does not help, the scheduler should have one already.
+
/**
* Task to timeout pending orders.
*/
@@ -600,7 +606,7 @@ resume_by_event (void *cls,
order_serial_id = GNUNET_ntohll (oce->order_serial_id);
date = GNUNET_TIME_timestamp_ntoh (oce->execution_date);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Received notification about new order %llu\n",
+ "Received notification about order %llu\n",
(unsigned long long) order_serial_id);
for (struct TMH_PendingOrder *po = mi->po_head;
NULL != po;
@@ -940,15 +946,24 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"timeout_ms");
}
- po->of.timeout = GNUNET_TIME_absolute_get_remaining (po->long_poll_timeout);
- if ( (0 >= po->of.delta) &&
- (GNUNET_TIME_absolute_is_future (po->long_poll_timeout)) )
+ if (GNUNET_TIME_absolute_is_future (po->long_poll_timeout))
{
- GNUNET_break_op (0);
- po->of.timeout = GNUNET_TIME_UNIT_ZERO;
- po->long_poll_timeout = GNUNET_TIME_UNIT_ZERO_ABS;
+ struct TMH_MerchantInstance *mi = hc->instance;
+ struct TMH_OrderChangeEventP change_eh = {
+ .header.type = htons (TALER_DBEVENT_MERCHANT_ORDERS_CHANGE),
+ .header.size = htons (sizeof (change_eh)),
+ .merchant_pub = mi->merchant_pub
+ };
+
+ mi->po_eh = TMH_db->event_listen (TMH_db->cls,
+ &change_eh.header,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &resume_by_event,
+ mi);
}
+ po->of.timeout = GNUNET_TIME_absolute_get_remaining (po->long_poll_timeout);
+
qs = TMH_db->lookup_orders (TMH_db->cls,
po->instance_id,
&po->of,
@@ -971,6 +986,7 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh,
(GNUNET_TIME_absolute_is_future (po->long_poll_timeout)) )
{
struct TMH_MerchantInstance *mi = hc->instance;
+ struct TMH_PendingOrder *pot;
/* setup timeout heap (if not yet exists) */
if (NULL == order_timeout_heap)
@@ -983,32 +999,14 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh,
mi->po_tail,
po);
po->in_dll = true;
- if (NULL == mi->po_eh)
- {
- struct TMH_OrderChangeEventP change_eh = {
- .header.type = htons (TALER_DBEVENT_MERCHANT_ORDERS_CHANGE),
- .header.size = htons (sizeof (change_eh)),
- .merchant_pub = mi->merchant_pub
- };
-
- mi->po_eh = TMH_db->event_listen (TMH_db->cls,
- &change_eh.header,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &resume_by_event,
- mi);
- }
MHD_suspend_connection (connection);
- {
- struct TMH_PendingOrder *pot;
-
- /* start timeout task */
- pot = GNUNET_CONTAINER_heap_peek (order_timeout_heap);
- if (NULL != order_timeout_task)
- GNUNET_SCHEDULER_cancel (order_timeout_task);
- order_timeout_task = GNUNET_SCHEDULER_add_at (pot->long_poll_timeout,
- &order_timeout,
- NULL);
- }
+ /* start timeout task */
+ pot = GNUNET_CONTAINER_heap_peek (order_timeout_heap);
+ if (NULL != order_timeout_task)
+ GNUNET_SCHEDULER_cancel (order_timeout_task);
+ order_timeout_task = GNUNET_SCHEDULER_add_at (pot->long_poll_timeout,
+ &order_timeout,
+ NULL);
return MHD_YES;
}
return TALER_MHD_REPLY_JSON_PACK (