From acdd8203a0589a03da842c65fbe89d4a83d44887 Mon Sep 17 00:00:00 2001 From: kanoi Date: Tue, 12 May 2015 09:38:57 +1000 Subject: [PATCH] ckdb - ensure (unlikely) summarisation can never affect payout generation --- src/ckdb.h | 2 +- src/ckdb_data.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index 9395b2b3..6a3bc10f 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.0" -#define CKDB_VERSION DB_VERSION"-1.100" +#define CKDB_VERSION DB_VERSION"-1.101" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_data.c b/src/ckdb_data.c index e4e620cb..6b097d6c 100644 --- a/src/ckdb_data.c +++ b/src/ckdb_data.c @@ -3875,6 +3875,7 @@ bool make_markersummaries(bool msg, char *by, char *code, char *inet, WORKMARKERS *workmarkers; K_ITEM *wm_item, *wm_last = NULL; tv_t now; + bool ok; K_RLOCK(workmarkers_free); wm_item = last_in_ktree(workmarkers_workinfoid_root, ctx); @@ -3916,8 +3917,15 @@ bool make_markersummaries(bool msg, char *by, char *code, char *inet, else setnow(&now); - return sharesummaries_to_markersummaries(NULL, workmarkers, by, code, - inet, &now, trf_root); + /* So we can't change any sharesummaries/markersummaries while a + * payout is being generated + * N.B. this is a long lock since it stores the markersummaries */ + ck_wlock(&process_pplns_lock); + ok = sharesummaries_to_markersummaries(NULL, workmarkers, by, code, + inet, &now, trf_root); + ck_wunlock(&process_pplns_lock); + + return ok; } void dsp_workmarkers(K_ITEM *item, FILE *stream)