Browse Source

ckp - make blob ram alloc/free/accounting more consistent

master
kanoi 9 years ago
parent
commit
f4d00f83e5
  1. 8
      src/ckdb.c
  2. 22
      src/ckdb.h
  3. 6
      src/ckdb_cmd.c
  4. 2
      src/ckdb_crypt.c
  5. 42
      src/ckdb_data.c
  6. 105
      src/ckdb_dbio.c

8
src/ckdb.c

@ -1320,7 +1320,9 @@ static void dealloc_storage()
FREE_ALL(auths); FREE_ALL(auths);
FREE_TREE(payouts_id); FREE_TREE(payouts_id);
FREE_ALL(payouts); FREE_TREE(payouts);
FREE_STORE_DATA(payouts);
FREE_LIST_DATA(payouts);
FREE_ALL(miningpayouts); FREE_ALL(miningpayouts);
FREE_ALL(blocks); FREE_ALL(blocks);
@ -1400,7 +1402,9 @@ static void dealloc_storage()
FREE_ALL(useratts); FREE_ALL(useratts);
FREE_TREE(userid); FREE_TREE(userid);
FREE_ALL(users); FREE_TREE(users);
FREE_STORE_DATA(users);
FREE_LIST_DATA(users);
LOGWARNING("%s() transfer/heartbeatqueue/workqueue ...", __func__); LOGWARNING("%s() transfer/heartbeatqueue/workqueue ...", __func__);

22
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.1" #define DB_VERSION "1.0.1"
#define CKDB_VERSION DB_VERSION"-1.200" #define CKDB_VERSION DB_VERSION"-1.210"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -67,13 +67,6 @@
#define STRINT(x) STRINT2(x) #define STRINT(x) STRINT2(x)
#define STRINT2(x) #x #define STRINT2(x) #x
#define FREENULL(mem) do { \
if (mem) { \
free(mem); \
mem = NULL; \
} \
} while (0)
// So they can fit into a 1 byte flag field // So they can fit into a 1 byte flag field
#define TRUE_STR "Y" #define TRUE_STR "Y"
#define FALSE_STR "N" #define FALSE_STR "N"
@ -105,6 +98,13 @@ extern int switch_state;
#define BLANK " " #define BLANK " "
extern char *EMPTY; extern char *EMPTY;
#define FREENULL(mem) do { \
if ((mem) && (void *)(mem) != (void *)EMPTY) { \
free(mem); \
mem = NULL; \
} \
} while (0)
// To ensure there's space for the ticker // To ensure there's space for the ticker
#define TICK_PREFIX " " #define TICK_PREFIX " "
@ -450,17 +450,21 @@ enum cmd_values {
} while (0) } while (0)
#define LIST_MEM_ADD(_list, _fld) do { \ #define LIST_MEM_ADD(_list, _fld) do { \
if ((_fld) && (_fld) != EMPTY) { \
size_t __siz; \ size_t __siz; \
__siz = strlen(_fld) + 1; \ __siz = strlen(_fld) + 1; \
LIST_MEM_ADD_SIZ(_list, __siz); \ LIST_MEM_ADD_SIZ(_list, __siz); \
} \
} while (0) } while (0)
#define LIST_MEM_SUB(_list, _fld) do { \ #define LIST_MEM_SUB(_list, _fld) do { \
if ((_fld) && (_fld) != EMPTY) { \
size_t __siz; \ size_t __siz; \
__siz = strlen(_fld) + 1; \ __siz = strlen(_fld) + 1; \
if (__siz % MEMBASE) \ if (__siz % MEMBASE) \
__siz += MEMBASE - (__siz % MEMBASE); \ __siz += MEMBASE - (__siz % MEMBASE); \
_list->ram -= (int)__siz; \ _list->ram -= (int)__siz; \
} \
} while (0) } while (0)
#define SET_POINTER(_list, _fld, _val, _def) do { \ #define SET_POINTER(_list, _fld, _val, _def) do { \
@ -2029,8 +2033,10 @@ extern void sequence_report(bool lock);
// Data free functions (first) // Data free functions (first)
extern void free_msgline_data(K_ITEM *item, bool t_lock, bool t_cull); extern void free_msgline_data(K_ITEM *item, bool t_lock, bool t_cull);
extern void free_users_data(K_ITEM *item);
extern void free_workinfo_data(K_ITEM *item); extern void free_workinfo_data(K_ITEM *item);
extern void free_sharesummary_data(K_ITEM *item); extern void free_sharesummary_data(K_ITEM *item);
extern void free_payouts_data(K_ITEM *item);
extern void free_optioncontrol_data(K_ITEM *item); extern void free_optioncontrol_data(K_ITEM *item);
extern void free_markersummary_data(K_ITEM *item); extern void free_markersummary_data(K_ITEM *item);
extern void free_workmarkers_data(K_ITEM *item); extern void free_workmarkers_data(K_ITEM *item);

