check dbinit return value to not fail hard if DB not available

This commit is contained in:
Christian Grothoff 2016-10-10 16:54:37 +02:00
parent 808dc10bf4
commit 25618c561e
3 changed files with 33 additions and 4 deletions

View File

@ -554,7 +554,12 @@ decode_keys_json (const json_t *resp_obj,
EXITIF (NULL == (denom_keys_array = EXITIF (NULL == (denom_keys_array =
json_object_get (resp_obj, "denoms"))); json_object_get (resp_obj, "denoms")));
EXITIF (JSON_ARRAY != json_typeof (denom_keys_array)); EXITIF (JSON_ARRAY != json_typeof (denom_keys_array));
EXITIF (0 == (key_data->num_denom_keys = json_array_size (denom_keys_array))); if (0 == (key_data->num_denom_keys = json_array_size (denom_keys_array)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Found no denomination keys at this exchange\n");
goto EXITIF_exit;
}
key_data->denom_keys = GNUNET_new_array (key_data->num_denom_keys, key_data->denom_keys = GNUNET_new_array (key_data->num_denom_keys,
struct TALER_EXCHANGE_DenomPublicKey); struct TALER_EXCHANGE_DenomPublicKey);
index = 0; index = 0;

View File

@ -3047,6 +3047,8 @@ main (int argc,
struct GNUNET_OS_Process *proc; struct GNUNET_OS_Process *proc;
struct GNUNET_OS_Process *exchanged; struct GNUNET_OS_Process *exchanged;
struct GNUNET_SIGNAL_Context *shc_chld; struct GNUNET_SIGNAL_Context *shc_chld;
enum GNUNET_OS_ProcessStatusType type;
unsigned long code;
GNUNET_log_setup ("test-exchange-api", GNUNET_log_setup ("test-exchange-api",
"WARNING", "WARNING",
@ -3071,8 +3073,30 @@ main (int argc,
"-c", "test_exchange_api.conf", "-c", "test_exchange_api.conf",
"-r", "-r",
NULL); NULL);
GNUNET_OS_process_wait (proc); if (GNUNET_SYSERR ==
GNUNET_OS_process_wait_status (proc,
&type,
&code))
{
GNUNET_break (0);
GNUNET_OS_process_destroy (proc);
return 1;
}
GNUNET_OS_process_destroy (proc); GNUNET_OS_process_destroy (proc);
if ( (type == GNUNET_OS_PROCESS_EXITED) &&
(0 != code) )
{
fprintf (stderr,
"Failed to setup database\n");
return 77;
}
if ( (type != GNUNET_OS_PROCESS_EXITED) ||
(0 != code) )
{
fprintf (stderr,
"Unexpected error running taler-exchange-dbinit!\n");
return 1;
}
exchanged = GNUNET_OS_start_process (GNUNET_NO, exchanged = GNUNET_OS_start_process (GNUNET_NO,
GNUNET_OS_INHERIT_STD_ALL, GNUNET_OS_INHERIT_STD_ALL,
NULL, NULL, NULL, NULL, NULL, NULL,
@ -3081,7 +3105,8 @@ main (int argc,
"-c", "test_exchange_api.conf", "-c", "test_exchange_api.conf",
NULL); NULL);
/* give child time to start and bind against the socket */ /* give child time to start and bind against the socket */
fprintf (stderr, "Waiting for taler-exchange-httpd to be ready"); fprintf (stderr,
"Waiting for taler-exchange-httpd to be ready");
do do
{ {
fprintf (stderr, "."); fprintf (stderr, ".");

View File

@ -180,7 +180,6 @@ connect_to_postgres (struct PostgresClosure *pc)
{ {
TALER_LOG_ERROR ("Database connection failed: %s\n", TALER_LOG_ERROR ("Database connection failed: %s\n",
PQerrorMessage (conn)); PQerrorMessage (conn));
GNUNET_break (0);
return NULL; return NULL;
} }
PQsetNoticeReceiver (conn, PQsetNoticeReceiver (conn,