|
|
@ -3936,7 +3936,7 @@ static void update_workerstats(ckpool_t *ckp, sdata_t *sdata) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void add_log_entry(log_entry_t *entries, char **fname, char **buf) |
|
|
|
static void add_log_entry(log_entry_t **entries, char **fname, char **buf) |
|
|
|
{ |
|
|
|
{ |
|
|
|
log_entry_t *entry = ckalloc(sizeof(log_entry_t)); |
|
|
|
log_entry_t *entry = ckalloc(sizeof(log_entry_t)); |
|
|
|
|
|
|
|
|
|
|
@ -3944,18 +3944,18 @@ static void add_log_entry(log_entry_t *entries, char **fname, char **buf) |
|
|
|
*fname = NULL; |
|
|
|
*fname = NULL; |
|
|
|
entry->buf = *buf; |
|
|
|
entry->buf = *buf; |
|
|
|
*buf = NULL; |
|
|
|
*buf = NULL; |
|
|
|
DL_APPEND(entries, entry); |
|
|
|
DL_APPEND(*entries, entry); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void dump_log_entries(log_entry_t *entries) |
|
|
|
static void dump_log_entries(log_entry_t **entries) |
|
|
|
{ |
|
|
|
{ |
|
|
|
log_entry_t *entry, *tmpentry; |
|
|
|
log_entry_t *entry, *tmpentry; |
|
|
|
FILE *fp; |
|
|
|
FILE *fp; |
|
|
|
|
|
|
|
|
|
|
|
DL_FOREACH_SAFE(entries, entry, tmpentry) { |
|
|
|
DL_FOREACH_SAFE(*entries, entry, tmpentry) { |
|
|
|
DL_DELETE(entries, entry); |
|
|
|
DL_DELETE(*entries, entry); |
|
|
|
fp = fopen(entry->fname, "we"); |
|
|
|
fp = fopen(entry->fname, "we"); |
|
|
|
if (likely(!fp)) { |
|
|
|
if (likely(fp)) { |
|
|
|
fprintf(fp, "%s", entry->buf); |
|
|
|
fprintf(fp, "%s", entry->buf); |
|
|
|
fclose(fp); |
|
|
|
fclose(fp); |
|
|
|
} else |
|
|
|
} else |
|
|
@ -3985,14 +3985,14 @@ static void *statsupdate(void *arg) |
|
|
|
char suffix360[16], suffix1440[16], suffix10080[16]; |
|
|
|
char suffix360[16], suffix1440[16], suffix10080[16]; |
|
|
|
char_entry_t *char_list = NULL, *char_t, *chartmp_t; |
|
|
|
char_entry_t *char_list = NULL, *char_t, *chartmp_t; |
|
|
|
stratum_instance_t *client, *tmp; |
|
|
|
stratum_instance_t *client, *tmp; |
|
|
|
|
|
|
|
log_entry_t *log_entries = NULL; |
|
|
|
user_instance_t *user, *tmpuser; |
|
|
|
user_instance_t *user, *tmpuser; |
|
|
|
int idle_workers = 0; |
|
|
|
int idle_workers = 0; |
|
|
|
char fname[512] = {}; |
|
|
|
char *fname, *s; |
|
|
|
tv_t now, diff; |
|
|
|
tv_t now, diff; |
|
|
|
ts_t ts_now; |
|
|
|
ts_t ts_now; |
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
FILE *fp; |
|
|
|
FILE *fp; |
|
|
|
char *s; |
|
|
|
|
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
tv_time(&now); |
|
|
|
tv_time(&now); |
|
|
@ -4058,17 +4058,10 @@ static void *statsupdate(void *arg) |
|
|
|
"lastupdate", now.tv_sec, |
|
|
|
"lastupdate", now.tv_sec, |
|
|
|
"bestshare", worker->best_diff); |
|
|
|
"bestshare", worker->best_diff); |
|
|
|
|
|
|
|
|
|
|
|
snprintf(fname, 511, "%s/workers/%s", ckp->logdir, worker->workername); |
|
|
|
ASPRINTF(&fname, "%s/workers/%s", ckp->logdir, worker->workername); |
|
|
|
fp = fopen(fname, "we"); |
|
|
|
|
|
|
|
if (unlikely(!fp)) { |
|
|
|
|
|
|
|
LOGERR("Failed to fopen %s", fname); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER | JSON_EOL); |
|
|
|
s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER | JSON_EOL); |
|
|
|
fprintf(fp, "%s", s); |
|
|
|
add_log_entry(&log_entries, &fname, &s); |
|
|
|
dealloc(s); |
|
|
|
|
|
|
|
json_decref(val); |
|
|
|
json_decref(val); |
|
|
|
fclose(fp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Decay times per user */ |
|
|
|
/* Decay times per user */ |
|
|
@ -4108,25 +4101,22 @@ static void *statsupdate(void *arg) |
|
|
|
"workers", user->workers, |
|
|
|
"workers", user->workers, |
|
|
|
"bestshare", user->best_diff); |
|
|
|
"bestshare", user->best_diff); |
|
|
|
|
|
|
|
|
|
|
|
snprintf(fname, 511, "%s/users/%s", ckp->logdir, user->username); |
|
|
|
ASPRINTF(&fname, "%s/users/%s", ckp->logdir, user->username); |
|
|
|
fp = fopen(fname, "we"); |
|
|
|
s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER | JSON_EOL); |
|
|
|
if (unlikely(!fp)) { |
|
|
|
add_log_entry(&log_entries, &fname, &s); |
|
|
|
LOGERR("Failed to fopen %s", fname); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER); |
|
|
|
|
|
|
|
fprintf(fp, "%s\n", s); |
|
|
|
|
|
|
|
if (!idle) { |
|
|
|
if (!idle) { |
|
|
|
char_t = ckalloc(sizeof(char_entry_t)); |
|
|
|
char_t = ckalloc(sizeof(char_entry_t)); |
|
|
|
|
|
|
|
s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER); |
|
|
|
ASPRINTF(&char_t->buf, "User %s:%s", user->username, s); |
|
|
|
ASPRINTF(&char_t->buf, "User %s:%s", user->username, s); |
|
|
|
DL_APPEND(char_list, char_t); |
|
|
|
DL_APPEND(char_list, char_t); |
|
|
|
} |
|
|
|
} |
|
|
|
dealloc(s); |
|
|
|
|
|
|
|
json_decref(val); |
|
|
|
json_decref(val); |
|
|
|
fclose(fp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
ck_runlock(&sdata->instance_lock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Dump log entries out of instance_lock */ |
|
|
|
|
|
|
|
dump_log_entries(&log_entries); |
|
|
|
|
|
|
|
|
|
|
|
DL_FOREACH_SAFE(char_list, char_t, chartmp_t) { |
|
|
|
DL_FOREACH_SAFE(char_list, char_t, chartmp_t) { |
|
|
|
LOGNOTICE("%s", char_t->buf); |
|
|
|
LOGNOTICE("%s", char_t->buf); |
|
|
|
DL_DELETE(char_list, char_t); |
|
|
|
DL_DELETE(char_list, char_t); |
|
|
@ -4155,10 +4145,11 @@ static void *statsupdate(void *arg) |
|
|
|
ghs10080 = stats->dsps10080 * nonces; |
|
|
|
ghs10080 = stats->dsps10080 * nonces; |
|
|
|
suffix_string(ghs10080, suffix10080, 16, 0); |
|
|
|
suffix_string(ghs10080, suffix10080, 16, 0); |
|
|
|
|
|
|
|
|
|
|
|
snprintf(fname, 511, "%s/pool/pool.status", ckp->logdir); |
|
|
|
ASPRINTF(&fname, "%s/pool/pool.status", ckp->logdir); |
|
|
|
fp = fopen(fname, "we"); |
|
|
|
fp = fopen(fname, "we"); |
|
|
|
if (unlikely(!fp)) |
|
|
|
if (unlikely(!fp)) |
|
|
|
LOGERR("Failed to fopen %s", fname); |
|
|
|
LOGERR("Failed to fopen %s", fname); |
|
|
|
|
|
|
|
dealloc(fname); |
|
|
|
|
|
|
|
|
|
|
|
JSON_CPACK(val, "{si,si,si,si,si,si}", |
|
|
|
JSON_CPACK(val, "{si,si,si,si,si,si}", |
|
|
|
"runtime", diff.tv_sec, |
|
|
|
"runtime", diff.tv_sec, |
|
|
|