commit 2ff04f3608220043cf5c025679a6f26344c4c9ab
parent a2814640dd4403af8883f3ba0862870c60f883df
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 10 Mar 2026 01:17:14 +0100
fix misc. cleanup issues
Diffstat:
6 files changed, 77 insertions(+), 29 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_get-private-kyc.c b/src/backend/taler-merchant-httpd_get-private-kyc.c
@@ -329,6 +329,34 @@ TMH_force_kyc_resume ()
/**
+ * Release resources of @a ekr
+ *
+ * @param[in] ekr key request data to clean up
+ */
+static void
+ekr_cleanup (struct ExchangeKycRequest *ekr)
+{
+ struct KycContext *kc = ekr->kc;
+
+ GNUNET_CONTAINER_DLL_remove (kc->exchange_pending_head,
+ kc->exchange_pending_tail,
+ ekr);
+ if (NULL != ekr->fo)
+ {
+ TMH_EXCHANGES_keys4exchange_cancel (ekr->fo);
+ ekr->fo = NULL;
+ }
+ json_decref (ekr->pkaa);
+ json_decref (ekr->jlimits);
+ if (NULL != ekr->keys)
+ TALER_EXCHANGE_keys_decref (ekr->keys);
+ GNUNET_free (ekr->exchange_url);
+ GNUNET_free (ekr->payto_uri.full_payto);
+ GNUNET_free (ekr);
+}
+
+
+/**
* Custom cleanup routine for a `struct KycContext`.
*
* @param cls the `struct KycContext` to clean up.
@@ -341,21 +369,7 @@ kyc_context_cleanup (void *cls)
while (NULL != (ekr = kc->exchange_pending_head))
{
- GNUNET_CONTAINER_DLL_remove (kc->exchange_pending_head,
- kc->exchange_pending_tail,
- ekr);
- if (NULL != ekr->fo)
- {
- TMH_EXCHANGES_keys4exchange_cancel (ekr->fo);
- ekr->fo = NULL;
- }
- json_decref (ekr->pkaa);
- json_decref (ekr->jlimits);
- if (NULL != ekr->keys)
- TALER_EXCHANGE_keys_decref (ekr->keys);
- GNUNET_free (ekr->exchange_url);
- GNUNET_free (ekr->payto_uri.full_payto);
- GNUNET_free (ekr);
+ ekr_cleanup (ekr);
}
if (NULL != kc->eh)
{
@@ -924,17 +938,7 @@ ekr_finished (struct ExchangeKycRequest *ekr)
struct KycContext *kc = ekr->kc;
ekr_expand_response (ekr);
- GNUNET_CONTAINER_DLL_remove (kc->exchange_pending_head,
- kc->exchange_pending_tail,
- ekr);
- json_decref (ekr->jlimits);
- json_decref (ekr->pkaa);
- if (NULL != ekr->keys)
- TALER_EXCHANGE_keys_decref (ekr->keys);
- GNUNET_free (ekr->exchange_url);
- GNUNET_free (ekr->payto_uri.full_payto);
- GNUNET_free (ekr);
-
+ ekr_cleanup (ekr);
if (NULL != kc->exchange_pending_head)
return; /* wait for more */
kc_respond (kc);
@@ -1455,8 +1459,6 @@ get_instances_ID_kyc (
{
enum GNUNET_DB_QueryStatus qs;
- GNUNET_break (0 ==
- json_array_clear (kc->kycs_data));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Checking KYC status for %s (%d/%s)\n",
mi->settings.id,
@@ -1464,7 +1466,8 @@ get_instances_ID_kyc (
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));
+ GNUNET_break (0 ==
+ json_array_clear (kc->kycs_data));
qs = TMH_db->account_kyc_get_status (
TMH_db->cls,
mi->settings.id,
diff --git a/src/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c b/src/backend/taler-merchant-httpd_get-private-orders-ORDER_ID.c
@@ -1166,6 +1166,7 @@ phase_unpaid_finish (struct GetOrderRequestContext *gorc)
gorc->contract_terms->timestamp));
check_reply (gorc,
reply);
+ json_decref (reply);
GNUNET_free (taler_pay_uri);
}
GNUNET_free (order_status_url);
diff --git a/src/backenddb/pg_account_kyc_get_status.sql b/src/backenddb/pg_account_kyc_get_status.sql
@@ -60,6 +60,7 @@ BEGIN
WHERE merchant_serial = my_merchant_serial
AND active
AND (in_h_wire IS NULL OR h_wire = in_h_wire)
+ ORDER BY account_serial ASC
LOOP
-- Fetch KYC info for this account (can have multiple results)
@@ -77,6 +78,7 @@ BEGIN
FROM merchant_kyc mk
WHERE mk.account_serial = my_account_serial
AND (in_exchange_url IS NULL OR mk.exchange_url = in_exchange_url)
+ ORDER BY mk.kyc_serial_id ASC
LOOP
-- Ask taler-merchant-kyccheck to get us an update on the status ASAP
UPDATE merchant_kyc
diff --git a/src/backenddb/pg_merchant_kyc_trigger.sql b/src/backenddb/pg_merchant_kyc_trigger.sql
@@ -0,0 +1,40 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2026 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+
+-- @file pg_merchant_kyc_trigger.sql
+-- @brief Fix trigger logic
+-- @author Christian Grothoff
+
+
+CREATE OR REPLACE FUNCTION merchant_kyc_update_trigger()
+RETURNS trigger
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ IF (OLD.kyc_ok
+ ,OLD.last_rule_gen
+ ,OLD.aml_review
+ ,OLD.jaccount_limits)
+ IS DISTINCT FROM
+ (NEW.kyc_ok
+ ,NEW.last_rule_gen
+ ,NEW.aml_review
+ ,NEW.jaccount_limits)
+ THEN
+ CALL merchant_send_kyc_notification(NEW.account_serial,
+ NEW.exchange_url);
+ END IF;
+ RETURN NEW;
+END $$;
diff --git a/src/backenddb/procedures.sql.in b/src/backenddb/procedures.sql.in
@@ -38,6 +38,7 @@ SET search_path TO merchant;
#include "pg_insert_deposit_confirmation.sql"
#include "pg_base32_crockford.sql"
#include "pg_uri_escape.sql"
+#include "pg_merchant_kyc_trigger.sql"
DROP PROCEDURE IF EXISTS merchant_do_gc;
CREATE PROCEDURE merchant_do_gc(in_now INT8)
diff --git a/src/include/taler/Makefile.am b/src/include/taler/Makefile.am
@@ -6,6 +6,7 @@ EXTRA_DIST = \
talerincludedir = $(includedir)/taler
talerinclude_HEADERS = \
+ platform.h \
taler_merchant_bank_lib.h \
taler_merchantdb_lib.h \
taler_merchantdb_plugin.h \