Browse Source

ckdb - thread breakdown, limit it's ram usage, close/open db connections during db load, report new stats during reload every 15s

master
kanoi 9 years ago
parent
commit
57aaad447f
  1. 712
      src/ckdb.c
  2. 61
      src/ckdb.h
  3. 152
      src/ckdb_cmd.c
  4. 3
      src/ckdb_dbio.c

712
src/ckdb.c

File diff suppressed because it is too large Load Diff

61
src/ckdb.h

@ -51,7 +51,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.5" #define DB_VERSION "1.0.5"
#define CKDB_VERSION DB_VERSION"-1.990" #define CKDB_VERSION DB_VERSION"-2.000"
#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__
@ -1037,7 +1037,7 @@ typedef struct msgline {
#define ALLOC_MSGLINE 8192 #define ALLOC_MSGLINE 8192
#define LIMIT_MSGLINE 0 #define LIMIT_MSGLINE 0
#define CULL_MSGLINE 16 #define CULL_MSGLINE 8
#define INIT_MSGLINE(_item) INIT_GENERIC(_item, msgline) #define INIT_MSGLINE(_item) INIT_GENERIC(_item, msgline)
#define DATA_MSGLINE(_var, _item) DATA_GENERIC(_var, _item, msgline, true) #define DATA_MSGLINE(_var, _item) DATA_GENERIC(_var, _item, msgline, true)
#define DATA_MSGLINE_NULL(_var, _item) DATA_GENERIC(_var, _item, msgline, false) #define DATA_MSGLINE_NULL(_var, _item) DATA_GENERIC(_var, _item, msgline, false)
@ -1045,6 +1045,57 @@ typedef struct msgline {
extern K_LIST *msgline_free; extern K_LIST *msgline_free;
extern K_STORE *msgline_store; extern K_STORE *msgline_store;
// BREAKQUEUE
typedef struct breakqueue {
char *buf;
tv_t now;
int seqentryflags;
int sockd;
enum cmd_values cmdnum;
K_ITEM *ml_item;
uint64_t count;
char *filename;
} BREAKQUEUE;
#define ALLOC_BREAKQUEUE 16384
#define LIMIT_BREAKQUEUE 0
#define CULL_BREAKQUEUE 4
#define INIT_BREAKQUEUE(_item) INIT_GENERIC(_item, breakqueue)
#define DATA_BREAKQUEUE(_var, _item) DATA_GENERIC(_var, _item, breakqueue, true)
/* If a breaker() thread's done break queue count hits the LIMIT, or is empty,
* it will sleep for SLEEP ms
* So this means that with a single breaker() thread,
* it can process at most LIMIT records per SLEEP ms
* or: 1000 * LIMIT / SLEEP records per second
* For N breaker() threads, that would mean between 1 and N times that value
* dependent upon the random time spacing of the N thread sleeps
* However, also note that LIMIT defines how much RAM can be used by
* the break queues, so a limit is required
* A breakqueue item can get quite large since it includes both buf
* and ml_item (which has the transfer data) in the 'done' queue
* Of course the processing speed of the ml_items will also decide how big the
* break queue count can get
* Note that if the CMD queues get too large they will be too slow responding
* to the sockets that sent the message, however the CMD ml_item processing
* responds immediately before processing the ml_item for all but ADDRAUTH,
* AUTHORISE and HEARTBEAT
* The reload also uses this limit when filling the reload break queue
* thus limiting the line processing of reload files
*/
// 16300,42 equated to single thread limitation of ~388k per second
#define RELOAD_QUEUE_LIMIT 16300
#define RELOAD_QUEUE_SLEEP 42
#define CMD_QUEUE_LIMIT 16300
#define CMD_QUEUE_SLEEP 42
extern K_LIST *breakqueue_free;
extern K_STORE *reload_breakqueue_store;
extern K_STORE *reload_done_breakqueue_store;
extern K_STORE *cmd_breakqueue_store;
extern K_STORE *cmd_done_breakqueue_store;
extern int max_sockd_count;
// WORKQUEUE // WORKQUEUE
typedef struct workqueue { typedef struct workqueue {
K_ITEM *msgline_item; K_ITEM *msgline_item;
@ -1093,7 +1144,7 @@ typedef struct transfer {
// Suggest malloc use MMAP - 1913 = largest under 2MB // Suggest malloc use MMAP - 1913 = largest under 2MB
#define ALLOC_TRANSFER 1913 #define ALLOC_TRANSFER 1913
#define LIMIT_TRANSFER 0 #define LIMIT_TRANSFER 0
#define CULL_TRANSFER 64 #define CULL_TRANSFER 32
#define INIT_TRANSFER(_item) INIT_GENERIC(_item, transfer) #define INIT_TRANSFER(_item) INIT_GENERIC(_item, transfer)
#define DATA_TRANSFER(_var, _item) DATA_GENERIC(_var, _item, transfer, true) #define DATA_TRANSFER(_var, _item) DATA_GENERIC(_var, _item, transfer, true)
@ -3124,7 +3175,7 @@ extern bool auths_add(PGconn *conn, char *poolinstance, char *username,
char *useragent, char *preauth, char *by, char *code, char *useragent, char *preauth, char *by, char *code,
char *inet, tv_t *cd, K_TREE *trf_root, char *inet, tv_t *cd, K_TREE *trf_root,
bool addressuser, USERS **users, WORKERS **workers, bool addressuser, USERS **users, WORKERS **workers,
int *event); int *event, bool reload_data);
extern bool poolstats_add(PGconn *conn, bool store, char *poolinstance, extern bool poolstats_add(PGconn *conn, bool store, char *poolinstance,
char *elapsed, char *users, char *workers, char *elapsed, char *users, char *workers,
char *hashrate, char *hashrate5m, char *hashrate, char *hashrate5m,
@ -3192,7 +3243,7 @@ struct CMDS {
bool noid; // doesn't require an id bool noid; // doesn't require an id
bool createdate; // requires a createdate bool createdate; // requires a createdate
char *(*func)(PGconn *, char *, char *, tv_t *, char *, char *, char *(*func)(PGconn *, char *, char *, tv_t *, char *, char *,
char *, tv_t *, K_TREE *); char *, tv_t *, K_TREE *, bool);
enum seq_num seq; enum seq_num seq;
int access; int access;
}; };

152
src/ckdb_cmd.c

@ -34,7 +34,7 @@ static K_ITEM *adminuser(K_TREE *trf_root, char *reply, size_t siz)
static char *cmd_adduser(PGconn *conn, char *cmd, char *id, tv_t *now, char *by, static char *cmd_adduser(PGconn *conn, char *cmd, char *id, tv_t *now, char *by,
char *code, char *inet, __maybe_unused tv_t *notcd, char *code, char *inet, __maybe_unused tv_t *notcd,
K_TREE *trf_root) K_TREE *trf_root, __maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -87,7 +87,8 @@ static char *cmd_adduser(PGconn *conn, char *cmd, char *id, tv_t *now, char *by,
static char *cmd_newpass(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_newpass(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, char *by, char *code, char *inet, tv_t *now, char *by, char *code, char *inet,
__maybe_unused tv_t *cd, K_TREE *trf_root) __maybe_unused tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_oldhash, *i_newhash, *i_2fa, *u_item; K_ITEM *i_username, *i_oldhash, *i_newhash, *i_2fa, *u_item;
char reply[1024] = ""; char reply[1024] = "";
@ -166,7 +167,8 @@ static char *cmd_newpass(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_chkpass(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_chkpass(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_passwordhash, *i_2fa, *u_item; K_ITEM *i_username, *i_passwordhash, *i_2fa, *u_item;
char reply[1024] = ""; char reply[1024] = "";
@ -222,7 +224,8 @@ static char *cmd_chkpass(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_2fa(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_2fa(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, char *by, char *code, char *inet, tv_t *now, char *by, char *code, char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_action, *i_entropy, *i_value, *u_item, *u_new; K_ITEM *i_username, *i_action, *i_entropy, *i_value, *u_item, *u_new;
char reply[1024] = ""; char reply[1024] = "";
@ -464,7 +467,8 @@ dame:
static char *cmd_userset(PGconn *conn, char *cmd, char *id, static char *cmd_userset(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_passwordhash, *i_2fa, *i_rows, *i_address; K_ITEM *i_username, *i_passwordhash, *i_2fa, *i_rows, *i_address;
K_ITEM *i_ratio, *i_payname, *i_email, *u_item, *pa_item, *old_pa_item; K_ITEM *i_ratio, *i_payname, *i_email, *u_item, *pa_item, *old_pa_item;
@ -781,7 +785,7 @@ struckout:
static char *cmd_workerset(PGconn *conn, char *cmd, char *id, tv_t *now, static char *cmd_workerset(PGconn *conn, char *cmd, char *id, tv_t *now,
char *by, char *code, char *inet, tv_t *cd, char *by, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, __maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_workername, *i_diffdef, *i_oldworkers; K_ITEM *i_username, *i_workername, *i_diffdef, *i_oldworkers;
K_ITEM *u_item, *ua_item, *w_item; K_ITEM *u_item, *ua_item, *w_item;
@ -1081,7 +1085,7 @@ static char *cmd_poolstats_do(PGconn *conn, char *cmd, char *id, char *by,
static char *cmd_poolstats(PGconn *conn, char *cmd, char *id, static char *cmd_poolstats(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *notnow, char *by, __maybe_unused tv_t *notnow, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, __maybe_unused bool reload_data)
{ {
bool igndup = false; bool igndup = false;
@ -1096,7 +1100,8 @@ static char *cmd_poolstats(PGconn *conn, char *cmd, char *id,
static char *cmd_userstats(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_userstats(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *notnow, char *by, char *code, __maybe_unused tv_t *notnow, char *by, char *code,
char *inet, tv_t *cd, K_TREE *trf_root) char *inet, tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -1180,7 +1185,8 @@ static char *cmd_userstats(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_workerstats(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_workerstats(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *notnow, char *by, char *code, __maybe_unused tv_t *notnow, char *by, char *code,
char *inet, tv_t *cd, K_TREE *trf_root) char *inet, tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -1263,7 +1269,8 @@ static char *cmd_blocklist(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
int ovent = OVENT_OK; int ovent = OVENT_OK;
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
@ -1525,7 +1532,8 @@ redo:
static char *cmd_blockstatus(PGconn *conn, char *cmd, char *id, tv_t *now, static char *cmd_blockstatus(PGconn *conn, char *cmd, char *id, tv_t *now,
char *by, char *code, char *inet, char *by, char *code, char *inet,
__maybe_unused tv_t *cd, K_TREE *trf_root) __maybe_unused tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_height, *i_blockhash, *i_action, *i_info; K_ITEM *i_height, *i_blockhash, *i_action, *i_info;
char reply[1024] = ""; char reply[1024] = "";
@ -1682,7 +1690,7 @@ static char *cmd_blockstatus(PGconn *conn, char *cmd, char *id, tv_t *now,
static char *cmd_newid(PGconn *conn, char *cmd, char *id, tv_t *now, char *by, static char *cmd_newid(PGconn *conn, char *cmd, char *id, tv_t *now, char *by,
char *code, char *inet, __maybe_unused tv_t *cd, char *code, char *inet, __maybe_unused tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, __maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -1718,7 +1726,8 @@ static char *cmd_payments(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *u_item, *p_item, *p2_item, *po_item; K_ITEM *i_username, *u_item, *p_item, *p2_item, *po_item;
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
@ -2056,7 +2065,8 @@ static char *cmd_percent(char *cmd, char *id, tv_t *now, USERS *users)
static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_workers(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_stats, *i_percent, w_look, *u_item, *w_item; K_ITEM *i_username, *i_stats, *i_percent, w_look, *u_item, *w_item;
K_ITEM *ua_item, *us_item, *ws_item; K_ITEM *ua_item, *us_item, *ws_item;
@ -2382,7 +2392,8 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_STORE *usu_store = k_new_store(userstats_free); K_STORE *usu_store = k_new_store(userstats_free);
K_ITEM *us_item, *usu_item, *u_item; K_ITEM *us_item, *usu_item, *u_item;
@ -2494,7 +2505,8 @@ static char *cmd_allusers(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_sharelog(PGconn *conn, char *cmd, char *id, static char *cmd_sharelog(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *notnow, char *by, __maybe_unused tv_t *notnow, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -2946,7 +2958,7 @@ static char *cmd_blocks_do(PGconn *conn, char *cmd, int32_t height, char *id,
static char *cmd_blocks(PGconn *conn, char *cmd, char *id, static char *cmd_blocks(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *notnow, char *by, __maybe_unused tv_t *notnow, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, __maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -2969,12 +2981,13 @@ static char *cmd_blocks(PGconn *conn, char *cmd, char *id,
igndup = true; igndup = true;
} }
return cmd_blocks_do(conn, cmd, height, id, by, code, inet, cd, igndup, trf_root); return cmd_blocks_do(conn, cmd, height, id, by, code, inet, cd, igndup,
trf_root);
} }
static char *cmd_auth_do(PGconn *conn, char *cmd, char *id, char *by, static char *cmd_auth_do(PGconn *conn, char *cmd, char *id, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, bool reload_data)
{ {
K_ITEM tmp_poolinstance_item; K_ITEM tmp_poolinstance_item;
TRANSFER tmp_poolinstance; TRANSFER tmp_poolinstance;
@ -3046,6 +3059,7 @@ static char *cmd_auth_do(PGconn *conn, char *cmd, char *id, char *by,
u_item = find_users(username); u_item = find_users(username);
K_RUNLOCK(users_free); K_RUNLOCK(users_free);
if (!u_item) { if (!u_item) {
if (!reload_data)
event = events_add(EVENTID_AUTOACC, trf_root); event = events_add(EVENTID_AUTOACC, trf_root);
if (event == EVENT_OK) { if (event == EVENT_OK) {
DATA_OPTIONCONTROL(optioncontrol, oc_item); DATA_OPTIONCONTROL(optioncontrol, oc_item);
@ -3067,7 +3081,7 @@ static char *cmd_auth_do(PGconn *conn, char *cmd, char *id, char *by,
transfer_data(i_useragent), transfer_data(i_useragent),
transfer_data(i_preauth), transfer_data(i_preauth),
by, code, inet, cd, trf_root, false, by, code, inet, cd, trf_root, false,
&users, &workers, &event); &users, &workers, &event, reload_data);
} }
if (!ok) { if (!ok) {
@ -3123,14 +3137,15 @@ static char *cmd_auth_do(PGconn *conn, char *cmd, char *id, char *by,
static char *cmd_auth(PGconn *conn, char *cmd, char *id, static char *cmd_auth(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, char *by, __maybe_unused tv_t *now, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, bool reload_data)
{ {
return cmd_auth_do(conn, cmd, id, by, code, inet, cd, trf_root); return cmd_auth_do(conn, cmd, id, by, code, inet, cd, trf_root,
reload_data);
} }
static char *cmd_addrauth_do(PGconn *conn, char *cmd, char *id, char *by, static char *cmd_addrauth_do(PGconn *conn, char *cmd, char *id, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, bool reload_data)
{ {
K_ITEM tmp_poolinstance_item; K_ITEM tmp_poolinstance_item;
TRANSFER tmp_poolinstance; TRANSFER tmp_poolinstance;
@ -3201,7 +3216,7 @@ static char *cmd_addrauth_do(PGconn *conn, char *cmd, char *id, char *by,
transfer_data(i_useragent), transfer_data(i_useragent),
transfer_data(i_preauth), transfer_data(i_preauth),
by, code, inet, cd, trf_root, true, by, code, inet, cd, trf_root, true,
&users, &workers, &event); &users, &workers, &event, reload_data);
if (!ok) { if (!ok) {
LOGDEBUG("%s() %s.failed.DBE", __func__, id); LOGDEBUG("%s() %s.failed.DBE", __func__, id);
@ -3256,16 +3271,18 @@ static char *cmd_addrauth_do(PGconn *conn, char *cmd, char *id, char *by,
static char *cmd_addrauth(PGconn *conn, char *cmd, char *id, static char *cmd_addrauth(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, char *by, __maybe_unused tv_t *now, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, bool reload_data)
{ {
return cmd_addrauth_do(conn, cmd, id, by, code, inet, cd, trf_root); return cmd_addrauth_do(conn, cmd, id, by, code, inet, cd, trf_root,
reload_data);
} }
static char *cmd_heartbeat(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_heartbeat(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *cd, __maybe_unused tv_t *cd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
HEARTBEATQUEUE *heartbeatqueue; HEARTBEATQUEUE *heartbeatqueue;
K_STORE *hq_store; K_STORE *hq_store;
@ -3331,7 +3348,8 @@ pulse:
static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *u_item, *b_item, *p_item, *us_item, look; K_ITEM *i_username, *u_item, *b_item, *p_item, *us_item, look;
K_ITEM *ua_item, *pa_item; K_ITEM *ua_item, *pa_item;
@ -3506,12 +3524,16 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id,
int psync = pool_workqueue_store->count; int psync = pool_workqueue_store->count;
int csync = cmd_workqueue_store->count; int csync = cmd_workqueue_store->count;
int bsync = btc_workqueue_store->count; int bsync = btc_workqueue_store->count;
int qsync = breakqueue_free->total - breakqueue_free->count;
snprintf(tmp, sizeof(tmp), "psync=%d%c", psync, FLDSEP); snprintf(tmp, sizeof(tmp), "psync=%d%c", psync, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
snprintf(tmp, sizeof(tmp), "csync=%d%c", csync, FLDSEP); snprintf(tmp, sizeof(tmp), "csync=%d%c", csync, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
snprintf(tmp, sizeof(tmp), "bsync=%d%c", bsync, FLDSEP); snprintf(tmp, sizeof(tmp), "bsync=%d%c", bsync, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
snprintf(tmp, sizeof(tmp), "qsync=%d%c", qsync, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
// qsync isn't part of 'sync'
snprintf(tmp, sizeof(tmp), "sync=%d%c", psync + csync + bsync, FLDSEP); snprintf(tmp, sizeof(tmp), "sync=%d%c", psync + csync + bsync, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
@ -3622,7 +3644,8 @@ static char *cmd_homepage(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_getatts(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_getatts(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_attlist, *u_item, *ua_item; K_ITEM *i_username, *i_attlist, *u_item, *ua_item;
char reply[1024] = ""; char reply[1024] = "";
@ -3798,7 +3821,8 @@ static void att_to_date(tv_t *date, char *data, tv_t *now)
* */ * */
static char *cmd_setatts(PGconn *conn, char *cmd, char *id, static char *cmd_setatts(PGconn *conn, char *cmd, char *id,
tv_t *now, char *by, char *code, char *inet, tv_t *now, char *by, char *code, char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
ExecStatusType rescode; ExecStatusType rescode;
PGresult *res; PGresult *res;
@ -3967,7 +3991,8 @@ bats:
static char *cmd_expatts(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_expatts(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_attlist, *u_item, *ua_item; K_ITEM *i_username, *i_attlist, *u_item, *ua_item;
char reply[1024] = ""; char reply[1024] = "";
@ -4050,7 +4075,8 @@ rats:
static char *cmd_getopts(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_getopts(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_optlist, *oc_item; K_ITEM *i_optlist, *oc_item;
char reply[1024] = ""; char reply[1024] = "";
@ -4128,7 +4154,8 @@ ruts:
* See opt_set_date() above */ * See opt_set_date() above */
static char *cmd_setopts(PGconn *conn, char *cmd, char *id, static char *cmd_setopts(PGconn *conn, char *cmd, char *id,
tv_t *now, char *by, char *code, char *inet, tv_t *now, char *by, char *code, char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
ExecStatusType rescode; ExecStatusType rescode;
PGresult *res; PGresult *res;
@ -4278,7 +4305,8 @@ rollback:
static char *cmd_pplns(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_pplns(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char reply[1024], tmp[1024], *buf; char reply[1024], tmp[1024], *buf;
char *block_extra, *share_status = EMPTY, *marks_status = EMPTY; char *block_extra, *share_status = EMPTY, *marks_status = EMPTY;
@ -4755,7 +4783,8 @@ shazbot:
static char *cmd_pplns2(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_pplns2(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char reply[1024], tmp[1024], *buf; char reply[1024], tmp[1024], *buf;
char *block_extra, *marks_status = EMPTY; char *block_extra, *marks_status = EMPTY;
@ -5022,7 +5051,8 @@ shazbot:
static char *cmd_payouts(PGconn *conn, char *cmd, char *id, tv_t *now, static char *cmd_payouts(PGconn *conn, char *cmd, char *id, tv_t *now,
char *by, char *code, char *inet, char *by, char *code, char *inet,
__maybe_unused tv_t *cd, K_TREE *trf_root) __maybe_unused tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -5274,7 +5304,8 @@ static char *cmd_mpayouts(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *u_item, *mp_item, *po_item; K_ITEM *i_username, *u_item, *mp_item, *po_item;
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
@ -5466,7 +5497,8 @@ static int select_list(WM *wm, char *select)
static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username, *i_select; K_ITEM *i_username, *i_select;
K_ITEM *u_item, *p_item, *m_item, ms_look, *wm_item, *ms_item, *wi_item; K_ITEM *u_item, *p_item, *m_item, ms_look, *wm_item, *ms_item, *wi_item;
@ -5815,7 +5847,8 @@ static char *cmd_dsp(__maybe_unused PGconn *conn, __maybe_unused char *cmd,
char *id, __maybe_unused tv_t *now, char *id, __maybe_unused tv_t *now,
__maybe_unused char *by, __maybe_unused char *code, __maybe_unused char *by, __maybe_unused char *code,
__maybe_unused char *inet, __maybe_unused tv_t *notcd, __maybe_unused char *inet, __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
__maybe_unused K_ITEM *i_file; __maybe_unused K_ITEM *i_file;
__maybe_unused char reply[1024] = ""; __maybe_unused char reply[1024] = "";
@ -5861,7 +5894,9 @@ static char *cmd_dsp(__maybe_unused PGconn *conn, __maybe_unused char *cmd,
static char *cmd_stats(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_stats(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused K_TREE *trf_root) __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char tmp[1024], *buf; char tmp[1024], *buf;
const char *name; const char *name;
@ -5949,7 +5984,7 @@ static char *cmd_stats(__maybe_unused PGconn *conn, char *cmd, char *id,
// TODO: add to heartbeat to disable the miner if active and status != "" // TODO: add to heartbeat to disable the miner if active and status != ""
static char *cmd_userstatus(PGconn *conn, char *cmd, char *id, tv_t *now, char *by, static char *cmd_userstatus(PGconn *conn, char *cmd, char *id, tv_t *now, char *by,
char *code, char *inet, __maybe_unused tv_t *cd, char *code, char *inet, __maybe_unused tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, __maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -6016,7 +6051,7 @@ static char *cmd_userstatus(PGconn *conn, char *cmd, char *id, tv_t *now, char *
static char *cmd_marks(PGconn *conn, char *cmd, char *id, static char *cmd_marks(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, char *by, __maybe_unused tv_t *now, char *by,
char *code, char *inet, tv_t *cd, char *code, char *inet, tv_t *cd,
K_TREE *trf_root) K_TREE *trf_root, __maybe_unused bool reload_data)
{ {
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
@ -6535,7 +6570,8 @@ dame:
static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_username; K_ITEM *i_username;
K_ITEM *u_item, *p_item, *m_item, *wm_item, *ms_item, *wi_item; K_ITEM *u_item, *p_item, *m_item, *wm_item, *ms_item, *wi_item;
@ -6740,18 +6776,26 @@ static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id,
} }
/* Show a share status report on the console /* Show a share status report on the console
* Currently: sequence status and OoO info */ * Currently: sequence status, OoO info and max_sockd_count */
static char *cmd_shsta(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_shsta(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused K_TREE *trf_root) __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
char ooo_buf[256]; char ooo_buf[256];
char buf[256]; char buf[256];
int count;
LOGWARNING("OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf))); LOGWARNING("OoO %s", ooo_status(ooo_buf, sizeof(ooo_buf)));
sequence_report(true); sequence_report(true);
K_RLOCK(breakqueue_free);
count = max_sockd_count;
K_RUNLOCK(breakqueue_free);
LOGWARNING(" max_sockd_count=%d", count);
snprintf(buf, sizeof(buf), "ok.%s", cmd); snprintf(buf, sizeof(buf), "ok.%s", cmd);
LOGDEBUG("%s.%s", id, buf); LOGDEBUG("%s.%s", id, buf);
return strdup(buf); return strdup(buf);
@ -6761,7 +6805,8 @@ static char *cmd_userinfo(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, __maybe_unused tv_t *notcd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *ui_item; K_ITEM *ui_item;
USERINFO *userinfo; USERINFO *userinfo;
@ -6850,7 +6895,8 @@ static char *cmd_userinfo(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_btcset(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_btcset(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_btcserver, *i_userpass; K_ITEM *i_btcserver, *i_userpass;
char *btcserver = NULL, *userpass = NULL, *tmp; char *btcserver = NULL, *userpass = NULL, *tmp;
@ -6902,7 +6948,8 @@ static char *cmd_btcset(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_query(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *cd, K_TREE *trf_root) __maybe_unused tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
char cd_buf[DATE_BUFSIZ]; char cd_buf[DATE_BUFSIZ];
@ -7498,7 +7545,8 @@ static char *cmd_locks(__maybe_unused PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *cd, __maybe_unused tv_t *cd,
__maybe_unused K_TREE *trf_root) __maybe_unused K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
bool code_locks = false, code_deadlocks = false; bool code_locks = false, code_deadlocks = false;
bool was_locks = false, was_deadlocks = false; bool was_locks = false, was_deadlocks = false;
@ -7610,7 +7658,8 @@ static void event_tree(K_TREE *the_tree, char *list, char *reply, size_t siz,
static char *cmd_events(__maybe_unused PGconn *conn, char *cmd, char *id, static char *cmd_events(__maybe_unused PGconn *conn, char *cmd, char *id,
tv_t *now, __maybe_unused char *by, tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *cd, K_TREE *trf_root) __maybe_unused tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
K_ITEM *i_action, *i_cmd, *i_list, *i_ip, *i_eventname, *i_lifetime; K_ITEM *i_action, *i_cmd, *i_list, *i_ip, *i_eventname, *i_lifetime;
K_ITEM *i_des, *i_item, *next_item, *o_item; K_ITEM *i_des, *i_item, *next_item, *o_item;
@ -8093,7 +8142,8 @@ static char *cmd_events(__maybe_unused PGconn *conn, char *cmd, char *id,
static char *cmd_high(PGconn *conn, char *cmd, char *id, static char *cmd_high(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *now, __maybe_unused char *by, __maybe_unused tv_t *now, __maybe_unused char *by,
__maybe_unused char *code, __maybe_unused char *inet, __maybe_unused char *code, __maybe_unused char *inet,
__maybe_unused tv_t *cd, K_TREE *trf_root) __maybe_unused tv_t *cd, K_TREE *trf_root,
__maybe_unused bool reload_data)
{ {
bool conned = false; bool conned = false;
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];

3
src/ckdb_dbio.c

@ -7100,7 +7100,7 @@ bool auths_add(PGconn *conn, char *poolinstance, char *username,
char *useragent, char *preauth, char *by, char *code, char *useragent, char *preauth, char *by, char *code,
char *inet, tv_t *cd, K_TREE *trf_root, char *inet, tv_t *cd, K_TREE *trf_root,
bool addressuser, USERS **users, WORKERS **workers, bool addressuser, USERS **users, WORKERS **workers,
int *event) int *event, bool reload_data)
{ {
K_TREE_CTX ctx[1]; K_TREE_CTX ctx[1];
K_ITEM *a_item, *u_item, *w_item; K_ITEM *a_item, *u_item, *w_item;
@ -7131,6 +7131,7 @@ bool auths_add(PGconn *conn, char *poolinstance, char *username,
__func__, __func__,
st = safe_text_nonull(username)); st = safe_text_nonull(username));
FREENULL(st); FREENULL(st);
if (!reload_data)
*event = events_add(EVENTID_INVAUTH, trf_root); *event = events_add(EVENTID_INVAUTH, trf_root);
} }
if (!u_item) if (!u_item)

Loading…
Cancel
Save