commit e53e06bc753e444b7365cf97bcbe006a52d850b9
parent a7f7875619a067c1faf5282eec1ca8b16e1d612e
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 22 Nov 2023 22:34:26 +0100
avoid race on serial_counter by deferring access to serial_counter after the parsing function is done and we have the lock
Diffstat:
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
@@ -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
@@ -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
@@ -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);