diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-21 14:21:58 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-21 14:21:58 +0100 |
commit | c9a819a5efdc359fd8d7a3c32e497679c92d0741 (patch) | |
tree | 05d5f3bfdde7a44ea379fae24cfeafcd3b48c1b4 | |
parent | 2ef511eece640f0e8ecd5fe3bd8dacf092624287 (diff) |
handle DB connect errors
-rw-r--r-- | src/mint/taler-mint-httpd_db.c | 23 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.c | 15 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 11 |
3 files changed, 34 insertions, 15 deletions
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index f5aa11722..bcdda621a 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -25,6 +25,7 @@ * - /deposit: check for leaks * - ALL: check API: given structs are usually not perfect, as they * often contain too many fields for the context + * - ALL: check transactional behavior */ #include "platform.h" #include <pthread.h> @@ -59,8 +60,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection, if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) { GNUNET_break (0); - return TALER_MINT_reply_internal_error (connection, - "Failed to connect to database"); + return TALER_MINT_reply_internal_db_error (connection); } res = TALER_MINT_DB_get_deposit (db_conn, &deposit->coin_pub, @@ -176,12 +176,10 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection, struct MintKeyState *key_state; int must_update = GNUNET_NO; - if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) { GNUNET_break (0); - return TALER_MINT_reply_internal_error (connection, - "Failed to connect to database"); + return TALER_MINT_reply_internal_db_error (connection); } res = TALER_MINT_DB_get_reserve (db_conn, reserve_pub, @@ -245,9 +243,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection, if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) { - // FIXME: return 'internal error'? GNUNET_break (0); - return MHD_NO; + return TALER_MINT_reply_internal_db_error (connection); } @@ -576,8 +573,8 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection, if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) { - /* FIXME: return error code to MHD! */ - return MHD_NO; + GNUNET_break (0); + return TALER_MINT_reply_internal_db_error (connection); } res = TALER_MINT_DB_get_refresh_session (db_conn, refresh_session_pub, @@ -717,9 +714,8 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection, if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) { - // FIXME: return 'internal error'? GNUNET_break (0); - return MHD_NO; + return TALER_MINT_reply_internal_db_error (connection); } /* Send response immediately if we already know the session. @@ -864,8 +860,7 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection, if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) { GNUNET_break (0); - // FIXME: return error code! - return MHD_NO; + return TALER_MINT_reply_internal_db_error (connection); } res = TALER_db_get_transfer (db_conn, @@ -920,6 +915,4 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection, return TALER_MINT_reply_json (connection, root, MHD_HTTP_OK); - - } diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index 9ba855eea..75342cd2d 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -172,6 +172,21 @@ TALER_MINT_reply_internal_error (struct MHD_Connection *connection, /** + * Send a response indicating a failure to talk to the Mint's + * database. + * + * @param connection the MHD connection to use + * @return a MHD result code + */ +int +TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection) +{ + return TALER_MINT_reply_internal_error (connection, + "Failed to connect to database"); +} + + +/** * Send a response indicating that the request was too big. * * @param connection the MHD connection to use diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index 55ebc0ca9..11e916f16 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h @@ -104,6 +104,17 @@ TALER_MINT_reply_internal_error (struct MHD_Connection *connection, /** + * Send a response indicating a failure to talk to the Mint's + * database. + * + * @param connection the MHD connection to use + * @return a MHD result code + */ +int +TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection); + + +/** * Send a response indicating that the request was too big. * * @param connection the MHD connection to use |