6
src/ckdb_cmd.c

@ -3797,6 +3797,7 @@ static char *cmd_setopts(PGconn *conn, char *cmd, char *id,
optioncontrol->optionvalue = strdup(data); optioncontrol->optionvalue = strdup(data);
if (!(optioncontrol->optionvalue)) if (!(optioncontrol->optionvalue))
quithere(1, "malloc (%d) OOM", (int)strlen(data)); quithere(1, "malloc (%d) OOM", (int)strlen(data));
LIST_MEM_ADD(optioncontrol_free, optioncontrol->optionvalue);
gotvalue = true; gotvalue = true;
} else if (strcmp(dot, "date") == 0) { } else if (strcmp(dot, "date") == 0) {
att_to_date(&(optioncontrol->activationdate), data, now); att_to_date(&(optioncontrol->activationdate), data, now);
@ -4695,6 +4696,7 @@ static char *cmd_payouts(PGconn *conn, char *cmd, char *id, tv_t *now,
payouts2->shareacc = payouts->shareacc; payouts2->shareacc = payouts->shareacc;
copy_tv(&(payouts2->lastshareacc), &(payouts->lastshareacc)); copy_tv(&(payouts2->lastshareacc), &(payouts->lastshareacc));
payouts2->stats = strdup(payouts->stats); payouts2->stats = strdup(payouts->stats);
LIST_MEM_ADD(payouts_free, payouts2->stats);
ok = payouts_add(conn, true, p2_item, &old_p2_item, ok = payouts_add(conn, true, p2_item, &old_p2_item,
by, code, inet, now, NULL, false); by, code, inet, now, NULL, false);
@ -4759,6 +4761,7 @@ static char *cmd_payouts(PGconn *conn, char *cmd, char *id, tv_t *now,
payouts2->shareacc = payouts->shareacc; payouts2->shareacc = payouts->shareacc;
copy_tv(&(payouts2->lastshareacc), &(payouts->lastshareacc)); copy_tv(&(payouts2->lastshareacc), &(payouts->lastshareacc));
payouts2->stats = strdup(payouts->stats); payouts2->stats = strdup(payouts->stats);
LIST_MEM_ADD(payouts_free, payouts2->stats);
ok = payouts_add(conn, true, p2_item, &old_p2_item, ok = payouts_add(conn, true, p2_item, &old_p2_item,
by, code, inet, now, NULL, false); by, code, inet, now, NULL, false);
@ -5410,8 +5413,7 @@ static char *cmd_stats(__maybe_unused PGconn *conn, char *cmd, char *id,
APPEND_REALLOC_INIT(buf, off, len); APPEND_REALLOC_INIT(buf, off, len);
APPEND_REALLOC(buf, off, len, "ok."); APPEND_REALLOC(buf, off, len, "ok.");
// Doesn't include blob memory // FYI average transactiontree length of the ~119k I have is ~28k (>3.3GB)
// - average transactiontree length of ~119k I have is ~28k (>3.3GB)
#define USEINFO(_obj, _stores, _trees) \ #define USEINFO(_obj, _stores, _trees) \
klist = _obj ## _free; \ klist = _obj ## _free; \
ram = sizeof(K_LIST) + _stores * sizeof(K_STORE) + \ ram = sizeof(K_LIST) + _stores * sizeof(K_STORE) + \

2
src/ckdb_crypt.c

@ -122,6 +122,7 @@ K_ITEM *gen_2fa_key(K_ITEM *old_u_item, int32_t entropy, char *by, char *code,
users->userdata = strdup(users->userdata); users->userdata = strdup(users->userdata);
if (!users->userdata) if (!users->userdata)
quithere(1, "strdup OOM"); quithere(1, "strdup OOM");
LIST_MEM_ADD(users_free, users->userdata);
} }
users_userdata_add_bin(users, USER_TOTPAUTH_NAME, users_userdata_add_bin(users, USER_TOTPAUTH_NAME,
USER_TOTPAUTH, key, sizeof(key)); USER_TOTPAUTH, key, sizeof(key));
@ -229,6 +230,7 @@ bool tst_2fa(K_ITEM *old_u_item, int32_t value, char *by, char *code,
users->userdata = strdup(users->userdata); users->userdata = strdup(users->userdata);
if (!users->userdata) if (!users->userdata)
quithere(1, "strdup OOM"); quithere(1, "strdup OOM");
LIST_MEM_ADD(users_free, users->userdata);
} }
users_userdata_del(users, USER_TEST2FA_NAME, USER_TEST2FA); users_userdata_del(users, USER_TEST2FA_NAME, USER_TEST2FA);
ok = users_replace(NULL, u_item, old_u_item, by, code, inet, cd, ok = users_replace(NULL, u_item, old_u_item, by, code, inet, cd,

42
src/ckdb_data.c

@ -44,26 +44,42 @@ void free_msgline_data(K_ITEM *item, bool t_lock, bool t_cull)
FREENULL(msgline->msg); FREENULL(msgline->msg);
} }
void free_users_data(K_ITEM *item)
{
USERS *users;
DATA_USERS(users, item);
LIST_MEM_SUB(users_free, users->userdata);
FREENULL(users->userdata);
}
void free_workinfo_data(K_ITEM *item) void free_workinfo_data(K_ITEM *item)
{ {
WORKINFO *workinfo; WORKINFO *workinfo;
DATA_WORKINFO(workinfo, item); DATA_WORKINFO(workinfo, item);
if (workinfo->transactiontree) LIST_MEM_SUB(workinfo_free, workinfo->transactiontree);
FREENULL(workinfo->transactiontree); FREENULL(workinfo->transactiontree);
if (workinfo->merklehash) LIST_MEM_SUB(workinfo_free, workinfo->merklehash);
FREENULL(workinfo->merklehash); FREENULL(workinfo->merklehash);
} }
void free_payouts_data(K_ITEM *item)
{
PAYOUTS *payouts;
DATA_PAYOUTS(payouts, item);
LIST_MEM_SUB(payouts_free, payouts->stats);
FREENULL(payouts->stats);
}
void free_sharesummary_data(K_ITEM *item) void free_sharesummary_data(K_ITEM *item)
{ {
SHARESUMMARY *sharesummary; SHARESUMMARY *sharesummary;
DATA_SHARESUMMARY(sharesummary, item); DATA_SHARESUMMARY(sharesummary, item);
if (sharesummary->workername) {
LIST_MEM_SUB(sharesummary_free, sharesummary->workername); LIST_MEM_SUB(sharesummary_free, sharesummary->workername);
FREENULL(sharesummary->workername); FREENULL(sharesummary->workername);
}
SET_CREATEBY(sharesummary_free, sharesummary->createby, EMPTY); SET_CREATEBY(sharesummary_free, sharesummary->createby, EMPTY);
SET_CREATECODE(sharesummary_free, sharesummary->createcode, EMPTY); SET_CREATECODE(sharesummary_free, sharesummary->createcode, EMPTY);
SET_CREATEINET(sharesummary_free, sharesummary->createinet, EMPTY); SET_CREATEINET(sharesummary_free, sharesummary->createinet, EMPTY);
@ -77,7 +93,7 @@ void free_optioncontrol_data(K_ITEM *item)
OPTIONCONTROL *optioncontrol; OPTIONCONTROL *optioncontrol;
DATA_OPTIONCONTROL(optioncontrol, item); DATA_OPTIONCONTROL(optioncontrol, item);
if (optioncontrol->optionvalue) LIST_MEM_SUB(optioncontrol_free, optioncontrol->optionvalue);
FREENULL(optioncontrol->optionvalue); FREENULL(optioncontrol->optionvalue);
} }
@ -86,7 +102,7 @@ void free_markersummary_data(K_ITEM *item)
MARKERSUMMARY *markersummary; MARKERSUMMARY *markersummary;
DATA_MARKERSUMMARY(markersummary, item); DATA_MARKERSUMMARY(markersummary, item);
if (markersummary->workername) LIST_MEM_SUB(markersummary_free, markersummary->workername);
FREENULL(markersummary->workername); FREENULL(markersummary->workername);
SET_CREATEBY(markersummary_free, markersummary->createby, EMPTY); SET_CREATEBY(markersummary_free, markersummary->createby, EMPTY);
SET_CREATECODE(markersummary_free, markersummary->createcode, EMPTY); SET_CREATECODE(markersummary_free, markersummary->createcode, EMPTY);
@ -101,9 +117,9 @@ void free_workmarkers_data(K_ITEM *item)
WORKMARKERS *workmarkers; WORKMARKERS *workmarkers;
DATA_WORKMARKERS(workmarkers, item); DATA_WORKMARKERS(workmarkers, item);
if (workmarkers->poolinstance) LIST_MEM_SUB(workmarkers_free, workmarkers->poolinstance);
FREENULL(workmarkers->poolinstance); FREENULL(workmarkers->poolinstance);
if (workmarkers->description) LIST_MEM_SUB(workmarkers_free, workmarkers->description);
FREENULL(workmarkers->description); FREENULL(workmarkers->description);
} }
@ -112,11 +128,11 @@ void free_marks_data(K_ITEM *item)
MARKS *marks; MARKS *marks;
DATA_MARKS(marks, item); DATA_MARKS(marks, item);
if (marks->poolinstance && marks->poolinstance != EMPTY) LIST_MEM_SUB(marks_free, marks->poolinstance);
FREENULL(marks->poolinstance); FREENULL(marks->poolinstance);
if (marks->description && marks->description != EMPTY) LIST_MEM_SUB(marks_free, marks->description);
FREENULL(marks->description); FREENULL(marks->description);
if (marks->extra && marks->extra != EMPTY) LIST_MEM_SUB(marks_free, marks->extra);
FREENULL(marks->extra); FREENULL(marks->extra);
} }
@ -3657,6 +3673,7 @@ bool process_pplns(int32_t height, char *blockhash, tv_t *addr_cd)
FLDSEP, ss_count, FLDSEP, wm_count, FLDSEP, ms_count, FLDSEP, ss_count, FLDSEP, wm_count, FLDSEP, ms_count,
FLDSEP, cd_buf); FLDSEP, cd_buf);
payouts->stats = buf; payouts->stats = buf;
LIST_MEM_ADD(payouts_free, payouts->stats);
conned = CKPQConn(&conn); conned = CKPQConn(&conn);
begun = CKPQBegin(conn); begun = CKPQBegin(conn);
@ -3872,6 +3889,7 @@ bool process_pplns(int32_t height, char *blockhash, tv_t *addr_cd)
// convert the stack memory to heap memeory // convert the stack memory to heap memeory
payouts->stats = strdup(payouts->stats); payouts->stats = strdup(payouts->stats);
LIST_MEM_ADD(payouts_free, payouts->stats);
K_WLOCK(payouts_free); K_WLOCK(payouts_free);
p2_item = k_unlink_head(payouts_free); p2_item = k_unlink_head(payouts_free);
@ -3891,6 +3909,7 @@ bool process_pplns(int32_t height, char *blockhash, tv_t *addr_cd)
payouts2->shareacc = payouts->shareacc; payouts2->shareacc = payouts->shareacc;
copy_tv(&(payouts2->lastshareacc), &(payouts->lastshareacc)); copy_tv(&(payouts2->lastshareacc), &(payouts->lastshareacc));
payouts2->stats = strdup(payouts->stats); payouts2->stats = strdup(payouts->stats);
LIST_MEM_ADD(payouts_free, payouts2->stats);
setnow(&now); setnow(&now);
/* N.B. the PROCESSING payouts could have expirydate = createdate /* N.B. the PROCESSING payouts could have expirydate = createdate
@ -3918,6 +3937,7 @@ shazbot:
if (p_item) { if (p_item) {
K_WLOCK(payouts_free); K_WLOCK(payouts_free);
free_payouts_data(p_item);
k_add_head(payouts_free, p_item); k_add_head(payouts_free, p_item);
K_WUNLOCK(payouts_free); K_WUNLOCK(payouts_free);
} }

105
src/ckdb_dbio.c

@ -432,6 +432,7 @@ bool users_update(PGconn *conn, K_ITEM *u_item, char *oldhash,
row->userdata = strdup(users->userdata); row->userdata = strdup(users->userdata);
if (!row->userdata) if (!row->userdata)
quithere(1, "strdup OOM"); quithere(1, "strdup OOM");
LIST_MEM_ADD(users_free, row->userdata);
} }
HISTORYDATEINIT(row, cd, by, code, inet); HISTORYDATEINIT(row, cd, by, code, inet);
@ -514,8 +515,7 @@ unparam:
K_WLOCK(users_free); K_WLOCK(users_free);
if (!ok) { if (!ok) {
if (row->userdata != EMPTY) free_users_data(item);
FREENULL(row->userdata);
k_add_head(users_free, item); k_add_head(users_free, item);
} else { } else {
users_root = remove_from_ktree(users_root, u_item, cmp_users); users_root = remove_from_ktree(users_root, u_item, cmp_users);
@ -649,9 +649,10 @@ unparam:
free(params[n]); free(params[n]);
unitem: unitem:
K_WLOCK(users_free); K_WLOCK(users_free);
if (!ok) if (!ok) {
free_users_data(item);
k_add_head(users_free, item); k_add_head(users_free, item);
else { } else {
users_root = add_to_ktree(users_root, item, cmp_users); users_root = add_to_ktree(users_root, item, cmp_users);
userid_root = add_to_ktree(userid_root, item, cmp_userid); userid_root = add_to_ktree(userid_root, item, cmp_userid);
k_add_head(users_store, item); k_add_head(users_store, item);
@ -761,8 +762,7 @@ unparam:
K_WLOCK(users_free); K_WLOCK(users_free);
if (!ok) { if (!ok) {
// cleanup done here // cleanup done here
if (users->userdata != EMPTY) free_users_data(u_item);
FREENULL(users->userdata);
k_add_head(users_free, u_item); k_add_head(users_free, u_item);
} else { } else {
users_root = remove_from_ktree(users_root, old_u_item, cmp_users); users_root = remove_from_ktree(users_root, old_u_item, cmp_users);
@ -892,8 +892,10 @@ bool users_fill(PGconn *conn)
userid_root = add_to_ktree(userid_root, item, cmp_userid); userid_root = add_to_ktree(userid_root, item, cmp_userid);
k_add_head(users_store, item); k_add_head(users_store, item);
} }
if (!ok) if (!ok) {
free_users_data(item);
k_add_head(users_free, item); k_add_head(users_free, item);
}
K_WUNLOCK(users_free); K_WUNLOCK(users_free);
PQclear(res); PQclear(res);
@ -2341,7 +2343,7 @@ K_ITEM *optioncontrol_item_add(PGconn *conn, K_ITEM *oc_item, tv_t *cd, bool beg
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
PGresult *res; PGresult *res;
K_ITEM *old_item, look; K_ITEM *old_item, look;
OPTIONCONTROL *row, *optioncontrol; OPTIONCONTROL *row;
char *upd, *ins; char *upd, *ins;
bool ok = false; bool ok = false;
char *params[4 + HISTORYDATECOUNT]; char *params[4 + HISTORYDATECOUNT];
@ -2444,16 +2446,15 @@ nostart:
K_WLOCK(optioncontrol_free); K_WLOCK(optioncontrol_free);
if (!ok) { if (!ok) {
// Cleanup item passed in // Cleanup item passed in
FREENULL(row->optionvalue); free_optioncontrol_data(oc_item);
k_add_head(optioncontrol_free, oc_item); k_add_head(optioncontrol_free, oc_item);
} else { } else {
// Discard old // Discard old
if (old_item) { if (old_item) {
DATA_OPTIONCONTROL(optioncontrol, old_item);
optioncontrol_root = remove_from_ktree(optioncontrol_root, old_item, optioncontrol_root = remove_from_ktree(optioncontrol_root, old_item,
cmp_optioncontrol); cmp_optioncontrol);
k_unlink_item(optioncontrol_store, old_item); k_unlink_item(optioncontrol_store, old_item);
FREENULL(optioncontrol->optionvalue); free_optioncontrol_data(old_item);
k_add_head(optioncontrol_free, old_item); k_add_head(optioncontrol_free, old_item);
} }
optioncontrol_root = add_to_ktree(optioncontrol_root, oc_item, cmp_optioncontrol); optioncontrol_root = add_to_ktree(optioncontrol_root, oc_item, cmp_optioncontrol);
@ -2600,7 +2601,7 @@ bool optioncontrol_fill(PGconn *conn)
} }
} }
if (!ok) { if (!ok) {
FREENULL(row->optionvalue); free_optioncontrol_data(item);
k_add_head(optioncontrol_free, item); k_add_head(optioncontrol_free, item);
} }
@ -2670,11 +2671,8 @@ int64_t workinfo_add(PGconn *conn, char *workinfoidstr, char *poolinstance,
K_WLOCK(workinfo_free); K_WLOCK(workinfo_free);
if (find_in_ktree(workinfo_root, item, cmp_workinfo, ctx)) { if (find_in_ktree(workinfo_root, item, cmp_workinfo, ctx)) {
LIST_MEM_SUB(workinfo_free, row->transactiontree);
FREENULL(row->transactiontree);
LIST_MEM_SUB(workinfo_free, row->merklehash);
FREENULL(row->merklehash);
workinfoid = row->workinfoid; workinfoid = row->workinfoid;
free_workinfo_data(item);
k_add_head(workinfo_free, item); k_add_head(workinfo_free, item);
K_WUNLOCK(workinfo_free); K_WUNLOCK(workinfo_free);
@ -2735,19 +2733,12 @@ unparam:
K_WLOCK(workinfo_free); K_WLOCK(workinfo_free);
if (workinfoid == -1) { if (workinfoid == -1) {
LIST_MEM_SUB(workinfo_free, row->transactiontree); free_workinfo_data(item);
FREENULL(row->transactiontree);
LIST_MEM_SUB(workinfo_free, row->merklehash);
FREENULL(row->merklehash);
k_add_head(workinfo_free, item); k_add_head(workinfo_free, item);
} else { } else {
if (row->transactiontree && *(row->transactiontree)) {
// Not currently needed in RAM // Not currently needed in RAM
LIST_MEM_SUB(workinfo_free, row->transactiontree); LIST_MEM_SUB(workinfo_free, row->transactiontree);
free(row->transactiontree); FREENULL(row->transactiontree);
row->transactiontree = strdup(EMPTY);
LIST_MEM_ADD(workinfo_free, row->transactiontree);
}
hex2bin(ndiffbin, row->bits, 4); hex2bin(ndiffbin, row->bits, 4);
current_ndiff = diff_from_nbits(ndiffbin); current_ndiff = diff_from_nbits(ndiffbin);
@ -2870,9 +2861,9 @@ bool workinfo_fill(PGconn *conn)
if (!ok) if (!ok)
break; break;
TXT_TO_BLOB("transactiontree", field, row->transactiontree); TXT_TO_BLOB("transactiontree", field, row->transactiontree);
*/
row->transactiontree = strdup(EMPTY);
LIST_MEM_ADD(workinfo_free, row->transactiontree); LIST_MEM_ADD(workinfo_free, row->transactiontree);
*/
row->transactiontree = EMPTY;
PQ_GET_FLD(res, i, "merklehash", field, ok); PQ_GET_FLD(res, i, "merklehash", field, ok);
if (!ok) if (!ok)
@ -2940,8 +2931,7 @@ bool workinfo_fill(PGconn *conn)
tick(); tick();
} }
if (!ok) { if (!ok) {
//FREENULL(row->transactiontree); free_workinfo_data(item);
FREENULL(row->merklehash);
k_add_head(workinfo_free, item); k_add_head(workinfo_free, item);
} }
@ -5097,6 +5087,7 @@ void payouts_add_ram(bool ok, K_ITEM *p_item, K_ITEM *old_p_item, tv_t *cd)
K_WLOCK(payouts_free); K_WLOCK(payouts_free);
if (!ok) { if (!ok) {
// Cleanup for the calling function // Cleanup for the calling function
free_payouts_data(p_item);
k_add_head(payouts_free, p_item); k_add_head(payouts_free, p_item);
} else { } else {
if (old_p_item) { if (old_p_item) {
@ -5601,7 +5592,7 @@ bool payouts_fill(PGconn *conn)
tick(); tick();
} }
if (!ok) { if (!ok) {
FREENULL(row->stats); free_payouts_data(item);
k_add_head(payouts_free, item); k_add_head(payouts_free, item);
} }
@ -6448,7 +6439,7 @@ bool markersummary_fill(PGconn *conn)
tick(); tick();
} }
if (!ok) { if (!ok) {
FREENULL(row->workername); free_markersummary_data(item);
k_add_head(markersummary_free, item); k_add_head(markersummary_free, item);
} }
@ -6658,23 +6649,7 @@ unparam:
K_WLOCK(workmarkers_free); K_WLOCK(workmarkers_free);
if (!ok) { if (!ok) {
if (wm_item) { if (wm_item) {
DATA_WORKMARKERS(row, wm_item); free_workmarkers_data(wm_item);
if (row->poolinstance) {
if (row->poolinstance != EMPTY) {
LIST_MEM_SUB(workmarkers_free,
row->poolinstance);
free(row->poolinstance);
}
row->poolinstance = NULL;
}
if (row->description) {
if (row->description != EMPTY) {
LIST_MEM_SUB(workmarkers_free,
row->description);
free(row->description);
}
row->description = NULL;
}
k_add_head(workmarkers_free, wm_item); k_add_head(workmarkers_free, wm_item);
} }
} }
@ -6820,8 +6795,10 @@ bool workmarkers_fill(PGconn *conn)
tick(); tick();
} }
if (!ok) if (!ok) {
free_workmarkers_data(item);
k_add_head(workmarkers_free, item); k_add_head(workmarkers_free, item);
}
K_WUNLOCK(workmarkers_free); K_WUNLOCK(workmarkers_free);
PQclear(res); PQclear(res);
@ -6991,32 +6968,10 @@ unparam:
K_WLOCK(marks_free); K_WLOCK(marks_free);
if (!ok) { if (!ok) {
if (m_item) { if (m_item) {
DATA_MARKS(row, m_item); free_marks_data(m_item);
if (row->poolinstance) {
if (row->poolinstance != EMPTY) {
LIST_MEM_SUB(marks_free, row->poolinstance);
free(row->poolinstance);
}
row->poolinstance = NULL;
}
if (row->description) {
if (row->description != EMPTY) {
LIST_MEM_SUB(marks_free, row->description);
free(row->description);
}
row->description = NULL;
}
if (row->extra) {
if (row->extra != EMPTY) {
LIST_MEM_SUB(marks_free, row->extra);
free(row->extra);
}
row->extra = NULL;
}
k_add_head(marks_free, m_item); k_add_head(marks_free, m_item);
} }
} } else {
else {
if (old_m_item) { if (old_m_item) {
marks_root = remove_from_ktree(marks_root, old_m_item, cmp_marks); marks_root = remove_from_ktree(marks_root, old_m_item, cmp_marks);
copy_tv(&(oldmarks->expirydate), cd); copy_tv(&(oldmarks->expirydate), cd);
@ -7123,8 +7078,10 @@ bool marks_fill(PGconn *conn)
tick(); tick();
} }
if (!ok) if (!ok) {
free_marks_data(item);
k_add_head(marks_free, item); k_add_head(marks_free, item);
}
K_WUNLOCK(marks_free); K_WUNLOCK(marks_free);
PQclear(res); PQclear(res);

Loading…
Cancel
Save