|
|
@ -3636,7 +3636,7 @@ static void shares_process_early(PGconn *conn, K_ITEM *wi, tv_t *good_cd, |
|
|
|
char *st = NULL; |
|
|
|
char *st = NULL; |
|
|
|
char tmp[1024]; |
|
|
|
char tmp[1024]; |
|
|
|
double delta; |
|
|
|
double delta; |
|
|
|
bool ok; |
|
|
|
bool ok, failed; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s() add", __func__); |
|
|
|
LOGDEBUG("%s() add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -3645,7 +3645,7 @@ static void shares_process_early(PGconn *conn, K_ITEM *wi, tv_t *good_cd, |
|
|
|
if (shares_early_store->count == 0) { |
|
|
|
if (shares_early_store->count == 0) { |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
// None
|
|
|
|
// None
|
|
|
|
return; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
es_item = last_in_ktree(shares_early_root, ctx); |
|
|
|
es_item = last_in_ktree(shares_early_root, ctx); |
|
|
|
if (es_item) { |
|
|
|
if (es_item) { |
|
|
@ -3696,18 +3696,20 @@ static void shares_process_early(PGconn *conn, K_ITEM *wi, tv_t *good_cd, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
redo: |
|
|
|
redo: |
|
|
|
K_WLOCK(shares_free); |
|
|
|
K_WLOCK(shares_free); |
|
|
|
add_to_ktree(shares_early_root, es_item); |
|
|
|
add_to_ktree(shares_early_root, es_item); |
|
|
|
k_add_tail(shares_early_store, es_item); |
|
|
|
k_add_tail(shares_early_store, es_item); |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
keep: |
|
|
|
keep: |
|
|
|
|
|
|
|
failed = esm_flag(early_shares->workinfoid, false, true); |
|
|
|
btv_to_buf(&(early_shares->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
btv_to_buf(&(early_shares->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
LOGERR("%s() %"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
LOGNOTICE("%s() %s%"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
" Early share procured", |
|
|
|
" Early share procured", |
|
|
|
__func__, early_shares->workinfoid, |
|
|
|
__func__, failed ? "***ESM " : EMPTY, |
|
|
|
|
|
|
|
early_shares->workinfoid, |
|
|
|
st = safe_text_nonull(early_shares->workername), |
|
|
|
st = safe_text_nonull(early_shares->workername), |
|
|
|
early_shares->createdate.tv_sec, |
|
|
|
early_shares->createdate.tv_sec, |
|
|
|
early_shares->createdate.tv_usec, cd_buf, |
|
|
|
early_shares->createdate.tv_usec, cd_buf, |
|
|
@ -3717,12 +3719,14 @@ keep: |
|
|
|
// Discard it, it's been processed
|
|
|
|
// Discard it, it's been processed
|
|
|
|
k_add_head(shares_free, es_item); |
|
|
|
k_add_head(shares_free, es_item); |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
discard: |
|
|
|
discard: |
|
|
|
|
|
|
|
failed = esm_flag(early_shares->workinfoid, false, false); |
|
|
|
btv_to_buf(&(early_shares->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
btv_to_buf(&(early_shares->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
LOGERR("%s() %"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
LOGNOTICE("%s() %s%"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
" Early share discarded!%s", |
|
|
|
" Early share discarded!%s", |
|
|
|
__func__, early_shares->workinfoid, |
|
|
|
__func__, failed ? "***ESM " : EMPTY, |
|
|
|
|
|
|
|
early_shares->workinfoid, |
|
|
|
st = safe_text_nonull(early_shares->workername), |
|
|
|
st = safe_text_nonull(early_shares->workername), |
|
|
|
early_shares->createdate.tv_sec, |
|
|
|
early_shares->createdate.tv_sec, |
|
|
|
early_shares->createdate.tv_usec, cd_buf, |
|
|
|
early_shares->createdate.tv_usec, cd_buf, |
|
|
@ -3731,7 +3735,10 @@ discard: |
|
|
|
K_WLOCK(shares_free); |
|
|
|
K_WLOCK(shares_free); |
|
|
|
k_add_head(shares_free, es_item); |
|
|
|
k_add_head(shares_free, es_item); |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
K_WUNLOCK(shares_free); |
|
|
|
return; |
|
|
|
out: |
|
|
|
|
|
|
|
// accessed outside lock, but esm_check() uses the lock
|
|
|
|
|
|
|
|
if (esm_store->count) |
|
|
|
|
|
|
|
esm_check(good_cd); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void shareerrors_process_early(PGconn *conn, int64_t good_wid, |
|
|
|
static void shareerrors_process_early(PGconn *conn, int64_t good_wid, |
|
|
@ -3750,7 +3757,7 @@ bool shares_add(PGconn *conn, char *workinfoid, char *username, char *workername |
|
|
|
SHARES *shares = NULL, *shares2 = NULL; |
|
|
|
SHARES *shares = NULL, *shares2 = NULL; |
|
|
|
double sdiff_amt; |
|
|
|
double sdiff_amt; |
|
|
|
USERS *users; |
|
|
|
USERS *users; |
|
|
|
bool ok = false, dup = false; |
|
|
|
bool ok = false, dup = false, created; |
|
|
|
char *st = NULL; |
|
|
|
char *st = NULL; |
|
|
|
tv_t share_cd; |
|
|
|
tv_t share_cd; |
|
|
|
|
|
|
|
|
|
|
@ -3827,10 +3834,12 @@ bool shares_add(PGconn *conn, char *workinfoid, char *username, char *workername |
|
|
|
memcpy(shares2, shares, sizeof(*shares2)); |
|
|
|
memcpy(shares2, shares, sizeof(*shares2)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wi_item = find_workinfo(shares->workinfoid, NULL); |
|
|
|
wi_item = find_workinfo_esm(shares->workinfoid, false, &created, |
|
|
|
|
|
|
|
&(shares->createdate)); |
|
|
|
if (!wi_item) { |
|
|
|
if (!wi_item) { |
|
|
|
|
|
|
|
int sta = (created ? LOG_ERR : LOG_NOTICE); |
|
|
|
btv_to_buf(cd, cd_buf, sizeof(cd_buf)); |
|
|
|
btv_to_buf(cd, cd_buf, sizeof(cd_buf)); |
|
|
|
LOGERR("%s() %"PRId64"/%s/%ld,%ld %s no workinfo! " |
|
|
|
LOGMSG(sta, "%s() %"PRId64"/%s/%ld,%ld %s no workinfo! " |
|
|
|
"Early share queued!", |
|
|
|
"Early share queued!", |
|
|
|
__func__, shares->workinfoid, |
|
|
|
__func__, shares->workinfoid, |
|
|
|
st = safe_text_nonull(workername), |
|
|
|
st = safe_text_nonull(workername), |
|
|
@ -4338,7 +4347,7 @@ static void shareerrors_process_early(PGconn *conn, int64_t good_wid, |
|
|
|
char *st = NULL; |
|
|
|
char *st = NULL; |
|
|
|
char tmp[1024]; |
|
|
|
char tmp[1024]; |
|
|
|
double delta; |
|
|
|
double delta; |
|
|
|
bool ok; |
|
|
|
bool ok, failed; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s() add", __func__); |
|
|
|
LOGDEBUG("%s() add", __func__); |
|
|
|
|
|
|
|
|
|
|
@ -4346,7 +4355,7 @@ static void shareerrors_process_early(PGconn *conn, int64_t good_wid, |
|
|
|
if (shareerrors_early_store->count == 0) { |
|
|
|
if (shareerrors_early_store->count == 0) { |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
// None
|
|
|
|
// None
|
|
|
|
return; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
es_item = last_in_ktree(shareerrors_early_root, ctx); |
|
|
|
es_item = last_in_ktree(shareerrors_early_root, ctx); |
|
|
|
if (es_item) { |
|
|
|
if (es_item) { |
|
|
@ -4399,18 +4408,20 @@ static void shareerrors_process_early(PGconn *conn, int64_t good_wid, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
redo: |
|
|
|
redo: |
|
|
|
K_WLOCK(shareerrors_free); |
|
|
|
K_WLOCK(shareerrors_free); |
|
|
|
add_to_ktree(shareerrors_early_root, es_item); |
|
|
|
add_to_ktree(shareerrors_early_root, es_item); |
|
|
|
k_add_tail(shareerrors_early_store, es_item); |
|
|
|
k_add_tail(shareerrors_early_store, es_item); |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
keep: |
|
|
|
keep: |
|
|
|
|
|
|
|
failed = esm_flag(early_shareerrors->workinfoid, true, true); |
|
|
|
btv_to_buf(&(early_shareerrors->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
btv_to_buf(&(early_shareerrors->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
LOGERR("%s() %"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
LOGNOTICE("%s() %s%"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
" Early share procured", |
|
|
|
" Early shareerror procured", |
|
|
|
__func__, early_shareerrors->workinfoid, |
|
|
|
__func__, failed ? "***ESM " : EMPTY, |
|
|
|
|
|
|
|
early_shareerrors->workinfoid, |
|
|
|
st = safe_text_nonull(early_shareerrors->workername), |
|
|
|
st = safe_text_nonull(early_shareerrors->workername), |
|
|
|
early_shareerrors->createdate.tv_sec, |
|
|
|
early_shareerrors->createdate.tv_sec, |
|
|
|
early_shareerrors->createdate.tv_usec, cd_buf, |
|
|
|
early_shareerrors->createdate.tv_usec, cd_buf, |
|
|
@ -4420,12 +4431,14 @@ keep: |
|
|
|
add_to_ktree(shareerrors_root, es_item); |
|
|
|
add_to_ktree(shareerrors_root, es_item); |
|
|
|
k_add_head(shareerrors_store, es_item); |
|
|
|
k_add_head(shareerrors_store, es_item); |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
return; |
|
|
|
goto out; |
|
|
|
discard: |
|
|
|
discard: |
|
|
|
|
|
|
|
failed = esm_flag(early_shareerrors->workinfoid, true, false); |
|
|
|
btv_to_buf(&(early_shareerrors->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
btv_to_buf(&(early_shareerrors->createdate), cd_buf, sizeof(cd_buf)); |
|
|
|
LOGERR("%s() %"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
LOGNOTICE("%s() %s%"PRId64"/%s/%ld,%ld %s/%"PRId32"/%"PRId32 |
|
|
|
" Early share discarded!%s", |
|
|
|
" Early shareerror discarded!%s", |
|
|
|
__func__, early_shareerrors->workinfoid, |
|
|
|
__func__, failed ? "***ESM " : EMPTY, |
|
|
|
|
|
|
|
early_shareerrors->workinfoid, |
|
|
|
st = safe_text_nonull(early_shareerrors->workername), |
|
|
|
st = safe_text_nonull(early_shareerrors->workername), |
|
|
|
early_shareerrors->createdate.tv_sec, |
|
|
|
early_shareerrors->createdate.tv_sec, |
|
|
|
early_shareerrors->createdate.tv_usec, cd_buf, |
|
|
|
early_shareerrors->createdate.tv_usec, cd_buf, |
|
|
@ -4434,7 +4447,10 @@ discard: |
|
|
|
K_WLOCK(shareerrors_free); |
|
|
|
K_WLOCK(shareerrors_free); |
|
|
|
k_add_head(shareerrors_free, es_item); |
|
|
|
k_add_head(shareerrors_free, es_item); |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
K_WUNLOCK(shareerrors_free); |
|
|
|
return; |
|
|
|
out: |
|
|
|
|
|
|
|
// accessed outside lock, but esm_check() uses the lock
|
|
|
|
|
|
|
|
if (esm_store->count) |
|
|
|
|
|
|
|
esm_check(good_cd); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Memory (and log file) only
|
|
|
|
// Memory (and log file) only
|
|
|
@ -4447,7 +4463,7 @@ bool shareerrors_add(PGconn *conn, char *workinfoid, char *username, |
|
|
|
char cd_buf[DATE_BUFSIZ]; |
|
|
|
char cd_buf[DATE_BUFSIZ]; |
|
|
|
SHAREERRORS *shareerrors = NULL; |
|
|
|
SHAREERRORS *shareerrors = NULL; |
|
|
|
USERS *users; |
|
|
|
USERS *users; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false, created; |
|
|
|
char *st = NULL; |
|
|
|
char *st = NULL; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): %s/%s/%s/%s/%ld,%ld", |
|
|
|
LOGDEBUG("%s(): %s/%s/%s/%s/%ld,%ld", |
|
|
@ -4501,10 +4517,12 @@ bool shareerrors_add(PGconn *conn, char *workinfoid, char *username, |
|
|
|
HISTORYDATEINIT(shareerrors, cd, by, code, inet); |
|
|
|
HISTORYDATEINIT(shareerrors, cd, by, code, inet); |
|
|
|
HISTORYDATETRANSFER(trf_root, shareerrors); |
|
|
|
HISTORYDATETRANSFER(trf_root, shareerrors); |
|
|
|
|
|
|
|
|
|
|
|
wi_item = find_workinfo(shareerrors->workinfoid, NULL); |
|
|
|
wi_item = find_workinfo_esm(shareerrors->workinfoid, true, &created, |
|
|
|
|
|
|
|
&(shareerrors->createdate)); |
|
|
|
if (!wi_item) { |
|
|
|
if (!wi_item) { |
|
|
|
|
|
|
|
int sta = (created ? LOG_ERR : LOG_NOTICE); |
|
|
|
btv_to_buf(cd, cd_buf, sizeof(cd_buf)); |
|
|
|
btv_to_buf(cd, cd_buf, sizeof(cd_buf)); |
|
|
|
LOGERR("%s() %"PRId64"/%s/%ld,%ld %s no workinfo! " |
|
|
|
LOGMSG(sta, "%s() %"PRId64"/%s/%ld,%ld %s no workinfo! " |
|
|
|
"Early shareerror queued!", |
|
|
|
"Early shareerror queued!", |
|
|
|
__func__, shareerrors->workinfoid, |
|
|
|
__func__, shareerrors->workinfoid, |
|
|
|
st = safe_text_nonull(workername), |
|
|
|
st = safe_text_nonull(workername), |
|
|
|