From 33f5242ac4105d8631d659447989cb718459b081 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 May 2015 17:08:56 +0200 Subject: transaction logic is inside of DB function --- src/mint-tools/taler-mint-reservemod.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'src/mint-tools/taler-mint-reservemod.c') diff --git a/src/mint-tools/taler-mint-reservemod.c b/src/mint-tools/taler-mint-reservemod.c index 5bb6bce46..8607c6dbf 100644 --- a/src/mint-tools/taler-mint-reservemod.c +++ b/src/mint-tools/taler-mint-reservemod.c @@ -153,14 +153,6 @@ main (int argc, char *const *argv) "Failed to initialize DB session\n"); goto cleanup; } - if (GNUNET_OK != - plugin->start (plugin->cls, - session)) - { - fprintf (stderr, - "Failed to start transaction\n"); - goto cleanup; - } expiration = GNUNET_TIME_relative_to_absolute (RESERVE_EXPIRATION); if (GNUNET_OK != plugin->reserves_in_insert (plugin->cls, @@ -174,14 +166,6 @@ main (int argc, char *const *argv) "Failed to update reserve.\n"); goto cleanup; } - if (GNUNET_OK != - plugin->commit (plugin->cls, - session)) - { - fprintf (stderr, - "Failed to commit transaction\n"); - goto cleanup; - } ret = 0; cleanup: if (NULL != plugin) -- cgit v1.2.3 From d080e59e272e307b9ebc267f2c4dd2941cd79436 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 15 May 2015 17:24:27 +0200 Subject: resolve #3717 --- src/mint-tools/taler-mint-reservemod.c | 40 ++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'src/mint-tools/taler-mint-reservemod.c') diff --git a/src/mint-tools/taler-mint-reservemod.c b/src/mint-tools/taler-mint-reservemod.c index 8607c6dbf..645a2f32e 100644 --- a/src/mint-tools/taler-mint-reservemod.c +++ b/src/mint-tools/taler-mint-reservemod.c @@ -98,6 +98,9 @@ main (int argc, char *const *argv) { fprintf (stderr, "Mint directory not given\n"); + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (details); + GNUNET_free_non_null (reserve_pub_str); return 1; } if ((NULL == reserve_pub_str) || @@ -109,6 +112,9 @@ main (int argc, char *const *argv) { fprintf (stderr, "Parsing reserve key invalid\n"); + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (details); + GNUNET_free_non_null (reserve_pub_str); return 1; } if ( (NULL == add_str) || @@ -119,6 +125,9 @@ main (int argc, char *const *argv) fprintf (stderr, "Failed to parse currency amount `%s'\n", add_str); + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (details); + GNUNET_free_non_null (reserve_pub_str); return 1; } @@ -126,7 +135,9 @@ main (int argc, char *const *argv) { fprintf (stderr, "No wiring details given (justification required)\n"); - return 1; + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (reserve_pub_str); + return 1; } cfg = TALER_config_load (mint_directory); @@ -134,7 +145,10 @@ main (int argc, char *const *argv) { fprintf (stderr, "Failed to load mint configuration\n"); - return 1; + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (details); + GNUNET_free_non_null (reserve_pub_str); + return 1; } ret = 1; if (NULL == @@ -154,24 +168,32 @@ main (int argc, char *const *argv) goto cleanup; } expiration = GNUNET_TIME_relative_to_absolute (RESERVE_EXPIRATION); - if (GNUNET_OK != - plugin->reserves_in_insert (plugin->cls, - session, - &reserve_pub, - &add_value, - details, - expiration)) + ret = plugin->reserves_in_insert (plugin->cls, + session, + &reserve_pub, + &add_value, + details, + expiration); + if (GNUNET_SYSERR == ret) { fprintf (stderr, "Failed to update reserve.\n"); goto cleanup; } + if (GNUNET_NO == ret) + { + fprintf (stderr, + "Record exists, reserve not updated.\n"); + } ret = 0; cleanup: if (NULL != plugin) TALER_MINTDB_plugin_unload (plugin); if (NULL != cfg) GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_free_non_null (add_str); + GNUNET_free_non_null (details); + GNUNET_free_non_null (reserve_pub_str); return ret; } -- cgit v1.2.3 From aa89db4d0a92f341eb6239a06c7b69410934132b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 16 May 2015 20:33:01 +0200 Subject: organize #include, remove redundant includes --- src/mint-tools/taler-mint-reservemod.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/mint-tools/taler-mint-reservemod.c') diff --git a/src/mint-tools/taler-mint-reservemod.c b/src/mint-tools/taler-mint-reservemod.c index 645a2f32e..9dff5731c 100644 --- a/src/mint-tools/taler-mint-reservemod.c +++ b/src/mint-tools/taler-mint-reservemod.c @@ -22,11 +22,7 @@ #include "platform.h" #include #include -#include "taler_util.h" -#include "taler_signatures.h" -#include "taler_pq_lib.h" #include "taler_mintdb_plugin.h" -#include "taler_mintdb_lib.h" /** * After what time to inactive reserves expire? -- cgit v1.2.3