diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-10-10 16:54:37 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-10-10 16:54:37 +0200 |
commit | 25618c561e55fb82ab2b3701a4e207106300711f (patch) | |
tree | 7b06f0989dfa5ba1ce7f22e28952c1a79c706266 | |
parent | 808dc10bf4c0bffda06a2f617f361a0c2ea7ef58 (diff) | |
download | exchange-25618c561e55fb82ab2b3701a4e207106300711f.tar.xz |
check dbinit return value to not fail hard if DB not available
-rw-r--r-- | src/exchange-lib/exchange_api_handle.c | 7 | ||||
-rw-r--r-- | src/exchange-lib/test_exchange_api.c | 29 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 1 |
3 files changed, 33 insertions, 4 deletions
diff --git a/src/exchange-lib/exchange_api_handle.c b/src/exchange-lib/exchange_api_handle.c index 06dc2bf8d..152114850 100644 --- a/src/exchange-lib/exchange_api_handle.c +++ b/src/exchange-lib/exchange_api_handle.c @@ -554,7 +554,12 @@ decode_keys_json (const json_t *resp_obj, EXITIF (NULL == (denom_keys_array = json_object_get (resp_obj, "denoms"))); 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, struct TALER_EXCHANGE_DenomPublicKey); index = 0; diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index c5efe4594..541a621d2 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -3047,6 +3047,8 @@ main (int argc, struct GNUNET_OS_Process *proc; struct GNUNET_OS_Process *exchanged; struct GNUNET_SIGNAL_Context *shc_chld; + enum GNUNET_OS_ProcessStatusType type; + unsigned long code; GNUNET_log_setup ("test-exchange-api", "WARNING", @@ -3071,8 +3073,30 @@ main (int argc, "-c", "test_exchange_api.conf", "-r", 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); + 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, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL, NULL, @@ -3081,7 +3105,8 @@ main (int argc, "-c", "test_exchange_api.conf", NULL); /* 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 { fprintf (stderr, "."); diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 72320d6e5..c53b0a25d 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -180,7 +180,6 @@ connect_to_postgres (struct PostgresClosure *pc) { TALER_LOG_ERROR ("Database connection failed: %s\n", PQerrorMessage (conn)); - GNUNET_break (0); return NULL; } PQsetNoticeReceiver (conn, |