[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: -implement lock expiratin (#6937
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: -implement lock expiratin (#6937) |
Date: |
Sun, 01 Aug 2021 12:00:16 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new 76cf1110 -implement lock expiratin (#6937)
76cf1110 is described below
commit 76cf111084c13d5dc2d4ba686ecbbdeb8ff1ade9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Aug 1 11:55:11 2021 +0200
-implement lock expiratin (#6937)
---
contrib/merchant-backoffice | 2 +-
.../taler-merchant-httpd_private-post-orders.c | 6 ++-
...-merchant-httpd_private-post-products-ID-lock.c | 2 +
src/backenddb/plugin_merchantdb_postgres.c | 60 +++++++++++++++++++++-
src/include/taler_merchantdb_plugin.h | 11 ++++
5 files changed, 77 insertions(+), 4 deletions(-)
diff --git a/contrib/merchant-backoffice b/contrib/merchant-backoffice
index 4320467d..fe987187 160000
--- a/contrib/merchant-backoffice
+++ b/contrib/merchant-backoffice
@@ -1 +1 @@
-Subproject commit 4320467db1392e5f48a4acd079f7e2a253cf9984
+Subproject commit fe987187e178816d42ed12178d430c8771cb5a75
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 22e6327f..c3923995 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1331,9 +1331,11 @@ TMH_private_post_orders (const struct TMH_RequestHandler
*rh,
: MHD_NO;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Refund delay is %llu\n",
- (unsigned long long) refund_delay.rel_value_us);
+ "Refund delay is %s\n",
+ GNUNET_STRINGS_relative_time_to_string (refund_delay,
+ GNUNET_NO));
+ TMH_db->expire_locks (TMH_db->cls);
if (create_token)
{
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
diff --git a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c
b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c
index 7fc7b0ac..9983b520 100644
--- a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c
+++ b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c
@@ -24,6 +24,7 @@
*/
#include "platform.h"
#include "taler-merchant-httpd_private-post-products-ID-lock.h"
+#include "taler-merchant-httpd_helper.h"
#include <taler/taler_json_lib.h>
@@ -64,6 +65,7 @@ TMH_private_post_products_ID_lock (const struct
TMH_RequestHandler *rh,
}
TMH_uuid_from_string (uuids,
&uuid);
+ TMH_db->expire_locks (TMH_db->cls);
qs = TMH_db->lock_product (TMH_db->cls,
mi->settings.id,
product_id,
diff --git a/src/backenddb/plugin_merchantdb_postgres.c
b/src/backenddb/plugin_merchantdb_postgres.c
index 46e5e376..b882b24b 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2014--2020 Taler Systems SA
+ (C) 2014--2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software
@@ -1219,6 +1219,51 @@ postgres_lock_product (void *cls,
}
+/**
+ * Release all expired product locks, including
+ * those from expired offers -- across all
+ * instances.
+ *
+ * @param cls closure
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if
nothing was unlocked
+ */
+static void
+postgres_expire_locks (void *cls)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_TIME_Absolute now;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs1;
+ enum GNUNET_DB_QueryStatus qs2;
+
+ check_connection (pg);
+ now = GNUNET_TIME_absolute_get ();
+ qs1 = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "unlock_products",
+ params);
+ if (qs1 < 0)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ qs2 = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "unlock_orders",
+ params);
+ if (qs2 < 0)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Released %d+%d locks\n",
+ qs1,
+ qs2);
+}
+
+
/**
* Delete information about an order. Note that the transaction must
* enforce that the order is not awaiting payment anymore.
@@ -6586,6 +6631,18 @@ postgres_connect (void *cls)
" FROM merchant_order_locks"
" WHERE product_serial=ps.product_serial)",
5),
+
+ /* for postgres_expire_locks() */
+ GNUNET_PQ_make_prepare ("unlock_products",
+ "DELETE FROM merchant_inventory_locks"
+ " WHERE expiration < $1",
+ 1),
+ /* for postgres_expire_locks() */
+ GNUNET_PQ_make_prepare ("unlock_orders",
+ "DELETE FROM merchant_orders"
+ " WHERE pay_deadline < $1",
+ 1),
+
/* for postgres_delete_order() */
GNUNET_PQ_make_prepare ("delete_order",
"DELETE"
@@ -8832,6 +8889,7 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
plugin->insert_product = &postgres_insert_product;
plugin->update_product = &postgres_update_product;
plugin->lock_product = &postgres_lock_product;
+ plugin->expire_locks = &postgres_expire_locks;
plugin->delete_order = &postgres_delete_order;
plugin->lookup_order = &postgres_lookup_order;
plugin->lookup_order_summary = &postgres_lookup_order_summary;
diff --git a/src/include/taler_merchantdb_plugin.h
b/src/include/taler_merchantdb_plugin.h
index 91c33f60..f8ac0eaf 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -1010,6 +1010,17 @@ struct TALER_MERCHANTDB_Plugin
struct GNUNET_TIME_Absolute expiration_time);
+ /**
+ * Release all expired product locks, including
+ * those from expired offers -- across all
+ * instances.
+ *
+ * @param cls closure
+ */
+ void
+ (*expire_locks)(void *cls);
+
+
/**
* Delete information about an order. Note that the transaction must
* enforce that the order is not awaiting payment anymore.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: -implement lock expiratin (#6937),
gnunet <=