diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-11-22 22:34:26 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-11-22 22:34:26 +0100 |
commit | e53e06bc753e444b7365cf97bcbe006a52d850b9 (patch) | |
tree | 26a0ef169a866558a775848582f3373d2e089422 /src/bank-lib | |
parent | a7f7875619a067c1faf5282eec1ca8b16e1d612e (diff) | |
download | exchange-e53e06bc753e444b7365cf97bcbe006a52d850b9.tar.xz |
avoid race on serial_counter by deferring access to serial_counter after the parsing function is done and we have the lock
Diffstat (limited to 'src/bank-lib')
-rw-r--r-- | src/bank-lib/fakebank_common_parser.c | 2 | ||||
-rw-r--r-- | src/bank-lib/fakebank_tbr_get_history.c | 2 | ||||
-rw-r--r-- | src/bank-lib/fakebank_twg_history.c | 4 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/bank-lib/fakebank_common_parser.c b/src/bank-lib/fakebank_common_parser.c index 98b8d6097..cf2dc5a74 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 7e7f9dda2..e81e00894 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 e2c32a9eb..1d70ed127 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); |