match GNUnet API rename, work on #5010
This commit is contained in:
parent
780b716652
commit
cad64767d9
@ -732,6 +732,29 @@ static void
|
|||||||
run_aggregation (void *cls);
|
run_aggregation (void *cls);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a database commit. If it fails, print a warning.
|
||||||
|
*
|
||||||
|
* @param session session to perform the commit for.
|
||||||
|
* @return status of commit
|
||||||
|
*/
|
||||||
|
static enum GNUNET_DB_QueryStatus
|
||||||
|
commit_or_warn (struct TALER_EXCHANGEDB_Session *session)
|
||||||
|
{
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
|
qs = db_plugin->commit (db_plugin->cls,
|
||||||
|
session);
|
||||||
|
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
|
||||||
|
return qs;
|
||||||
|
GNUNET_log ((GNUNET_DB_STATUS_SOFT_ERROR == qs)
|
||||||
|
? GNUNET_ERROR_TYPE_INFO
|
||||||
|
: GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Failed to commit database transaction!\n");
|
||||||
|
return qs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to be called with the prepared transfer data
|
* Function to be called with the prepared transfer data
|
||||||
* when closing a reserve.
|
* when closing a reserve.
|
||||||
@ -782,13 +805,7 @@ prepare_close_cb (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* finally commit */
|
/* finally commit */
|
||||||
if (GNUNET_OK !=
|
(void) commit_or_warn (ctc->session);
|
||||||
db_plugin->commit (db_plugin->cls,
|
|
||||||
ctc->session))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
|
||||||
"Failed to commit database transaction!\n");
|
|
||||||
}
|
|
||||||
GNUNET_free (ctc->type);
|
GNUNET_free (ctc->type);
|
||||||
GNUNET_free (ctc);
|
GNUNET_free (ctc);
|
||||||
ctc = NULL;
|
ctc = NULL;
|
||||||
@ -948,13 +965,7 @@ expired_reserve_cb (void *cls,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
/* Reserve balance was almost zero; just commit */
|
/* Reserve balance was almost zero; just commit */
|
||||||
if (GNUNET_OK !=
|
(void) commit_or_warn (session);
|
||||||
db_plugin->commit (db_plugin->cls,
|
|
||||||
session))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
|
||||||
"Failed to commit database transaction!\n");
|
|
||||||
}
|
|
||||||
task = GNUNET_SCHEDULER_add_now (&run_reserve_closures,
|
task = GNUNET_SCHEDULER_add_now (&run_reserve_closures,
|
||||||
NULL);
|
NULL);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -1191,13 +1202,7 @@ run_aggregation (void *cls)
|
|||||||
au->additional_rows[i]))
|
au->additional_rows[i]))
|
||||||
ret = GNUNET_SYSERR;
|
ret = GNUNET_SYSERR;
|
||||||
/* commit */
|
/* commit */
|
||||||
if (GNUNET_OK !=
|
(void) commit_or_warn (session);
|
||||||
db_plugin->commit (db_plugin->cls,
|
|
||||||
session))
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
|
||||||
"Failed to commit database transaction!\n");
|
|
||||||
}
|
|
||||||
GNUNET_free_non_null (au->additional_rows);
|
GNUNET_free_non_null (au->additional_rows);
|
||||||
if (NULL != au->wire)
|
if (NULL != au->wire)
|
||||||
json_decref (au->wire);
|
json_decref (au->wire);
|
||||||
@ -1336,6 +1341,8 @@ prepare_cb (void *cls,
|
|||||||
au = NULL;
|
au = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
|
"Stored wire transfer out instructions\n");
|
||||||
if (NULL != au->wire)
|
if (NULL != au->wire)
|
||||||
{
|
{
|
||||||
json_decref (au->wire);
|
json_decref (au->wire);
|
||||||
@ -1346,22 +1353,31 @@ prepare_cb (void *cls,
|
|||||||
|
|
||||||
/* Now we can finally commit the overall transaction, as we are
|
/* Now we can finally commit the overall transaction, as we are
|
||||||
again consistent if all of this passes. */
|
again consistent if all of this passes. */
|
||||||
if (GNUNET_OK !=
|
switch (commit_or_warn (session))
|
||||||
db_plugin->commit (db_plugin->cls,
|
|
||||||
session))
|
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
case GNUNET_DB_STATUS_SOFT_ERROR:
|
||||||
"Failed to commit database transaction!\n");
|
|
||||||
/* try again */
|
/* try again */
|
||||||
task = GNUNET_SCHEDULER_add_now (&run_aggregation,
|
task = GNUNET_SCHEDULER_add_now (&run_aggregation,
|
||||||
NULL);
|
NULL);
|
||||||
return;
|
return;
|
||||||
|
case GNUNET_DB_STATUS_HARD_ERROR:
|
||||||
|
GNUNET_break (0);
|
||||||
|
global_ret = GNUNET_SYSERR;
|
||||||
|
GNUNET_SCHEDULER_shutdown ();
|
||||||
|
return;
|
||||||
|
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Preparation complete, switching to transfer mode\n");
|
||||||
|
/* run alternative task: actually do wire transfer! */
|
||||||
|
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
||||||
|
NULL);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
GNUNET_break (0);
|
||||||
|
global_ret = GNUNET_SYSERR;
|
||||||
|
GNUNET_SCHEDULER_shutdown ();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
|
||||||
"Preparation complete, switching to transfer mode\n");
|
|
||||||
/* run alternative task: actually do wire transfer! */
|
|
||||||
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1411,24 +1427,32 @@ wire_confirm_cb (void *cls,
|
|||||||
}
|
}
|
||||||
GNUNET_free (wpd);
|
GNUNET_free (wpd);
|
||||||
wpd = NULL;
|
wpd = NULL;
|
||||||
if (GNUNET_OK !=
|
switch (commit_or_warn (session))
|
||||||
db_plugin->commit (db_plugin->cls,
|
|
||||||
session))
|
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
case GNUNET_DB_STATUS_SOFT_ERROR:
|
||||||
"Failed to commit database transaction!\n");
|
|
||||||
/* try again */
|
/* try again */
|
||||||
task = GNUNET_SCHEDULER_add_now (&run_aggregation,
|
task = GNUNET_SCHEDULER_add_now (&run_aggregation,
|
||||||
NULL);
|
NULL);
|
||||||
return;
|
return;
|
||||||
|
case GNUNET_DB_STATUS_HARD_ERROR:
|
||||||
|
GNUNET_break (0);
|
||||||
|
global_ret = GNUNET_SYSERR;
|
||||||
|
GNUNET_SCHEDULER_shutdown ();
|
||||||
|
return;
|
||||||
|
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
|
"Wire transfer complete\n");
|
||||||
|
/* continue with #run_transfers(), just to guard
|
||||||
|
against the unlikely case that there are more. */
|
||||||
|
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
||||||
|
NULL);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
GNUNET_break (0);
|
||||||
|
global_ret = GNUNET_SYSERR;
|
||||||
|
GNUNET_SCHEDULER_shutdown ();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
|
||||||
"Wire transfer complete\n");
|
|
||||||
/* continue with #run_transfers(), just to guard
|
|
||||||
against the unlikely case that there are more. */
|
|
||||||
task = GNUNET_SCHEDULER_add_now (&run_transfers,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#define START_TRANSACTION(session,connection) \
|
#define START_TRANSACTION(session,connection) \
|
||||||
{ /* start new scope, will be ended by COMMIT_TRANSACTION() */\
|
{ /* start new scope, will be ended by COMMIT_TRANSACTION() */\
|
||||||
unsigned int transaction_retries = 0; \
|
unsigned int transaction_retries = 0; \
|
||||||
int transaction_commit_result; \
|
enum GNUNET_DB_QueryStatus transaction_commit_result; \
|
||||||
transaction_start_label: /* we will use goto for retries */ \
|
transaction_start_label: /* we will use goto for retries */ \
|
||||||
if (GNUNET_OK != \
|
if (GNUNET_OK != \
|
||||||
TEH_plugin->start (TEH_plugin->cls, \
|
TEH_plugin->start (TEH_plugin->cls, \
|
||||||
@ -71,13 +71,13 @@ transaction_start_label: /* we will use goto for retries */ \
|
|||||||
transaction_commit_result = \
|
transaction_commit_result = \
|
||||||
TEH_plugin->commit (TEH_plugin->cls, \
|
TEH_plugin->commit (TEH_plugin->cls, \
|
||||||
session); \
|
session); \
|
||||||
if (GNUNET_SYSERR == transaction_commit_result) \
|
if (GNUNET_DB_STATUS_HARD_ERROR == transaction_commit_result) \
|
||||||
{ \
|
{ \
|
||||||
TALER_LOG_WARNING ("Transaction commit failed in %s\n", __FUNCTION__); \
|
TALER_LOG_WARNING ("Transaction commit failed in %s\n", __FUNCTION__); \
|
||||||
return TEH_RESPONSE_reply_commit_error (connection, \
|
return TEH_RESPONSE_reply_commit_error (connection, \
|
||||||
TALER_EC_DB_COMMIT_FAILED_HARD); \
|
TALER_EC_DB_COMMIT_FAILED_HARD); \
|
||||||
} \
|
} \
|
||||||
if (GNUNET_NO == transaction_commit_result) \
|
if (GNUNET_DB_STATUS_SOFT_ERROR == transaction_commit_result) \
|
||||||
{ \
|
{ \
|
||||||
TALER_LOG_WARNING ("Transaction commit failed in %s\n", __FUNCTION__); \
|
TALER_LOG_WARNING ("Transaction commit failed in %s\n", __FUNCTION__); \
|
||||||
if (transaction_retries++ <= MAX_TRANSACTION_COMMIT_RETRIES) \
|
if (transaction_retries++ <= MAX_TRANSACTION_COMMIT_RETRIES) \
|
||||||
|
@ -331,7 +331,9 @@ reload_keys_denom_iter (void *cls,
|
|||||||
struct GNUNET_TIME_Absolute expire_deposit;
|
struct GNUNET_TIME_Absolute expire_deposit;
|
||||||
struct GNUNET_HashCode denom_key_hash;
|
struct GNUNET_HashCode denom_key_hash;
|
||||||
struct TALER_EXCHANGEDB_Session *session;
|
struct TALER_EXCHANGEDB_Session *session;
|
||||||
|
unsigned int thresh;
|
||||||
int res;
|
int res;
|
||||||
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Loading denomination key `%s'\n",
|
"Loading denomination key `%s'\n",
|
||||||
@ -361,8 +363,6 @@ reload_keys_denom_iter (void *cls,
|
|||||||
|
|
||||||
if (NULL != revocation_master_sig)
|
if (NULL != revocation_master_sig)
|
||||||
{
|
{
|
||||||
unsigned int thresh = 0;
|
|
||||||
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Adding denomination key `%s' to revokation set\n",
|
"Adding denomination key `%s' to revokation set\n",
|
||||||
alias);
|
alias);
|
||||||
@ -373,11 +373,13 @@ reload_keys_denom_iter (void *cls,
|
|||||||
/* Try to insert DKI into DB until we succeed; note that if the DB
|
/* Try to insert DKI into DB until we succeed; note that if the DB
|
||||||
failure is persistent, we need to die, as we cannot continue
|
failure is persistent, we need to die, as we cannot continue
|
||||||
without the DKI being in the DB). */
|
without the DKI being in the DB). */
|
||||||
res = GNUNET_SYSERR;
|
thresh = 0;
|
||||||
while (GNUNET_OK != res)
|
qs = GNUNET_DB_STATUS_SOFT_ERROR;
|
||||||
|
while (0 > qs)
|
||||||
{
|
{
|
||||||
thresh++;
|
thresh++;
|
||||||
if (thresh > 16)
|
if ( (thresh > 16) ||
|
||||||
|
(GNUNET_DB_STATUS_HARD_ERROR == qs) )
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Giving up, this is fatal. Committing suicide via SIGTERM.\n");
|
"Giving up, this is fatal. Committing suicide via SIGTERM.\n");
|
||||||
@ -409,8 +411,8 @@ reload_keys_denom_iter (void *cls,
|
|||||||
session);
|
session);
|
||||||
break; /* already in is also OK! */
|
break; /* already in is also OK! */
|
||||||
}
|
}
|
||||||
res = TEH_plugin->commit (TEH_plugin->cls,
|
qs = TEH_plugin->commit (TEH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
}
|
}
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
json_array_append_new (ctx->payback_array,
|
json_array_append_new (ctx->payback_array,
|
||||||
@ -440,12 +442,22 @@ reload_keys_denom_iter (void *cls,
|
|||||||
if (NULL == session)
|
if (NULL == session)
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
/* Try to insert DKI into DB until we succeed; note that if the DB
|
/* Try to insert DKI into DB until we succeed; note that if the DB
|
||||||
failure is persistent, this code may loop forever (as there is no
|
failure is persistent, we die, as we cannot continue without the
|
||||||
sane alternative, we cannot continue without the DKI being in the
|
DKI being in the DB). */
|
||||||
DB). */
|
qs = GNUNET_DB_STATUS_SOFT_ERROR;
|
||||||
res = GNUNET_SYSERR;
|
thresh = 0;
|
||||||
while (GNUNET_OK != res)
|
while (0 > qs)
|
||||||
{
|
{
|
||||||
|
thresh++;
|
||||||
|
if ( (thresh > 16) ||
|
||||||
|
(GNUNET_DB_STATUS_HARD_ERROR == qs) )
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Giving up, this is fatal. Committing suicide via SIGTERM.\n");
|
||||||
|
handle_signal (SIGTERM);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
|
||||||
res = TEH_plugin->start (TEH_plugin->cls,
|
res = TEH_plugin->start (TEH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
@ -485,8 +497,8 @@ reload_keys_denom_iter (void *cls,
|
|||||||
session);
|
session);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
res = TEH_plugin->commit (TEH_plugin->cls,
|
qs = TEH_plugin->commit (TEH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
/* If commit succeeded, we're done, otherwise we retry; this
|
/* If commit succeeded, we're done, otherwise we retry; this
|
||||||
time without logging, as theroetically commits can fail
|
time without logging, as theroetically commits can fail
|
||||||
in a transactional DB due to concurrent activities that
|
in a transactional DB due to concurrent activities that
|
||||||
|
@ -450,7 +450,7 @@ do_deposit (struct Command *cmd)
|
|||||||
plugin->insert_deposit (plugin->cls,
|
plugin->insert_deposit (plugin->cls,
|
||||||
session,
|
session,
|
||||||
&deposit)) ||
|
&deposit)) ||
|
||||||
(GNUNET_OK !=
|
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session)) )
|
session)) )
|
||||||
ret = GNUNET_SYSERR;
|
ret = GNUNET_SYSERR;
|
||||||
@ -1148,7 +1148,7 @@ run (void *cls)
|
|||||||
session,
|
session,
|
||||||
&dpk,
|
&dpk,
|
||||||
&issue)) ||
|
&issue)) ||
|
||||||
(GNUNET_OK !=
|
(GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session)) )
|
session)) )
|
||||||
{
|
{
|
||||||
|
@ -1292,13 +1292,16 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION:
|
case PERF_TALER_EXCHANGEDB_CMD_START_TRANSACTION:
|
||||||
state->plugin->start (state->plugin->cls, state->session);
|
GNUNET_break (GNUNET_OK ==
|
||||||
|
state->plugin->start (state->plugin->cls,
|
||||||
|
state->session));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION:
|
case PERF_TALER_EXCHANGEDB_CMD_COMMIT_TRANSACTION:
|
||||||
state->plugin->commit (state->plugin->cls, state->session);
|
GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
|
||||||
|
state->plugin->commit (state->plugin->cls,
|
||||||
|
state->session));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION:
|
case PERF_TALER_EXCHANGEDB_CMD_ABORT_TRANSACTION:
|
||||||
state->plugin->rollback (state->plugin->cls,
|
state->plugin->rollback (state->plugin->cls,
|
||||||
state->session);
|
state->session);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1337,7 +1337,7 @@ test_wire_out (struct TALER_EXCHANGEDB_Session *session,
|
|||||||
wire_out_account,
|
wire_out_account,
|
||||||
&wire_out_amount));
|
&wire_out_amount));
|
||||||
/* And now the commit should still succeed! */
|
/* And now the commit should still succeed! */
|
||||||
FAILIF (GNUNET_OK !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session));
|
session));
|
||||||
|
|
||||||
@ -1828,7 +1828,7 @@ run (void *cls)
|
|||||||
plugin->mark_deposit_done (plugin->cls,
|
plugin->mark_deposit_done (plugin->cls,
|
||||||
session,
|
session,
|
||||||
deposit_rowid));
|
deposit_rowid));
|
||||||
FAILIF (GNUNET_OK !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session));
|
session));
|
||||||
FAILIF (GNUNET_YES !=
|
FAILIF (GNUNET_YES !=
|
||||||
@ -1873,7 +1873,7 @@ run (void *cls)
|
|||||||
session,
|
session,
|
||||||
&dkp_pub_hash,
|
&dkp_pub_hash,
|
||||||
&master_sig));
|
&master_sig));
|
||||||
FAILIF (GNUNET_OK !=
|
FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
|
||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session));
|
session));
|
||||||
FAILIF (GNUNET_OK !=
|
FAILIF (GNUNET_OK !=
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
|
#include <gnunet/gnunet_db_lib.h>
|
||||||
#include "taler_exchangedb_lib.h"
|
#include "taler_exchangedb_lib.h"
|
||||||
|
|
||||||
|
|
||||||
@ -1109,7 +1110,7 @@ struct TALER_EXCHANGEDB_Plugin
|
|||||||
* @return #GNUNET_OK on success, #GNUNET_NO if the transaction
|
* @return #GNUNET_OK on success, #GNUNET_NO if the transaction
|
||||||
* can be retried, #GNUNET_SYSERR on hard failures
|
* can be retried, #GNUNET_SYSERR on hard failures
|
||||||
*/
|
*/
|
||||||
int
|
enum GNUNET_DB_QueryStatus
|
||||||
(*commit) (void *cls,
|
(*commit) (void *cls,
|
||||||
struct TALER_EXCHANGEDB_Session *session);
|
struct TALER_EXCHANGEDB_Session *session);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user