Browse Source

Dump the user stats to log in statsupdate outside of lock

master
Con Kolivas 10 years ago
parent
commit
f01bb374b7
  1. 23
      src/stratifier.c

23
src/stratifier.c

@ -372,6 +372,14 @@ struct json_entry{
json_t *val;
};
typedef struct char_entry char_entry_t;
struct char_entry {
char_entry_t *next;
char_entry_t *prev;
char *buf;
};
/* Priority levels for generator messages */
#define GEN_LAX 0
#define GEN_NORMAL 1
@ -3798,6 +3806,7 @@ static void *statsupdate(void *arg)
double tdiff, per_tdiff;
char suffix1[16], suffix5[16], suffix15[16], suffix60[16], cdfield[64];
char suffix360[16], suffix1440[16], suffix10080[16];
char_entry_t *char_list = NULL, *char_t, *chartmp_t;
user_instance_t *instance, *tmpuser;
stratum_instance_t *client, *tmp;
double sps1, sps5, sps15, sps60;
@ -3926,14 +3935,24 @@ static void *statsupdate(void *arg)
}
s = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER);
fprintf(fp, "%s\n", s);
if (!idle)
LOGNOTICE("User %s:%s", instance->username, s);
if (!idle) {
char_t = ckalloc(sizeof(char_entry_t));
ASPRINTF(&char_t->buf, "User %s:%s", instance->username, s);
DL_APPEND(char_list, char_t);
}
dealloc(s);
json_decref(val);
fclose(fp);
}
ck_runlock(&sdata->instance_lock);
DL_FOREACH_SAFE(char_list, char_t, chartmp_t) {
LOGNOTICE("%s", char_t->buf);
DL_DELETE(char_list, char_t);
free(char_t->buf);
dealloc(char_t);
}
ghs1 = stats->dsps1 * nonces;
suffix_string(ghs1, suffix1, 16, 0);
sps1 = stats->sps1;

Loading…
Cancel
Save