gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] 02/02: avoid race on serial_counter by deferring access


From: gnunet
Subject: [taler-exchange] 02/02: avoid race on serial_counter by deferring access to serial_counter after the parsing function is done and we have the lock
Date: Wed, 22 Nov 2023 23:34:31 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

commit e53e06bc753e444b7365cf97bcbe006a52d850b9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Nov 22 22:34:26 2023 +0100

    avoid race on serial_counter by deferring access to serial_counter after 
the parsing function is done and we have the lock
---
 src/bank-lib/fakebank_common_parser.c   | 2 +-
 src/bank-lib/fakebank_tbr_get_history.c | 2 ++
 src/bank-lib/fakebank_twg_history.c     | 4 ++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/bank-lib/fakebank_common_parser.c 
b/src/bank-lib/fakebank_common_parser.c
index 98b8d609..cf2dc5a7 100644
--- a/src/bank-lib/fakebank_common_parser.c
+++ b/src/bank-lib/fakebank_common_parser.c
@@ -112,7 +112,7 @@ TALER_FAKEBANK_common_parse_history_args (
            : GNUNET_SYSERR;
   }
   if (NULL == start)
-    ha->start_idx = (d > 0) ? 0 : h->serial_counter;
+    ha->start_idx = (d > 0) ? 0 : UINT64_MAX;
   else
     ha->start_idx = (uint64_t) sval;
   ha->delta = (int64_t) d;
diff --git a/src/bank-lib/fakebank_tbr_get_history.c 
b/src/bank-lib/fakebank_tbr_get_history.c
index 7e7f9dda..e81e0089 100644
--- a/src/bank-lib/fakebank_tbr_get_history.c
+++ b/src/bank-lib/fakebank_tbr_get_history.c
@@ -84,6 +84,8 @@ TALER_FAKEBANK_tbr_get_history_incoming (
     }
     GNUNET_assert (0 ==
                    pthread_mutex_lock (&h->big_lock));
+    if (UINT64_MAX == hc->ha.start_idx)
+      hc->ha.start_idx = h->serial_counter;
     hc->acc = TALER_FAKEBANK_lookup_account_ (h,
                                               account,
                                               NULL);
diff --git a/src/bank-lib/fakebank_twg_history.c 
b/src/bank-lib/fakebank_twg_history.c
index e2c32a9e..1d70ed12 100644
--- a/src/bank-lib/fakebank_twg_history.c
+++ b/src/bank-lib/fakebank_twg_history.c
@@ -82,6 +82,8 @@ TALER_FAKEBANK_twg_get_debit_history_ (
     }
     GNUNET_assert (0 ==
                    pthread_mutex_lock (&h->big_lock));
+    if (UINT64_MAX == hc->ha.start_idx)
+      hc->ha.start_idx = h->serial_counter;
     hc->acc = TALER_FAKEBANK_lookup_account_ (h,
                                               account,
                                               NULL);
@@ -333,6 +335,8 @@ TALER_FAKEBANK_twg_get_credit_history_ (
     }
     GNUNET_assert (0 ==
                    pthread_mutex_lock (&h->big_lock));
+    if (UINT64_MAX == hc->ha.start_idx)
+      hc->ha.start_idx = h->serial_counter;
     hc->acc = TALER_FAKEBANK_lookup_account_ (h,
                                               account,
                                               NULL);

-- 
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]