From b92034e1a934e545f0d9967cf1ebba85f88fa51f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 7 Mar 2024 10:53:29 +0100 Subject: remove unnecessary operations from global lock scope --- src/bank-lib/fakebank_tbr_get_history.c | 17 +++++++---------- src/bank-lib/fakebank_twg_history.c | 17 +++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/bank-lib/fakebank_tbr_get_history.c b/src/bank-lib/fakebank_tbr_get_history.c index e318a2af9..a6cfaad8d 100644 --- a/src/bank-lib/fakebank_tbr_get_history.c +++ b/src/bank-lib/fakebank_tbr_get_history.c @@ -70,7 +70,12 @@ TALER_FAKEBANK_tbr_get_history ( *con_cls = cc; hc = GNUNET_new (struct HistoryContext); cc->ctx = hc; - + hc->history = json_array (); + if (NULL == hc->history) + { + GNUNET_break (0); + return MHD_NO; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Handling /accounts/%s/taler-revenue/history request\n", account); @@ -82,6 +87,7 @@ TALER_FAKEBANK_tbr_get_history ( GNUNET_break_op (0); return (GNUNET_SYSERR == ret) ? MHD_NO : MHD_YES; } + hc->timeout = GNUNET_TIME_relative_to_absolute (hc->ha.lp_timeout); GNUNET_assert (0 == pthread_mutex_lock (&h->big_lock)); if (UINT64_MAX == hc->ha.start_idx) @@ -101,15 +107,6 @@ TALER_FAKEBANK_tbr_get_history ( TALER_EC_BANK_UNKNOWN_ACCOUNT, account); } - hc->history = json_array (); - if (NULL == hc->history) - { - GNUNET_break (0); - GNUNET_assert (0 == - pthread_mutex_unlock (&h->big_lock)); - return MHD_NO; - } - hc->timeout = GNUNET_TIME_relative_to_absolute (hc->ha.lp_timeout); } else { diff --git a/src/bank-lib/fakebank_twg_history.c b/src/bank-lib/fakebank_twg_history.c index c10358c1a..6d3c376e5 100644 --- a/src/bank-lib/fakebank_twg_history.c +++ b/src/bank-lib/fakebank_twg_history.c @@ -325,7 +325,12 @@ TALER_FAKEBANK_twg_get_credit_history_ ( *con_cls = cc; hc = GNUNET_new (struct HistoryContext); cc->ctx = hc; - + hc->history = json_array (); + if (NULL == hc->history) + { + GNUNET_break (0); + return MHD_NO; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Handling /history/incoming connection %p\n", connection); @@ -337,6 +342,7 @@ TALER_FAKEBANK_twg_get_credit_history_ ( GNUNET_break_op (0); return (GNUNET_SYSERR == ret) ? MHD_NO : MHD_YES; } + hc->timeout = GNUNET_TIME_relative_to_absolute (hc->ha.lp_timeout); GNUNET_assert (0 == pthread_mutex_lock (&h->big_lock)); if (UINT64_MAX == hc->ha.start_idx) @@ -353,15 +359,6 @@ TALER_FAKEBANK_twg_get_credit_history_ ( TALER_EC_BANK_UNKNOWN_ACCOUNT, account); } - hc->history = json_array (); - if (NULL == hc->history) - { - GNUNET_break (0); - GNUNET_assert (0 == - pthread_mutex_unlock (&h->big_lock)); - return MHD_NO; - } - hc->timeout = GNUNET_TIME_relative_to_absolute (hc->ha.lp_timeout); } else { -- cgit v1.2.3