commit 66f4b840038776d130de644e9c4cc17845cf873d
parent 5c83bb2ac1de5419e735c4ba4d09bb459cd4bc0d
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sun, 25 Jan 2026 15:47:55 +0900
implement support for lp_status and lp_not_status
Diffstat:
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -107,8 +107,7 @@ struct ExchangeKycRequest
struct GNUNET_TIME_Timestamp last_check;
/**
- * Last HTTP status code obtained via /kyc-check from
- * the exchange.
+ * Last HTTP status code obtained via /kyc-check from the exchange.
*/
unsigned int last_http_status;
@@ -241,8 +240,6 @@ struct KycContext
* endpoint will only return once the status *matches* the given value. If
* multiple accounts or exchanges match the query, any account reaching the
* STATUS will cause the response to be returned.
- *
- * FIXME: not yet used!
*/
const char *lp_status;
@@ -251,9 +248,6 @@ struct KycContext
* endpoint will only return once the status no longer matches the given
* value. If multiple accounts or exchanges *no longer matches* the given
* STATUS will cause the response to be returned.
- *
-
- * FIXME: not yet used!
*/
const char *lp_not_status;
@@ -371,6 +365,29 @@ kyc_context_cleanup (void *cls)
/**
+ * We have found an exchange in status @a status. Clear any
+ * long-pollers that wait for us having (or not having) this
+ * status.
+ *
+ * @param[in,out] kc context
+ * @param status the status we encountered
+ */
+static void
+clear_status (struct KycContext *kc,
+ const char *status)
+{
+ if ( (NULL != kc->lp_status) &&
+ (0 == strcmp (kc->lp_status,
+ status)) )
+ kc->lp_status = NULL; /* satisfied! */
+ if ( (NULL != kc->lp_not_status) &&
+ (0 != strcmp (kc->lp_not_status,
+ status) ) )
+ kc->lp_not_status = NULL; /* satisfied! */
+}
+
+
+/**
* Resume the given KYC context and send the final response. Stores the
* response in the @a kc and signals MHD to resume the connection. Also
* ensures MHD runs immediately.
@@ -383,6 +400,19 @@ resume_kyc_with_response (struct KycContext *kc)
struct GNUNET_ShortHashCode sh;
bool not_modified;
+ if ( (! GNUNET_TIME_absolute_is_past (kc->timeout)) &&
+ ( (NULL != kc->lp_not_status) ||
+ (NULL != kc->lp_status) ) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Long-poll target status not reached, not returning response yet\n");
+ if (GNUNET_NO == kc->suspended)
+ {
+ MHD_suspend_connection (kc->connection);
+ kc->suspended = GNUNET_YES;
+ }
+ return;
+ }
{
char *can;
@@ -720,6 +750,8 @@ ekr_expand_response (struct ExchangeKycRequest *ekr)
GNUNET_break (0);
status = "logic-bug";
}
+ clear_status (ekr->kc,
+ status);
GNUNET_assert (
0 ==
json_array_append_new (
@@ -1013,6 +1045,8 @@ add_unreachable_status (void *cls,
struct UnreachableContext *uc = cls;
struct KycContext *kc = uc->kc;
+ clear_status (kc,
+ "exchange-unreachable");
GNUNET_assert (
0 ==
json_array_append_new (
@@ -1305,6 +1339,9 @@ get_instances_ID_kyc (
mi->settings.id,
kc->have_h_wire,
kc->exchange_url);
+ /* We may run repeatedly due to long-polling; clear data
+ from previous runs first */
+ GNUNET_break (0 == json_array_clear (kc->kycs_data));
qs = TMH_db->account_kyc_get_status (
TMH_db->cls,
mi->settings.id,