diff --git a/src/ckdb.h b/src/ckdb.h index 85930c7b..6eadecff 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.2" -#define CKDB_VERSION DB_VERSION"-1.310" +#define CKDB_VERSION DB_VERSION"-1.311" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -2211,6 +2211,7 @@ extern K_ITEM *_find_create_workerstatus(int64_t userid, char *workername, bool create, const char *file2, const char *func2, const int line2, WHERE_FFL_ARGS); +extern void zero_all_active(tv_t *when); extern void workerstatus_ready(); #define workerstatus_update(_auths, _shares, _userstats) \ _workerstatus_update(_auths, _shares, _userstats, WHERE_FFL_HERE) diff --git a/src/ckdb_data.c b/src/ckdb_data.c index 34f29848..3393b99f 100644 --- a/src/ckdb_data.c +++ b/src/ckdb_data.c @@ -913,6 +913,23 @@ static void zero_on_idle(tv_t *when, WORKERSTATUS *workerstatus) workerstatus->active_sharehi = workerstatus->active_sharerej = 0.0; } +void zero_all_active(tv_t *when) +{ + WORKERSTATUS *workerstatus; + K_TREE_CTX ws_ctx[1]; + K_ITEM *ws_item; + + K_WLOCK(workerstatus_free); + ws_item = first_in_ktree(workerstatus_root, ws_ctx); + while (ws_item) { + DATA_WORKERSTATUS(workerstatus, ws_item); + zero_on_idle(when, workerstatus); + ws_item = next_in_ktree(ws_ctx); + } + + K_WUNLOCK(workerstatus_free); +} + /* All data is loaded, now update workerstatus fields TODO: combine set_block_share_counters() with this? */ void workerstatus_ready() diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index db2ed64f..d4a91555 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -2623,6 +2623,7 @@ int64_t workinfo_add(PGconn *conn, char *workinfoidstr, char *poolinstance, char *ins; char *params[11 + HISTORYDATECOUNT]; int n, par = 0; + bool zero_active = false; LOGDEBUG("%s(): add", __func__); @@ -2730,14 +2731,19 @@ unparam: if (workinfo_current) { WORKINFO *wic; DATA_WORKINFO(wic, workinfo_current); - if (cmp_height(wic->coinbase1, row->coinbase1) != 0) + if (cmp_height(wic->coinbase1, row->coinbase1) != 0) { copy_tv(&last_bc, cd); + zero_active = true; + } } workinfo_current = item; } K_WUNLOCK(workinfo_free); + if (zero_active) + zero_all_active(cd); + return workinfoid; }