From e6510bba846fefe2c3cbd9b8379f77d94532aa30 Mon Sep 17 00:00:00 2001 From: kanoi Date: Mon, 22 Aug 2016 17:34:00 +1000 Subject: [PATCH] ckdb - discard shares as soon as they've been summarised --- src/ckdb.h | 2 +- src/ckdb_data.c | 6 ++++++ src/ckdb_dbio.c | 15 ++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/ckdb.h b/src/ckdb.h index 383e5d4c..557903ad 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -58,7 +58,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.415" +#define CKDB_VERSION DB_VERSION"-2.416" #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 52c2fad8..84cb34f2 100644 --- a/src/ckdb_data.c +++ b/src/ckdb_data.c @@ -2153,6 +2153,11 @@ K_ITEM *next_workinfo(int64_t workinfoid, K_TREE_CTX *ctx) } #define DISCARD_ALL -1 +/* No longer required since we already discard the shares after being added + * to the sharesummary */ +#if 1 +#define discard_shares(...) +#else // userid = DISCARD_ALL will dump all shares for the given workinfoid static void discard_shares(int64_t *shares_tot, int64_t *shares_dumped, int64_t *diff_tot, bool skipupdate, @@ -2238,6 +2243,7 @@ static void discard_shares(int64_t *shares_tot, int64_t *shares_dumped, } } +#endif // Duplicates during a reload are set to not show messages bool workinfo_age(int64_t workinfoid, char *poolinstance, tv_t *cd, diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index f45c8aab..00eca084 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -3714,8 +3714,8 @@ keep: early_shares->oldcount, early_shares->redo); FREENULL(st); K_WLOCK(shares_free); - add_to_ktree(shares_root, es_item); - k_add_head(shares_store, es_item); + // Discard it, it's been processed + k_add_head(shares_free, es_item); K_WUNLOCK(shares_free); return; discard: @@ -3752,6 +3752,7 @@ bool shares_add(PGconn *conn, char *workinfoid, char *username, char *workername USERS *users; bool ok = false, dup = false; char *st = NULL; + tv_t share_cd; LOGDEBUG("%s(): %s/%s/%s/%s/%ld,%ld", __func__, @@ -3876,9 +3877,10 @@ bool shares_add(PGconn *conn, char *workinfoid, char *username, char *workername ok = shares_process(conn, shares, wi_item, trf_root); if (ok) { + copy_tv(&share_cd, &(shares->createdate)); K_WLOCK(shares_free); - add_to_ktree(shares_root, s_item); - k_add_head(shares_store, s_item); + // Discard it, it's been processed + k_add_head(shares_free, s_item); if (s2_item) { // Discard duplicates tmp_item = find_in_ktree(shares_db_root, s2_item, ctx); @@ -3905,11 +3907,10 @@ bool shares_add(PGconn *conn, char *workinfoid, char *username, char *workername FREENULL(st); } - shares_process_early(conn, wi_item, &(shares->createdate), - trf_root); + shares_process_early(conn, wi_item, &share_cd, trf_root); // Call both since shareerrors may be rare shareerrors_process_early(conn, shares->workinfoid, - &(shares->createdate), trf_root); + &share_cd, trf_root); // The original share was ok return true;