diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-06-18 15:13:13 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-06-19 00:17:15 +0200 |
commit | d2c7ef54a7eb906b40032969b5bc45c180003f4b (patch) | |
tree | 78192ff99f013e7d926c5f2acd0601c68f5bc485 /src/exchange/taler-exchange-httpd_db.c | |
parent | d66a29e383d1a6985906136c9606fcd18cb1c124 (diff) | |
download | exchange-d2c7ef54a7eb906b40032969b5bc45c180003f4b.tar.gz exchange-d2c7ef54a7eb906b40032969b5bc45c180003f4b.tar.bz2 exchange-d2c7ef54a7eb906b40032969b5bc45c180003f4b.zip |
convert another function for #5010
Diffstat (limited to 'src/exchange/taler-exchange-httpd_db.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_db.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 71f82e9d5..abbb6c3fe 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -228,6 +228,8 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection, struct TEH_KS_StateHandle *mks; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; int ret; + enum GNUNET_DB_QueryStatus qs; + unsigned int retries = 0; if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls))) { @@ -235,6 +237,7 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection, return TEH_RESPONSE_reply_internal_db_error (connection, TALER_EC_DB_SETUP_FAILED); } + again: if (GNUNET_YES == TEH_plugin->have_deposit (TEH_plugin->cls, session, @@ -305,10 +308,10 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection, } TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); - if (GNUNET_OK != - TEH_plugin->insert_deposit (TEH_plugin->cls, - session, - deposit)) + qs = TEH_plugin->insert_deposit (TEH_plugin->cls, + session, + deposit); + if (GNUNET_DB_STATUS_HARD_ERROR == qs) { TALER_LOG_WARNING ("Failed to store /deposit information in database\n"); TEH_plugin->rollback (TEH_plugin->cls, @@ -316,6 +319,16 @@ TEH_DB_execute_deposit (struct MHD_Connection *connection, return TEH_RESPONSE_reply_internal_db_error (connection, TALER_EC_DEPOSIT_STORE_DB_ERROR); } + if (GNUNET_DB_STATUS_SOFT_ERROR == qs) + { + retries++; + TEH_plugin->rollback (TEH_plugin->cls, + session); + if (retries > 5) + return TEH_RESPONSE_reply_internal_db_error (connection, + TALER_EC_DEPOSIT_STORE_DB_ERROR); + goto again; + } COMMIT_TRANSACTION(session, connection); GNUNET_assert (GNUNET_SYSERR != |