[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-exchange] 02/08: convert another function for #5010
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-exchange] 02/08: convert another function for #5010 |
Date: |
Mon, 19 Jun 2017 00:18:19 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit d66a29e383d1a6985906136c9606fcd18cb1c124
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Jun 18 15:02:35 2017 +0200
convert another function for #5010
---
src/exchange/taler-exchange-aggregator.c | 75 +++++++++++++++++++++--------
src/exchangedb/plugin_exchangedb_postgres.c | 24 ++++-----
src/exchangedb/test_exchangedb.c | 2 +-
src/include/taler_exchangedb_plugin.h | 6 +--
4 files changed, 67 insertions(+), 40 deletions(-)
diff --git a/src/exchange/taler-exchange-aggregator.c
b/src/exchange/taler-exchange-aggregator.c
index 89f72de..1024019 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -577,6 +577,8 @@ deposit_cb (void *cls,
struct GNUNET_TIME_Absolute wire_deadline,
const json_t *wire)
{
+ enum GNUNET_DB_QueryStatus qs;
+
au->merchant_pub = *merchant_pub;
if (GNUNET_OK !=
TALER_amount_subtract (&au->total_amount,
@@ -623,11 +625,12 @@ deposit_cb (void *cls,
GNUNET_break (0);
return GNUNET_SYSERR;
}
- if (GNUNET_OK !=
- db_plugin->mark_deposit_done (db_plugin->cls,
- au->session,
- row_id))
+ qs = db_plugin->mark_deposit_done (db_plugin->cls,
+ au->session,
+ row_id);
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{
+ /* FIXME #5010 */
GNUNET_break (0);
au->failed = GNUNET_YES;
return GNUNET_SYSERR;
@@ -664,6 +667,7 @@ aggregate_cb (void *cls,
const json_t *wire)
{
struct TALER_Amount delta;
+ enum GNUNET_DB_QueryStatus qs;
GNUNET_break (0 ==
memcmp (&au->merchant_pub,
@@ -714,11 +718,12 @@ aggregate_cb (void *cls,
GNUNET_break (0);
return GNUNET_SYSERR;
}
- if (GNUNET_OK !=
- db_plugin->mark_deposit_done (db_plugin->cls,
- au->session,
- row_id))
+ qs = db_plugin->mark_deposit_done (db_plugin->cls,
+ au->session,
+ row_id);
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
{
+ /* FIXME: #5010 */
GNUNET_break (0);
au->failed = GNUNET_YES;
return GNUNET_SYSERR;
@@ -1102,7 +1107,7 @@ run_aggregation (void *cls)
{
static int swap;
struct TALER_EXCHANGEDB_Session *session;
- unsigned int i;
+ enum GNUNET_DB_QueryStatus qs;
int ret;
const struct GNUNET_SCHEDULER_TaskContext *tc;
@@ -1246,18 +1251,46 @@ run_aggregation (void *cls)
}
/* Mark transactions by row_id as minor */
ret = GNUNET_OK;
- if (GNUNET_OK !=
- db_plugin->mark_deposit_tiny (db_plugin->cls,
- session,
- au->row_id))
- ret = GNUNET_SYSERR;
- else
- for (i=0;i<au->rows_offset;i++)
- if (GNUNET_OK !=
- db_plugin->mark_deposit_tiny (db_plugin->cls,
- session,
- au->additional_rows[i]))
- ret = GNUNET_SYSERR;
+ qs = db_plugin->mark_deposit_tiny (db_plugin->cls,
+ session,
+ au->row_id);
+ if (0 <= qs)
+ {
+ for (unsigned int i=0;i<au->rows_offset;i++)
+ {
+ qs = db_plugin->mark_deposit_tiny (db_plugin->cls,
+ session,
+ au->additional_rows[i]);
+ if (0 > qs)
+ break;
+ }
+ }
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ {
+ db_plugin->rollback (db_plugin->cls,
+ session);
+ GNUNET_free_non_null (au->additional_rows);
+ if (NULL != au->wire)
+ json_decref (au->wire);
+ GNUNET_free (au);
+ au = NULL;
+ /* start again */
+ task = GNUNET_SCHEDULER_add_now (&run_aggregation,
+ NULL);
+ return;
+ }
+ if (GNUNET_DB_STATUS_HARD_ERROR == qs)
+ {
+ db_plugin->rollback (db_plugin->cls,
+ session);
+ GNUNET_free_non_null (au->additional_rows);
+ if (NULL != au->wire)
+ json_decref (au->wire);
+ GNUNET_free (au);
+ au = NULL;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
/* commit */
(void) commit_or_warn (session);
GNUNET_free_non_null (au->additional_rows);
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c
b/src/exchangedb/plugin_exchangedb_postgres.c
index c2f4ffa..37db30d 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -2793,11 +2793,9 @@ postgres_have_deposit (void *cls,
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to the database
* @param rowid identifies the deposit row to modify
- * @return #GNUNET_OK on success,
- * #GNUNET_NO on transient error
- * #GNUNET_SYSERR on error
+ * @return query result status
*/
-static int
+static enum GNUNET_DB_QueryStatus
postgres_mark_deposit_tiny (void *cls,
struct TALER_EXCHANGEDB_Session *session,
uint64_t rowid)
@@ -2807,9 +2805,9 @@ postgres_mark_deposit_tiny (void *cls,
GNUNET_PQ_query_param_end
};
- return execute_prepared_non_select (session,
- "mark_deposit_tiny",
- params);
+ return GNUNET_PQ_eval_prepared_non_select (session->conn,
+ "mark_deposit_tiny",
+ params);
}
@@ -2890,11 +2888,9 @@ postgres_test_deposit_done (void *cls,
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to the database
* @param rowid identifies the deposit row to modify
- * @return #GNUNET_OK on success,
- * #GNUNET_NO on transient error,
- * #GNUNET_SYSERR on error
+ * @return query result status
*/
-static int
+static enum GNUNET_DB_QueryStatus
postgres_mark_deposit_done (void *cls,
struct TALER_EXCHANGEDB_Session *session,
uint64_t rowid)
@@ -2904,9 +2900,9 @@ postgres_mark_deposit_done (void *cls,
GNUNET_PQ_query_param_end
};
- return execute_prepared_non_select (session,
- "mark_deposit_done",
- params);
+ return GNUNET_PQ_eval_prepared_non_select (session->conn,
+ "mark_deposit_done",
+ params);
}
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index adb7237..28e089c 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1801,7 +1801,7 @@ run (void *cls)
FAILIF (GNUNET_OK !=
plugin->start (plugin->cls,
session));
- FAILIF (GNUNET_OK !=
+ FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->mark_deposit_tiny (plugin->cls,
session,
deposit_rowid));
diff --git a/src/include/taler_exchangedb_plugin.h
b/src/include/taler_exchangedb_plugin.h
index 924bfe7..eed4321 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -1343,11 +1343,9 @@ struct TALER_EXCHANGEDB_Plugin
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to the database
* @param deposit_rowid identifies the deposit row to modify
- * @return #GNUNET_OK on success
- * #GNUNET_NO on transient error
- * #GNUNET_SYSERR on error
+ * @return query result status
*/
- int
+ enum GNUNET_DB_QueryStatus
(*mark_deposit_tiny) (void *cls,
struct TALER_EXCHANGEDB_Session *session,
uint64_t rowid);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-exchange] branch master updated (7f9e627 -> 3d701e8), gnunet, 2017/06/18
- [GNUnet-SVN] [taler-exchange] 01/08: convert another function for #5010, gnunet, 2017/06/18
- [GNUnet-SVN] [taler-exchange] 08/08: fix leaks and typos, gnunet, 2017/06/18
- [GNUnet-SVN] [taler-exchange] 02/08: convert another function for #5010,
gnunet <=
- [GNUnet-SVN] [taler-exchange] 03/08: convert another function for #5010, gnunet, 2017/06/18
- [GNUnet-SVN] [taler-exchange] 05/08: rework /reserve/history to address #5010, gnunet, 2017/06/18
- [GNUnet-SVN] [taler-exchange] 06/08: rename file to match content better, gnunet, 2017/06/18
- [GNUnet-SVN] [taler-exchange] 04/08: refactoring /deposit towards new transaction style (#5010), gnunet, 2017/06/18
- [GNUnet-SVN] [taler-exchange] 07/08: fixing #5010 for /reserve/withdraw, gnunet, 2017/06/18