diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-07-01 14:11:54 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-07-01 14:11:54 +0200 |
commit | 4b447d032d24bc41ef79e40de5cc550429105907 (patch) | |
tree | 5c95387d1bcda56bf5009c2fc91b607992abacd0 /src/mintdb | |
parent | 3cdfdea8817ec550c2f02a8d67eed92bf54949bc (diff) |
do not use transaction scope in insert_withdraw_info
Diffstat (limited to 'src/mintdb')
-rw-r--r-- | src/mintdb/perf_taler_mintdb.c | 23 | ||||
-rw-r--r-- | src/mintdb/perf_taler_mintdb_init.h | 2 | ||||
-rw-r--r-- | src/mintdb/perf_taler_mintdb_interpreter.h | 63 | ||||
-rw-r--r-- | src/mintdb/plugin_mintdb_postgres.c | 21 |
4 files changed, 51 insertions, 58 deletions
diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c index 53c9a1c24..6eb700fd6 100644 --- a/src/mintdb/perf_taler_mintdb.c +++ b/src/mintdb/perf_taler_mintdb.c @@ -34,7 +34,7 @@ main (int argc, char ** argv) struct PERF_TALER_MINTDB_Cmd test[] = { // Denomination used to create coins - PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpretor"), + PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpreter"), PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop", PERF_TALER_MINTDB_NB_DENOMINATION_INIT), @@ -60,7 +60,7 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop", "02 - init reserve loop"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"), - // End reserve init + // End reserve init"00 - Start of interpreter"), // Withdrawal initialization PERF_TALER_MINTDB_INIT_CMD_LOOP ("03 - init withdraw loop", PERF_TALER_MINTDB_NB_WITHDRAW_INIT), @@ -82,7 +82,7 @@ main (int argc, char ** argv) PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop", "03 - init withdraw loop"), PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"), - //End of withdrawal initialization + //End of withdrawal initialization //Deposit initialization PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop", PERF_TALER_MINTDB_NB_DEPOSIT_INIT), @@ -91,7 +91,7 @@ main (int argc, char ** argv) "04 - deposit init loop", "01 - save denomination"), - PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit", + PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit", "04 - denomination load"), PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"), PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", @@ -108,21 +108,20 @@ main (int argc, char ** argv) GNUNET_log_setup ("perf-taler-mintdb", "INFO", NULL); - config = GNUNET_CONFIGURATION_create(); - GNUNET_CONFIGURATION_load(config, "./test-mint-db-postgres.conf"); + config = GNUNET_CONFIGURATION_create (); + GNUNET_CONFIGURATION_load (config, "./test-mint-db-postgres.conf"); GNUNET_assert (NULL != (plugin = TALER_MINTDB_plugin_load (config))); plugin->create_tables (plugin->cls, GNUNET_YES); - // Run command - PERF_TALER_MINTDB_interpret(plugin, test); - // Drop tables + PERF_TALER_MINTDB_interpret (plugin, test); + /* Drop tables */ { struct TALER_MINTDB_Session *session; session = plugin->get_session (plugin->cls, GNUNET_YES); plugin->drop_temporary (plugin->cls, session); } - TALER_MINTDB_plugin_unload(plugin); - GNUNET_CONFIGURATION_destroy(config); - return GNUNET_OK; + TALER_MINTDB_plugin_unload (plugin); + GNUNET_CONFIGURATION_destroy (config); + return 0; } diff --git a/src/mintdb/perf_taler_mintdb_init.h b/src/mintdb/perf_taler_mintdb_init.h index 4682f800f..8c49d1a96 100644 --- a/src/mintdb/perf_taler_mintdb_init.h +++ b/src/mintdb/perf_taler_mintdb_init.h @@ -15,7 +15,7 @@ */ /** * @file mintdb/perf_taler_mintdb_init.h - * @brief Heler function for creating dummy inpus for the mint database + * @brief Heler function for creating dummy inputs for the mint database * @author Nicolas Fournier */ #ifndef __PERF_TALER_MINTDB_INIT_H___ diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h index b3e9ba6d5..01fb4b7b3 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.h +++ b/src/mintdb/perf_taler_mintdb_interpreter.h @@ -15,7 +15,7 @@ */ /** * @file mintdb/perf_taler_mintdb_interpreter.h - * @brief Library for performance analysis of taler database + * @brief Library for performance analysis of the Taler database * @author Nicolas Fournier */ @@ -50,7 +50,7 @@ /** * The begining of a loop * @param _label the name of the loop - * @param _iter the number of iteration of the loop + * @param _iter the number of iterations of the loop */ #define PERF_TALER_MINTDB_INIT_CMD_LOOP(_label, _iter) \ { \ @@ -74,22 +74,23 @@ } /** - * Saves the time of execution to use for logging with gauger + * Saves the time of execution to use for logging with Gauger */ #define PERF_TALER_MINTDB_INIT_CMD_GET_TIME(_label) \ { \ .command = PERF_TALER_MINTDB_CMD_GET_TIME, \ .label = _label, \ - .exposed.type = PERF_TALER_MINTDB_NONE, \ + .exposed.type = PERF_TALER_MINTDB_NONE \ } /** * Commits the duration between @a _label_start and @a _label_stop - * to Gauger with @a _description explaining + * to Gauger with @a _description explaining what was measured. + * * @param _label_start label of the start of the measurment * @param _label_stop label of the end of the measurment - * @param _description description of the measure displayed in gauger - * @param _divide number of measurments in the interval + * @param _description description of the measure displayed in Gauger + * @param _divide number of measurments in the interval [FIXME: need UNIT] */ #define PERF_TALER_MINTDB_INIT_CMD_GAUGER(_label, _label_start, _label_stop, _description, _divide) \ { \ @@ -115,7 +116,7 @@ } /** - * Commits a database connection + * Commits a database transaction */ #define PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION(_label) \ { \ @@ -125,7 +126,7 @@ } /** - * Extracts @a _nb_saved items of type @a _save_type + * Extracts @a _nb_saved items of type @a _save_type * from the command @a _label_save during the loop @a _label_loop */ #define PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, _label_save, _nb_saved) \ @@ -142,7 +143,7 @@ /** * Loads @a _nb_saved previously sampled data of type @a _saved_type - * from @a _label_save during the loop @a _label_loop + * from @a _label_save during the loop @a _label_loop */ #define PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, _label_save) \ { \ @@ -244,7 +245,7 @@ /** - * Polls the database about informations regarding a secific withdrawal + * Polls the database about informations regarding a specific withdrawal */ #define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \ { \ @@ -259,7 +260,7 @@ * The type of data stored * in a PERF_TALER_MINTDB_Type */ -enum PERF_TALER_MINTDB_Type +enum PERF_TALER_MINTDB_Type { PERF_TALER_MINTDB_NONE, PERF_TALER_MINTDB_TIME, @@ -267,16 +268,16 @@ enum PERF_TALER_MINTDB_Type PERF_TALER_MINTDB_BLINDCOIN, PERF_TALER_MINTDB_RESERVE, PERF_TALER_MINTDB_DENOMINATION_INFO, - PERF_TALER_MINTDB_COIN_INFO, + PERF_TALER_MINTDB_COIN_INFO }; /** * Storage for a variety of data type */ -union PERF_TALER_MINTDB_Memory +union PERF_TALER_MINTDB_Memory { - struct timespec time; + struct timespec time; struct TALER_MINTDB_Deposit *deposit; struct TALER_MINTDB_CollectableBlindcoin *blindcoin; struct TALER_MINTDB_Reserve *reserve; @@ -286,12 +287,12 @@ union PERF_TALER_MINTDB_Memory /** - * + * */ struct PERF_TALER_MINTDB_Data { - union PERF_TALER_MINTDB_Memory data; enum PERF_TALER_MINTDB_Type type; + union PERF_TALER_MINTDB_Memory data; // inline def. }; @@ -300,15 +301,19 @@ struct PERF_TALER_MINTDB_Data */ enum PERF_TALER_MINTDB_CMD_Name { - // All comand chain must hace this as their last command + /** + * All comand chain must hace this as their last command + */ PERF_TALER_MINTDB_CMD_END, - - // Prints it's label + + /** + * Prints it's label + */ PERF_TALER_MINTDB_CMD_DEBUG, // Define the start of al command chain loop PERF_TALER_MINTDB_CMD_LOOP, - + // Define the end of a command chain loop PERF_TALER_MINTDB_CMD_END_LOOP, @@ -335,7 +340,7 @@ enum PERF_TALER_MINTDB_CMD_Name // Load deposits saved earlier PERF_TALER_MINTDB_CMD_LOAD_ARRAY, - + // Insert a deposit into the database PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT, @@ -361,7 +366,7 @@ enum PERF_TALER_MINTDB_CMD_Name PERF_TALER_MINTDB_CMD_GET_DENOMINATION, // Refresh a coin - PERF_TALER_MINTDB_CMD_REFRESH_COIN, + PERF_TALER_MINTDB_CMD_REFRESH_COIN }; @@ -377,9 +382,9 @@ struct PERF_TALER_MINTDB_CMD_loop_details /** - * Extra data requiered by the LOOP_END command + * Extra data requiered by the #PERF_TALER_MINTDB_CMD_END_LOOP command */ -struct PERF_TALER_MINTDB_CMD_loop_end_details +struct PERF_TALER_MINTDB_CMD_loop_end_details { /** * Label of the loop closed by the command @@ -389,7 +394,7 @@ struct PERF_TALER_MINTDB_CMD_loop_end_details /** - * Details about the GAUGER command + * Details about the Gauger command */ struct PERF_TALER_MINTDB_CMD_gauger_details { @@ -404,7 +409,7 @@ struct PERF_TALER_MINTDB_CMD_gauger_details const char *label_stop; /** - * Description of the metric, used in GAUGER + * Description of the metric, used in Gauger */ const char *description; @@ -458,7 +463,7 @@ struct PERF_TALER_MINTDB_CMD_load_array_details * Label of the command where the items were saved */ const char *label_save; - + /** * A permutation array used to randomize the order the items are loaded in */ @@ -467,7 +472,7 @@ struct PERF_TALER_MINTDB_CMD_load_array_details /** - * Data used by the command insert_deposit + * Data used by the command insert_deposit */ struct PERF_TALER_MINTDB_CMD_insert_deposit_details { diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 81a372e4a..54bbc845e 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -1536,11 +1536,6 @@ postgres_insert_withdraw_info (void *cls, TALER_PQ_query_param_end }; - if (GNUNET_OK != postgres_start (cls, - session)) - { - return GNUNET_SYSERR; - } now = GNUNET_TIME_absolute_get (); result = TALER_PQ_exec_prepared (session->conn, "insert_withdraw_info", @@ -1548,7 +1543,7 @@ postgres_insert_withdraw_info (void *cls, if (PGRES_COMMAND_OK != PQresultStatus (result)) { QUERY_ERR (result); - goto rollback; + goto cleanup; } reserve.pub = collectable->reserve_pub; if (GNUNET_OK != postgres_reserve_get (cls, @@ -1557,7 +1552,7 @@ postgres_insert_withdraw_info (void *cls, { /* Should have been checked before we got here... */ GNUNET_break (0); - goto rollback; + goto cleanup; } if (GNUNET_SYSERR == TALER_amount_subtract (&reserve.balance, @@ -1566,7 +1561,7 @@ postgres_insert_withdraw_info (void *cls, { /* Should have been checked before we got here... */ GNUNET_break (0); - goto rollback; + goto cleanup; } expiry = GNUNET_TIME_absolute_add (now, TALER_IDLE_RESERVE_EXPIRATION_TIME); @@ -1575,17 +1570,11 @@ postgres_insert_withdraw_info (void *cls, if (GNUNET_OK != reserves_update (cls, session, &reserve)) - goto rollback; - if (GNUNET_OK == postgres_commit (cls, - session)) { - ret = GNUNET_OK; + GNUNET_break (0); goto cleanup; } - - rollback: - postgres_rollback (cls, - session); + ret = GNUNET_OK; cleanup: PQclear (result); return ret; |