diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_history.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_history.c | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/src/backend/taler-merchant-httpd_history.c b/src/backend/taler-merchant-httpd_history.c index e4058722..9d6459ef 100644 --- a/src/backend/taler-merchant-httpd_history.c +++ b/src/backend/taler-merchant-httpd_history.c @@ -93,11 +93,12 @@ MH_handler_history (struct TMH_RequestHandler *rh, const char *str; struct GNUNET_TIME_Absolute date; json_t *response; - unsigned int ret; + int ret; unsigned long long seconds; struct MerchantInstance *mi; int start = -1; unsigned int delta; + enum GNUNET_DB_QueryStatus qs; response = json_array (); str = MHD_lookup_connection_value (connection, @@ -107,7 +108,9 @@ MH_handler_history (struct TMH_RequestHandler *rh, if (NULL != str) { - if (1 != sscanf (str, "%llu", &seconds)) + if (1 != sscanf (str, + "%llu", + &seconds)) { json_decref (response); return TMH_RESPONSE_reply_arg_invalid (connection, @@ -147,13 +150,17 @@ MH_handler_history (struct TMH_RequestHandler *rh, if (NULL != str) { - - ret = db->find_contract_terms_history (db->cls, - str, - &mi->pubkey, - &pd_cb, - response); - if (GNUNET_SYSERR == ret) + qs = db->find_contract_terms_history (db->cls, + str, + &mi->pubkey, + &pd_cb, + response); + /* single, read-only SQL statements should never cause + serialization problems */ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); + /* Always report on hard error as well to enable diagnostics */ + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + if (0 > qs) { json_decref (response); return TMH_RESPONSE_reply_internal_error (connection, @@ -174,7 +181,9 @@ MH_handler_history (struct TMH_RequestHandler *rh, "start"); if (NULL != str) { - if ( (1 != sscanf (str, "%d", &start)) || + if ( (1 != sscanf (str, + "%d", + &start)) || (0 > start) ) { json_decref (response); @@ -190,7 +199,9 @@ MH_handler_history (struct TMH_RequestHandler *rh, if (NULL != str) { - if (1 != sscanf (str, "%u", &delta)) + if (1 != sscanf (str, + "%u", + &delta)) return TMH_RESPONSE_reply_arg_invalid (connection, TALER_EC_PARAMETER_MALFORMED, "delta"); @@ -202,23 +213,28 @@ MH_handler_history (struct TMH_RequestHandler *rh, delta); if (0 > start) - ret = db->find_contract_terms_by_date (db->cls, - date, - &mi->pubkey, - delta, - &pd_cb, - response); + qs = db->find_contract_terms_by_date (db->cls, + date, + &mi->pubkey, + delta, + &pd_cb, + response); else - ret = db->find_contract_terms_by_date_and_range (db->cls, - date, - &mi->pubkey, - (unsigned int) start, - delta, - GNUNET_NO, - &pd_cb, - response); - if (GNUNET_SYSERR == ret) + qs = db->find_contract_terms_by_date_and_range (db->cls, + date, + &mi->pubkey, + (unsigned int) start, + delta, + GNUNET_NO, + &pd_cb, + response); + if (0 > qs) { + /* single, read-only SQL statements should never cause + serialization problems */ + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); + /* Always report on hard error as well to enable diagnostics */ + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); json_decref (response); return TMH_RESPONSE_reply_internal_error (connection, TALER_EC_HISTORY_DB_FETCH_ERROR, |