Browse Source

Add ckdbq entries outside of the instance lock in update_workerstats

master
Con Kolivas 10 years ago
parent
commit
15a4fd91a6
  1. 22
      src/stratifier.c

22
src/stratifier.c

@ -364,6 +364,14 @@ struct stratifier_data {
typedef struct stratifier_data sdata_t; typedef struct stratifier_data sdata_t;
typedef struct json_entry json_entry_t;
struct json_entry{
json_entry_t *next;
json_entry_t *prev;
json_t *val;
};
/* Priority levels for generator messages */ /* Priority levels for generator messages */
#define GEN_LAX 0 #define GEN_LAX 0
#define GEN_NORMAL 1 #define GEN_NORMAL 1
@ -3684,6 +3692,7 @@ out:
* avoid floods of stat data coming at once. */ * avoid floods of stat data coming at once. */
static void update_workerstats(ckpool_t *ckp, sdata_t *sdata) static void update_workerstats(ckpool_t *ckp, sdata_t *sdata)
{ {
json_entry_t *json_list = NULL, *entry, *tmpentry;
user_instance_t *user, *tmp; user_instance_t *user, *tmp;
char cdfield[64]; char cdfield[64];
time_t now_t; time_t now_t;
@ -3716,8 +3725,8 @@ static void update_workerstats(ckpool_t *ckp, sdata_t *sdata)
continue; continue;
DL_FOREACH(user->worker_instances, worker) { DL_FOREACH(user->worker_instances, worker) {
double ghs1, ghs5, ghs60, ghs1440; double ghs1, ghs5, ghs60, ghs1440;
int elapsed;
json_t *val; json_t *val;
int elapsed;
/* Send one lot of stats once the worker is idle if /* Send one lot of stats once the worker is idle if
* they have submitted no shares in the last 10 minutes * they have submitted no shares in the last 10 minutes
@ -3744,10 +3753,19 @@ static void update_workerstats(ckpool_t *ckp, sdata_t *sdata)
"createcode", __func__, "createcode", __func__,
"createinet", ckp->serverurl[0]); "createinet", ckp->serverurl[0]);
worker->notified_idle = worker->idle; worker->notified_idle = worker->idle;
ckdbq_add(ckp, ID_WORKERSTATS, val); entry = ckalloc(sizeof(json_entry_t));
entry->val = val;
DL_APPEND(json_list, entry);
} }
} }
ck_runlock(&sdata->instance_lock); ck_runlock(&sdata->instance_lock);
/* Add all entries outside of the instance lock */
DL_FOREACH_SAFE(json_list, entry, tmpentry) {
ckdbq_add(ckp, ID_WORKERSTATS, entry->val);
DL_DELETE(json_list, entry);
free(entry);
}
} }
static void *statsupdate(void *arg) static void *statsupdate(void *arg)

Loading…
Cancel
Save