Browse Source

api: fix histo thread param

master
Tanguy Pruvot 10 years ago
parent
commit
cc05128ae3
  1. 17
      api.cpp

17
api.cpp

@ -205,19 +205,15 @@ static char *getstats(char *params)
static char *gethistory(char *params) static char *gethistory(char *params)
{ {
struct stats_data data[20]; struct stats_data data[20];
int thr = atoi(params ? params : "-1"); int thr = params ? atoi(params) : -1;
char *p = buffer; char *p = buffer;
if (!thr)
thr = -1;
*buffer = '\0'; *buffer = '\0';
int records = stats_get_history(thr, data, ARRAY_SIZE(data)); int records = stats_get_history(thr, data, ARRAY_SIZE(data));
for (int i = 0; i < records; i++) { for (int i = 0; i < records; i++) {
char time[16];
time_t ts = data[i].tm_stat; time_t ts = data[i].tm_stat;
time2str(time, ts); p += sprintf(p, "GPU=%d;KHS=%.2f;DIFF=%.6f;COUNT=%u;FOUND=%u;TS=%u|",
p += sprintf(p, "GPU=%d;KHS=%.2f;DIFF=%.6f;COUNT=%u;FOUND=%u;TS=%u;TIME=%s|",
data[i].gpu_id, data[i].hashrate, data[i].difficulty, data[i].hashcount, data[i].gpu_id, data[i].hashrate, data[i].difficulty, data[i].hashcount,
data[i].hashfound, (uint32_t)ts, time); data[i].hashfound, (uint32_t)ts);
} }
return buffer; return buffer;
} }
@ -508,14 +504,17 @@ static void api()
} }
buf[n] = '\0'; buf[n] = '\0';
if (opt_debug && opt_protocol && n > 0) //if (opt_debug && opt_protocol && n > 0)
applog(LOG_DEBUG, "API: recv command: (%d) '%s'+char(%x)", n, buf, buf[n-1]); // applog(LOG_DEBUG, "API: recv command: (%d) '%s'+char(%x)", n, buf, buf[n-1]);
if (!fail) { if (!fail) {
params = strchr(buf, '|'); params = strchr(buf, '|');
if (params != NULL) if (params != NULL)
*(params++) = '\0'; *(params++) = '\0';
if (opt_debug && opt_protocol && n > 0)
applog(LOG_DEBUG, "API: exec command %s(%s)", buf, params);
for (i = 0; i < CMDMAX; i++) { for (i = 0; i < CMDMAX; i++) {
if (strcmp(buf, cmds[i].name) == 0) { if (strcmp(buf, cmds[i].name) == 0) {
result = (cmds[i].func)(params); result = (cmds[i].func)(params);

Loading…
Cancel
Save