aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-21 14:21:58 +0100
committerChristian Grothoff <christian@grothoff.org>2015-01-21 14:21:58 +0100
commitc9a819a5efdc359fd8d7a3c32e497679c92d0741 (patch)
tree05d5f3bfdde7a44ea379fae24cfeafcd3b48c1b4
parent2ef511eece640f0e8ecd5fe3bd8dacf092624287 (diff)
downloadexchange-c9a819a5efdc359fd8d7a3c32e497679c92d0741.tar.gz
exchange-c9a819a5efdc359fd8d7a3c32e497679c92d0741.zip
handle DB connect errors
-rw-r--r--src/mint/taler-mint-httpd_db.c23
-rw-r--r--src/mint/taler-mint-httpd_responses.c15
-rw-r--r--src/mint/taler-mint-httpd_responses.h11
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 @@
25 * - /deposit: check for leaks 25 * - /deposit: check for leaks
26 * - ALL: check API: given structs are usually not perfect, as they 26 * - ALL: check API: given structs are usually not perfect, as they
27 * often contain too many fields for the context 27 * often contain too many fields for the context
28 * - ALL: check transactional behavior
28 */ 29 */
29#include "platform.h" 30#include "platform.h"
30#include <pthread.h> 31#include <pthread.h>
@@ -59,8 +60,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
59 if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) 60 if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
60 { 61 {
61 GNUNET_break (0); 62 GNUNET_break (0);
62 return TALER_MINT_reply_internal_error (connection, 63 return TALER_MINT_reply_internal_db_error (connection);
63 "Failed to connect to database");
64 } 64 }
65 res = TALER_MINT_DB_get_deposit (db_conn, 65 res = TALER_MINT_DB_get_deposit (db_conn,
66 &deposit->coin_pub, 66 &deposit->coin_pub,
@@ -176,12 +176,10 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection,
176 struct MintKeyState *key_state; 176 struct MintKeyState *key_state;
177 int must_update = GNUNET_NO; 177 int must_update = GNUNET_NO;
178 178
179
180 if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) 179 if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
181 { 180 {
182 GNUNET_break (0); 181 GNUNET_break (0);
183 return TALER_MINT_reply_internal_error (connection, 182 return TALER_MINT_reply_internal_db_error (connection);
184 "Failed to connect to database");
185 } 183 }
186 res = TALER_MINT_DB_get_reserve (db_conn, 184 res = TALER_MINT_DB_get_reserve (db_conn,
187 reserve_pub, 185 reserve_pub,
@@ -245,9 +243,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
245 243
246 if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) 244 if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
247 { 245 {
248 // FIXME: return 'internal error'?
249 GNUNET_break (0); 246 GNUNET_break (0);
250 return MHD_NO; 247 return TALER_MINT_reply_internal_db_error (connection);
251 } 248 }
252 249
253 250
@@ -576,8 +573,8 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
576 573
577 if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) 574 if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
578 { 575 {
579 /* FIXME: return error code to MHD! */ 576 GNUNET_break (0);
580 return MHD_NO; 577 return TALER_MINT_reply_internal_db_error (connection);
581 } 578 }
582 res = TALER_MINT_DB_get_refresh_session (db_conn, 579 res = TALER_MINT_DB_get_refresh_session (db_conn,
583 refresh_session_pub, 580 refresh_session_pub,
@@ -717,9 +714,8 @@ TALER_MINT_db_execute_refresh_commit (struct MHD_Connection *connection,
717 714
718 if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) 715 if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
719 { 716 {
720 // FIXME: return 'internal error'?
721 GNUNET_break (0); 717 GNUNET_break (0);
722 return MHD_NO; 718 return TALER_MINT_reply_internal_db_error (connection);
723 } 719 }
724 720
725 /* Send response immediately if we already know the session. 721 /* Send response immediately if we already know the session.
@@ -864,8 +860,7 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection,
864 if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) 860 if (NULL == (db_conn = TALER_MINT_DB_get_connection ()))
865 { 861 {
866 GNUNET_break (0); 862 GNUNET_break (0);
867 // FIXME: return error code! 863 return TALER_MINT_reply_internal_db_error (connection);
868 return MHD_NO;
869 } 864 }
870 865
871 res = TALER_db_get_transfer (db_conn, 866 res = TALER_db_get_transfer (db_conn,
@@ -920,6 +915,4 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection,
920 return TALER_MINT_reply_json (connection, 915 return TALER_MINT_reply_json (connection,
921 root, 916 root,
922 MHD_HTTP_OK); 917 MHD_HTTP_OK);
923
924
925} 918}
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,
172 172
173 173
174/** 174/**
175 * Send a response indicating a failure to talk to the Mint's
176 * database.
177 *
178 * @param connection the MHD connection to use
179 * @return a MHD result code
180 */
181int
182TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection)
183{
184 return TALER_MINT_reply_internal_error (connection,
185 "Failed to connect to database");
186}
187
188
189/**
175 * Send a response indicating that the request was too big. 190 * Send a response indicating that the request was too big.
176 * 191 *
177 * @param connection the MHD connection to use 192 * @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,
104 104
105 105
106/** 106/**
107 * Send a response indicating a failure to talk to the Mint's
108 * database.
109 *
110 * @param connection the MHD connection to use
111 * @return a MHD result code
112 */
113int
114TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection);
115
116
117/**
107 * Send a response indicating that the request was too big. 118 * Send a response indicating that the request was too big.
108 * 119 *
109 * @param connection the MHD connection to use 120 * @param connection the MHD connection to use