gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] 01/01: -fix 200 vs. 204 in fakebank


From: gnunet
Subject: [taler-exchange] 01/01: -fix 200 vs. 204 in fakebank
Date: Mon, 19 Dec 2022 14:41:36 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

commit c4cc1ea13dccd7498b67f311d01c7c8b27838c5d
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Dec 19 14:37:20 2022 +0100

    -fix 200 vs. 204 in fakebank
---
 src/bank-lib/fakebank.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 81029041..c067889a 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -2257,23 +2257,20 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
     if ( (NULL == t) ||
          overflow)
     {
-      GNUNET_free (debit_payto);
       if (GNUNET_TIME_relative_is_zero (ha.lp_timeout) &&
           (0 < ha.delta))
       {
         GNUNET_assert (0 ==
                        pthread_mutex_unlock (&h->big_lock));
         if (overflow)
+        {
+          GNUNET_free (debit_payto);
           return TALER_MHD_reply_with_ec (
             connection,
             TALER_EC_BANK_ANCIENT_TRANSACTION_GONE,
             NULL);
-        return TALER_MHD_REPLY_JSON_PACK (
-          connection,
-          MHD_HTTP_OK,
-          GNUNET_JSON_pack_array_steal (
-            "outgoing_transactions",
-            history));
+        }
+        goto finish;
       }
       *con_cls = &special_ptr;
       start_lp (h,
@@ -2285,6 +2282,7 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
       GNUNET_assert (0 ==
                      pthread_mutex_unlock (&h->big_lock));
       json_decref (history);
+      GNUNET_free (debit_payto);
       return MHD_YES;
     }
     if (t->debit_account != acc)
@@ -2397,6 +2395,16 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
   }
   GNUNET_assert (0 ==
                  pthread_mutex_unlock (&h->big_lock));
+finish:
+  if (0 == json_array_size (history))
+  {
+    json_decref (history);
+    return TALER_MHD_reply_static (connection,
+                                   MHD_HTTP_NO_CONTENT,
+                                   NULL,
+                                   NULL,
+                                   0);
+  }
   GNUNET_free (debit_payto);
   return TALER_MHD_REPLY_JSON_PACK (connection,
                                     MHD_HTTP_OK,
@@ -2500,11 +2508,7 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
             connection,
             TALER_EC_BANK_ANCIENT_TRANSACTION_GONE,
             NULL);
-        return TALER_MHD_REPLY_JSON_PACK (connection,
-                                          MHD_HTTP_OK,
-                                          GNUNET_JSON_pack_array_steal (
-                                            "incoming_transactions",
-                                            history));
+        goto finish;
       }
       *con_cls = &special_ptr;
       start_lp (h,
@@ -2608,6 +2612,16 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
   }
   GNUNET_assert (0 ==
                  pthread_mutex_unlock (&h->big_lock));
+finish:
+  if (0 == json_array_size (history))
+  {
+    json_decref (history);
+    return TALER_MHD_reply_static (connection,
+                                   MHD_HTTP_NO_CONTENT,
+                                   NULL,
+                                   NULL,
+                                   0);
+  }
   return TALER_MHD_REPLY_JSON_PACK (connection,
                                     MHD_HTTP_OK,
                                     GNUNET_JSON_pack_array_steal (

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]