ckdb - fix warnings from code break up
This commit is contained in:
parent
1f16e05f1d
commit
ea8ee0d376
163
src/ckdb.c
163
src/ckdb.c
@ -807,169 +807,6 @@ static void workerstatus_ready()
|
||||
}
|
||||
}
|
||||
|
||||
static bool workinfo_age(PGconn *conn, int64_t workinfoid, char *poolinstance,
|
||||
char *by, char *code, char *inet, tv_t *cd,
|
||||
tv_t *ss_first, tv_t *ss_last, int64_t *ss_count,
|
||||
int64_t *s_count, int64_t *s_diff)
|
||||
{
|
||||
K_ITEM *wi_item, ss_look, *ss_item, s_look, *s_item, *tmp_item;
|
||||
K_TREE_CTX ss_ctx[1], s_ctx[1], tmp_ctx[1];
|
||||
char cd_buf[DATE_BUFSIZ];
|
||||
int64_t ss_tot, ss_already, ss_failed, shares_tot, shares_dumped;
|
||||
SHARESUMMARY looksharesummary, *sharesummary;
|
||||
WORKINFO *workinfo;
|
||||
SHARES lookshares, *shares;
|
||||
bool ok = false, conned = false, skipupdate;
|
||||
char error[1024];
|
||||
|
||||
LOGDEBUG("%s(): age", __func__);
|
||||
|
||||
ss_first->tv_sec = ss_first->tv_usec =
|
||||
ss_last->tv_sec = ss_last->tv_usec = 0;
|
||||
*ss_count = *s_count = *s_diff = 0;
|
||||
|
||||
wi_item = find_workinfo(workinfoid);
|
||||
if (!wi_item) {
|
||||
tv_to_buf(cd, cd_buf, sizeof(cd_buf));
|
||||
LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s no workinfo! Age discarded!",
|
||||
__func__, workinfoid, poolinstance,
|
||||
cd->tv_sec, cd->tv_usec, cd_buf);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
DATA_WORKINFO(workinfo, wi_item);
|
||||
if (strcmp(poolinstance, workinfo->poolinstance) != 0) {
|
||||
tv_to_buf(cd, cd_buf, sizeof(cd_buf));
|
||||
LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s Poolinstance changed "
|
||||
"(from %s)! Age discarded!",
|
||||
__func__, workinfoid, poolinstance,
|
||||
cd->tv_sec, cd->tv_usec, cd_buf,
|
||||
workinfo->poolinstance);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
INIT_SHARESUMMARY(&ss_look);
|
||||
INIT_SHARES(&s_look);
|
||||
|
||||
// Find the first matching sharesummary
|
||||
looksharesummary.workinfoid = workinfoid;
|
||||
looksharesummary.userid = -1;
|
||||
looksharesummary.workername[0] = '\0';
|
||||
|
||||
ok = true;
|
||||
ss_tot = ss_already = ss_failed = shares_tot = shares_dumped = 0;
|
||||
ss_look.data = (void *)(&looksharesummary);
|
||||
K_RLOCK(sharesummary_free);
|
||||
ss_item = find_after_in_ktree(sharesummary_workinfoid_root, &ss_look, cmp_sharesummary_workinfoid, ss_ctx);
|
||||
K_RUNLOCK(sharesummary_free);
|
||||
DATA_SHARESUMMARY_NULL(sharesummary, ss_item);
|
||||
while (ss_item && sharesummary->workinfoid == workinfoid) {
|
||||
ss_tot++;
|
||||
error[0] = '\0';
|
||||
skipupdate = false;
|
||||
/* Reloading during a confirm will not have any old data
|
||||
* so finding an aged sharesummary here is an error */
|
||||
if (reloading) {
|
||||
if (sharesummary->complete[0] == SUMMARY_COMPLETE) {
|
||||
ss_already++;
|
||||
skipupdate = true;
|
||||
if (confirm_sharesummary) {
|
||||
LOGERR("%s(): Duplicate %s found during confirm %"PRId64"/%s/%"PRId64,
|
||||
__func__, __func__,
|
||||
sharesummary->userid,
|
||||
sharesummary->workername,
|
||||
sharesummary->workinfoid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipupdate) {
|
||||
if (conn == NULL && !confirm_sharesummary) {
|
||||
conn = dbconnect();
|
||||
conned = true;
|
||||
}
|
||||
|
||||
if (!sharesummary_update(conn, NULL, NULL, ss_item, by, code, inet, cd)) {
|
||||
ss_failed++;
|
||||
LOGERR("%s(): Failed to age share summary %"PRId64"/%s/%"PRId64,
|
||||
__func__, sharesummary->userid,
|
||||
sharesummary->workername,
|
||||
sharesummary->workinfoid);
|
||||
ok = false;
|
||||
} else {
|
||||
(*ss_count)++;
|
||||
*s_count += sharesummary->sharecount;
|
||||
*s_diff += sharesummary->diffacc;
|
||||
if (ss_first->tv_sec == 0 ||
|
||||
!tv_newer(ss_first, &(sharesummary->firstshare)))
|
||||
copy_tv(ss_first, &(sharesummary->firstshare));
|
||||
if (tv_newer(ss_last, &(sharesummary->lastshare)))
|
||||
copy_tv(ss_last, &(sharesummary->lastshare));
|
||||
}
|
||||
}
|
||||
|
||||
// Discard the shares either way
|
||||
lookshares.workinfoid = workinfoid;
|
||||
lookshares.userid = sharesummary->userid;
|
||||
strcpy(lookshares.workername, sharesummary->workername);
|
||||
lookshares.createdate.tv_sec = 0;
|
||||
lookshares.createdate.tv_usec = 0;
|
||||
|
||||
s_look.data = (void *)(&lookshares);
|
||||
K_WLOCK(shares_free);
|
||||
s_item = find_after_in_ktree(shares_root, &s_look, cmp_shares, s_ctx);
|
||||
while (s_item) {
|
||||
DATA_SHARES(shares, s_item);
|
||||
if (shares->workinfoid != workinfoid ||
|
||||
shares->userid != lookshares.userid ||
|
||||
strcmp(shares->workername, lookshares.workername) != 0)
|
||||
break;
|
||||
|
||||
shares_tot++;
|
||||
tmp_item = next_in_ktree(s_ctx);
|
||||
shares_root = remove_from_ktree(shares_root, s_item, cmp_shares, tmp_ctx);
|
||||
k_unlink_item(shares_store, s_item);
|
||||
if (reloading && skipupdate)
|
||||
shares_dumped++;
|
||||
if (reloading && skipupdate && !error[0]) {
|
||||
snprintf(error, sizeof(error),
|
||||
"reload found aged shares: %"PRId64"/%"PRId64"/%s",
|
||||
shares->workinfoid,
|
||||
shares->userid,
|
||||
shares->workername);
|
||||
}
|
||||
k_add_head(shares_free, s_item);
|
||||
s_item = tmp_item;
|
||||
}
|
||||
K_WUNLOCK(shares_free);
|
||||
K_RLOCK(sharesummary_free);
|
||||
ss_item = next_in_ktree(ss_ctx);
|
||||
K_RUNLOCK(sharesummary_free);
|
||||
DATA_SHARESUMMARY_NULL(sharesummary, ss_item);
|
||||
|
||||
if (error[0])
|
||||
LOGERR("%s(): %s", __func__, error);
|
||||
}
|
||||
|
||||
if (conned)
|
||||
PQfinish(conn);
|
||||
|
||||
if (ss_already || ss_failed || shares_dumped) {
|
||||
/* If all were already aged, and no shares
|
||||
* then we don't want a message */
|
||||
if (!(ss_already == ss_tot && shares_tot == 0)) {
|
||||
LOGERR("%s(): Summary aging of %"PRId64"/%s sstotal=%"PRId64
|
||||
" already=%"PRId64" failed=%"PRId64
|
||||
", sharestotal=%"PRId64" dumped=%"PRId64,
|
||||
__func__, workinfoid, poolinstance, ss_tot,
|
||||
ss_already, ss_failed, shares_tot,
|
||||
shares_dumped);
|
||||
}
|
||||
}
|
||||
bye:
|
||||
return ok;
|
||||
}
|
||||
|
||||
void auto_age_older(PGconn *conn, int64_t workinfoid, char *poolinstance,
|
||||
char *by, char *code, char *inet, tv_t *cd)
|
||||
{
|
||||
|
||||
13
src/ckdb.h
13
src/ckdb.h
@ -52,7 +52,7 @@
|
||||
|
||||
#define DB_VLOCK "1"
|
||||
#define DB_VERSION "0.9.2"
|
||||
#define CKDB_VERSION DB_VERSION"-0.400"
|
||||
#define CKDB_VERSION DB_VERSION"-0.401"
|
||||
|
||||
#define WHERE_FFL " - from %s %s() line %d"
|
||||
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
|
||||
@ -71,9 +71,6 @@
|
||||
#define TRUE_CHR 'Y'
|
||||
#define FALSE_CHR 'N'
|
||||
|
||||
#define coinbase1height(_cb1) _coinbase1height(_cb1, WHERE_FFL_HERE)
|
||||
#define cmp_height(_cb1a, _cb1b) _cmp_height(_cb1a, _cb1b, WHERE_FFL_HERE)
|
||||
|
||||
extern char *EMPTY;
|
||||
|
||||
extern const char *userpatt;
|
||||
@ -1266,9 +1263,16 @@ extern cmp_t cmp_payments(K_ITEM *a, K_ITEM *b);
|
||||
extern cmp_t cmp_optioncontrol(K_ITEM *a, K_ITEM *b);
|
||||
extern K_ITEM *find_optioncontrol(char *optionname, tv_t *now);
|
||||
extern cmp_t cmp_workinfo(K_ITEM *a, K_ITEM *b);
|
||||
#define coinbase1height(_cb1) _coinbase1height(_cb1, WHERE_FFL_HERE)
|
||||
extern int32_t _coinbase1height(char *coinbase1, WHERE_FFL_ARGS);
|
||||
#define cmp_height(_cb1a, _cb1b) _cmp_height(_cb1a, _cb1b, WHERE_FFL_HERE)
|
||||
extern cmp_t _cmp_height(char *coinbase1a, char *coinbase1b, WHERE_FFL_ARGS);
|
||||
extern cmp_t cmp_workinfo_height(K_ITEM *a, K_ITEM *b);
|
||||
extern K_ITEM *find_workinfo(int64_t workinfoid);
|
||||
extern bool workinfo_age(PGconn *conn, int64_t workinfoid, char *poolinstance,
|
||||
char *by, char *code, char *inet, tv_t *cd,
|
||||
tv_t *ss_first, tv_t *ss_last, int64_t *ss_count,
|
||||
int64_t *s_count, int64_t *s_diff);
|
||||
extern cmp_t cmp_shares(K_ITEM *a, K_ITEM *b);
|
||||
extern cmp_t cmp_shareerrors(K_ITEM *a, K_ITEM *b);
|
||||
extern void dsp_sharesummary(K_ITEM *item, FILE *stream);
|
||||
@ -1430,6 +1434,7 @@ extern bool userstats_add(char *poolinstance, char *elapsed, char *username,
|
||||
bool eos, char *by, char *code, char *inet, tv_t *cd,
|
||||
K_TREE *trf_root);
|
||||
extern bool userstats_fill(PGconn *conn);
|
||||
extern bool check_db_version(PGconn *conn);
|
||||
|
||||
// ***
|
||||
// *** ckdb_cmd.c
|
||||
|
||||
165
src/ckdb_data.c
165
src/ckdb_data.c
@ -992,7 +992,7 @@ cmp_t cmp_workinfo(K_ITEM *a, K_ITEM *b)
|
||||
return c;
|
||||
}
|
||||
|
||||
inline int32_t _coinbase1height(char *coinbase1, WHERE_FFL_ARGS)
|
||||
int32_t _coinbase1height(char *coinbase1, WHERE_FFL_ARGS)
|
||||
{
|
||||
int32_t height = 0;
|
||||
uchar *cb1;
|
||||
@ -1054,6 +1054,169 @@ K_ITEM *find_workinfo(int64_t workinfoid)
|
||||
return item;
|
||||
}
|
||||
|
||||
bool workinfo_age(PGconn *conn, int64_t workinfoid, char *poolinstance,
|
||||
char *by, char *code, char *inet, tv_t *cd,
|
||||
tv_t *ss_first, tv_t *ss_last, int64_t *ss_count,
|
||||
int64_t *s_count, int64_t *s_diff)
|
||||
{
|
||||
K_ITEM *wi_item, ss_look, *ss_item, s_look, *s_item, *tmp_item;
|
||||
K_TREE_CTX ss_ctx[1], s_ctx[1], tmp_ctx[1];
|
||||
char cd_buf[DATE_BUFSIZ];
|
||||
int64_t ss_tot, ss_already, ss_failed, shares_tot, shares_dumped;
|
||||
SHARESUMMARY looksharesummary, *sharesummary;
|
||||
WORKINFO *workinfo;
|
||||
SHARES lookshares, *shares;
|
||||
bool ok = false, conned = false, skipupdate;
|
||||
char error[1024];
|
||||
|
||||
LOGDEBUG("%s(): age", __func__);
|
||||
|
||||
ss_first->tv_sec = ss_first->tv_usec =
|
||||
ss_last->tv_sec = ss_last->tv_usec = 0;
|
||||
*ss_count = *s_count = *s_diff = 0;
|
||||
|
||||
wi_item = find_workinfo(workinfoid);
|
||||
if (!wi_item) {
|
||||
tv_to_buf(cd, cd_buf, sizeof(cd_buf));
|
||||
LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s no workinfo! Age discarded!",
|
||||
__func__, workinfoid, poolinstance,
|
||||
cd->tv_sec, cd->tv_usec, cd_buf);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
DATA_WORKINFO(workinfo, wi_item);
|
||||
if (strcmp(poolinstance, workinfo->poolinstance) != 0) {
|
||||
tv_to_buf(cd, cd_buf, sizeof(cd_buf));
|
||||
LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s Poolinstance changed "
|
||||
"(from %s)! Age discarded!",
|
||||
__func__, workinfoid, poolinstance,
|
||||
cd->tv_sec, cd->tv_usec, cd_buf,
|
||||
workinfo->poolinstance);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
INIT_SHARESUMMARY(&ss_look);
|
||||
INIT_SHARES(&s_look);
|
||||
|
||||
// Find the first matching sharesummary
|
||||
looksharesummary.workinfoid = workinfoid;
|
||||
looksharesummary.userid = -1;
|
||||
looksharesummary.workername[0] = '\0';
|
||||
|
||||
ok = true;
|
||||
ss_tot = ss_already = ss_failed = shares_tot = shares_dumped = 0;
|
||||
ss_look.data = (void *)(&looksharesummary);
|
||||
K_RLOCK(sharesummary_free);
|
||||
ss_item = find_after_in_ktree(sharesummary_workinfoid_root, &ss_look, cmp_sharesummary_workinfoid, ss_ctx);
|
||||
K_RUNLOCK(sharesummary_free);
|
||||
DATA_SHARESUMMARY_NULL(sharesummary, ss_item);
|
||||
while (ss_item && sharesummary->workinfoid == workinfoid) {
|
||||
ss_tot++;
|
||||
error[0] = '\0';
|
||||
skipupdate = false;
|
||||
/* Reloading during a confirm will not have any old data
|
||||
* so finding an aged sharesummary here is an error */
|
||||
if (reloading) {
|
||||
if (sharesummary->complete[0] == SUMMARY_COMPLETE) {
|
||||
ss_already++;
|
||||
skipupdate = true;
|
||||
if (confirm_sharesummary) {
|
||||
LOGERR("%s(): Duplicate %s found during confirm %"PRId64"/%s/%"PRId64,
|
||||
__func__, __func__,
|
||||
sharesummary->userid,
|
||||
sharesummary->workername,
|
||||
sharesummary->workinfoid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipupdate) {
|
||||
if (conn == NULL && !confirm_sharesummary) {
|
||||
conn = dbconnect();
|
||||
conned = true;
|
||||
}
|
||||
|
||||
if (!sharesummary_update(conn, NULL, NULL, ss_item, by, code, inet, cd)) {
|
||||
ss_failed++;
|
||||
LOGERR("%s(): Failed to age share summary %"PRId64"/%s/%"PRId64,
|
||||
__func__, sharesummary->userid,
|
||||
sharesummary->workername,
|
||||
sharesummary->workinfoid);
|
||||
ok = false;
|
||||
} else {
|
||||
(*ss_count)++;
|
||||
*s_count += sharesummary->sharecount;
|
||||
*s_diff += sharesummary->diffacc;
|
||||
if (ss_first->tv_sec == 0 ||
|
||||
!tv_newer(ss_first, &(sharesummary->firstshare)))
|
||||
copy_tv(ss_first, &(sharesummary->firstshare));
|
||||
if (tv_newer(ss_last, &(sharesummary->lastshare)))
|
||||
copy_tv(ss_last, &(sharesummary->lastshare));
|
||||
}
|
||||
}
|
||||
|
||||
// Discard the shares either way
|
||||
lookshares.workinfoid = workinfoid;
|
||||
lookshares.userid = sharesummary->userid;
|
||||
strcpy(lookshares.workername, sharesummary->workername);
|
||||
lookshares.createdate.tv_sec = 0;
|
||||
lookshares.createdate.tv_usec = 0;
|
||||
|
||||
s_look.data = (void *)(&lookshares);
|
||||
K_WLOCK(shares_free);
|
||||
s_item = find_after_in_ktree(shares_root, &s_look, cmp_shares, s_ctx);
|
||||
while (s_item) {
|
||||
DATA_SHARES(shares, s_item);
|
||||
if (shares->workinfoid != workinfoid ||
|
||||
shares->userid != lookshares.userid ||
|
||||
strcmp(shares->workername, lookshares.workername) != 0)
|
||||
break;
|
||||
|
||||
shares_tot++;
|
||||
tmp_item = next_in_ktree(s_ctx);
|
||||
shares_root = remove_from_ktree(shares_root, s_item, cmp_shares, tmp_ctx);
|
||||
k_unlink_item(shares_store, s_item);
|
||||
if (reloading && skipupdate)
|
||||
shares_dumped++;
|
||||
if (reloading && skipupdate && !error[0]) {
|
||||
snprintf(error, sizeof(error),
|
||||
"reload found aged shares: %"PRId64"/%"PRId64"/%s",
|
||||
shares->workinfoid,
|
||||
shares->userid,
|
||||
shares->workername);
|
||||
}
|
||||
k_add_head(shares_free, s_item);
|
||||
s_item = tmp_item;
|
||||
}
|
||||
K_WUNLOCK(shares_free);
|
||||
K_RLOCK(sharesummary_free);
|
||||
ss_item = next_in_ktree(ss_ctx);
|
||||
K_RUNLOCK(sharesummary_free);
|
||||
DATA_SHARESUMMARY_NULL(sharesummary, ss_item);
|
||||
|
||||
if (error[0])
|
||||
LOGERR("%s(): %s", __func__, error);
|
||||
}
|
||||
|
||||
if (conned)
|
||||
PQfinish(conn);
|
||||
|
||||
if (ss_already || ss_failed || shares_dumped) {
|
||||
/* If all were already aged, and no shares
|
||||
* then we don't want a message */
|
||||
if (!(ss_already == ss_tot && shares_tot == 0)) {
|
||||
LOGERR("%s(): Summary aging of %"PRId64"/%s sstotal=%"PRId64
|
||||
" already=%"PRId64" failed=%"PRId64
|
||||
", sharestotal=%"PRId64" dumped=%"PRId64,
|
||||
__func__, workinfoid, poolinstance, ss_tot,
|
||||
ss_already, ss_failed, shares_tot,
|
||||
shares_dumped);
|
||||
}
|
||||
}
|
||||
bye:
|
||||
return ok;
|
||||
}
|
||||
|
||||
// order by workinfoid asc,userid asc,workername asc,createdate asc,nonce asc,expirydate desc
|
||||
cmp_t cmp_shares(K_ITEM *a, K_ITEM *b)
|
||||
{
|
||||
|
||||
166
src/ckdb_dbio.c
166
src/ckdb_dbio.c
@ -1819,7 +1819,8 @@ bool payments_fill(PGconn *conn)
|
||||
}
|
||||
|
||||
bool idcontrol_add(PGconn *conn, char *idname, char *idvalue, char *by,
|
||||
char *code, char *inet, tv_t *cd, K_TREE *trf_root)
|
||||
char *code, char *inet, tv_t *cd,
|
||||
__maybe_unused K_TREE *trf_root)
|
||||
{
|
||||
K_ITEM *look;
|
||||
IDCONTROL *row;
|
||||
@ -2287,169 +2288,6 @@ unparam:
|
||||
return workinfoid;
|
||||
}
|
||||
|
||||
bool workinfo_age(PGconn *conn, int64_t workinfoid, char *poolinstance,
|
||||
char *by, char *code, char *inet, tv_t *cd,
|
||||
tv_t *ss_first, tv_t *ss_last, int64_t *ss_count,
|
||||
int64_t *s_count, int64_t *s_diff)
|
||||
{
|
||||
K_ITEM *wi_item, ss_look, *ss_item, s_look, *s_item, *tmp_item;
|
||||
K_TREE_CTX ss_ctx[1], s_ctx[1], tmp_ctx[1];
|
||||
char cd_buf[DATE_BUFSIZ];
|
||||
int64_t ss_tot, ss_already, ss_failed, shares_tot, shares_dumped;
|
||||
SHARESUMMARY looksharesummary, *sharesummary;
|
||||
WORKINFO *workinfo;
|
||||
SHARES lookshares, *shares;
|
||||
bool ok = false, conned = false, skipupdate;
|
||||
char error[1024];
|
||||
|
||||
LOGDEBUG("%s(): age", __func__);
|
||||
|
||||
ss_first->tv_sec = ss_first->tv_usec =
|
||||
ss_last->tv_sec = ss_last->tv_usec = 0;
|
||||
*ss_count = *s_count = *s_diff = 0;
|
||||
|
||||
wi_item = find_workinfo(workinfoid);
|
||||
if (!wi_item) {
|
||||
tv_to_buf(cd, cd_buf, sizeof(cd_buf));
|
||||
LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s no workinfo! Age discarded!",
|
||||
__func__, workinfoid, poolinstance,
|
||||
cd->tv_sec, cd->tv_usec, cd_buf);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
DATA_WORKINFO(workinfo, wi_item);
|
||||
if (strcmp(poolinstance, workinfo->poolinstance) != 0) {
|
||||
tv_to_buf(cd, cd_buf, sizeof(cd_buf));
|
||||
LOGERR("%s() %"PRId64"/%s/%ld,%ld %.19s Poolinstance changed "
|
||||
"(from %s)! Age discarded!",
|
||||
__func__, workinfoid, poolinstance,
|
||||
cd->tv_sec, cd->tv_usec, cd_buf,
|
||||
workinfo->poolinstance);
|
||||
goto bye;
|
||||
}
|
||||
|
||||
INIT_SHARESUMMARY(&ss_look);
|
||||
INIT_SHARES(&s_look);
|
||||
|
||||
// Find the first matching sharesummary
|
||||
looksharesummary.workinfoid = workinfoid;
|
||||
looksharesummary.userid = -1;
|
||||
looksharesummary.workername[0] = '\0';
|
||||
|
||||
ok = true;
|
||||
ss_tot = ss_already = ss_failed = shares_tot = shares_dumped = 0;
|
||||
ss_look.data = (void *)(&looksharesummary);
|
||||
K_RLOCK(sharesummary_free);
|
||||
ss_item = find_after_in_ktree(sharesummary_workinfoid_root, &ss_look, cmp_sharesummary_workinfoid, ss_ctx);
|
||||
K_RUNLOCK(sharesummary_free);
|
||||
DATA_SHARESUMMARY_NULL(sharesummary, ss_item);
|
||||
while (ss_item && sharesummary->workinfoid == workinfoid) {
|
||||
ss_tot++;
|
||||
error[0] = '\0';
|
||||
skipupdate = false;
|
||||
/* Reloading during a confirm will not have any old data
|
||||
* so finding an aged sharesummary here is an error */
|
||||
if (reloading) {
|
||||
if (sharesummary->complete[0] == SUMMARY_COMPLETE) {
|
||||
ss_already++;
|
||||
skipupdate = true;
|
||||
if (confirm_sharesummary) {
|
||||
LOGERR("%s(): Duplicate %s found during confirm %"PRId64"/%s/%"PRId64,
|
||||
__func__, __func__,
|
||||
sharesummary->userid,
|
||||
sharesummary->workername,
|
||||
sharesummary->workinfoid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipupdate) {
|
||||
if (conn == NULL && !confirm_sharesummary) {
|
||||
conn = dbconnect();
|
||||
conned = true;
|
||||
}
|
||||
|
||||
if (!sharesummary_update(conn, NULL, NULL, ss_item, by, code, inet, cd)) {
|
||||
ss_failed++;
|
||||
LOGERR("%s(): Failed to age share summary %"PRId64"/%s/%"PRId64,
|
||||
__func__, sharesummary->userid,
|
||||
sharesummary->workername,
|
||||
sharesummary->workinfoid);
|
||||
ok = false;
|
||||
} else {
|
||||
(*ss_count)++;
|
||||
*s_count += sharesummary->sharecount;
|
||||
*s_diff += sharesummary->diffacc;
|
||||
if (ss_first->tv_sec == 0 ||
|
||||
!tv_newer(ss_first, &(sharesummary->firstshare)))
|
||||
copy_tv(ss_first, &(sharesummary->firstshare));
|
||||
if (tv_newer(ss_last, &(sharesummary->lastshare)))
|
||||
copy_tv(ss_last, &(sharesummary->lastshare));
|
||||
}
|
||||
}
|
||||
|
||||
// Discard the shares either way
|
||||
lookshares.workinfoid = workinfoid;
|
||||
lookshares.userid = sharesummary->userid;
|
||||
strcpy(lookshares.workername, sharesummary->workername);
|
||||
lookshares.createdate.tv_sec = 0;
|
||||
lookshares.createdate.tv_usec = 0;
|
||||
|
||||
s_look.data = (void *)(&lookshares);
|
||||
K_WLOCK(shares_free);
|
||||
s_item = find_after_in_ktree(shares_root, &s_look, cmp_shares, s_ctx);
|
||||
while (s_item) {
|
||||
DATA_SHARES(shares, s_item);
|
||||
if (shares->workinfoid != workinfoid ||
|
||||
shares->userid != lookshares.userid ||
|
||||
strcmp(shares->workername, lookshares.workername) != 0)
|
||||
break;
|
||||
|
||||
shares_tot++;
|
||||
tmp_item = next_in_ktree(s_ctx);
|
||||
shares_root = remove_from_ktree(shares_root, s_item, cmp_shares, tmp_ctx);
|
||||
k_unlink_item(shares_store, s_item);
|
||||
if (reloading && skipupdate)
|
||||
shares_dumped++;
|
||||
if (reloading && skipupdate && !error[0]) {
|
||||
snprintf(error, sizeof(error),
|
||||
"reload found aged shares: %"PRId64"/%"PRId64"/%s",
|
||||
shares->workinfoid,
|
||||
shares->userid,
|
||||
shares->workername);
|
||||
}
|
||||
k_add_head(shares_free, s_item);
|
||||
s_item = tmp_item;
|
||||
}
|
||||
K_WUNLOCK(shares_free);
|
||||
K_RLOCK(sharesummary_free);
|
||||
ss_item = next_in_ktree(ss_ctx);
|
||||
K_RUNLOCK(sharesummary_free);
|
||||
DATA_SHARESUMMARY_NULL(sharesummary, ss_item);
|
||||
|
||||
if (error[0])
|
||||
LOGERR("%s(): %s", __func__, error);
|
||||
}
|
||||
|
||||
if (conned)
|
||||
PQfinish(conn);
|
||||
|
||||
if (ss_already || ss_failed || shares_dumped) {
|
||||
/* If all were already aged, and no shares
|
||||
* then we don't want a message */
|
||||
if (!(ss_already == ss_tot && shares_tot == 0)) {
|
||||
LOGERR("%s(): Summary aging of %"PRId64"/%s sstotal=%"PRId64
|
||||
" already=%"PRId64" failed=%"PRId64
|
||||
", sharestotal=%"PRId64" dumped=%"PRId64,
|
||||
__func__, workinfoid, poolinstance, ss_tot,
|
||||
ss_already, ss_failed, shares_tot,
|
||||
shares_dumped);
|
||||
}
|
||||
}
|
||||
bye:
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool workinfo_fill(PGconn *conn)
|
||||
{
|
||||
ExecStatusType rescode;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user