Browse Source

Drop and regain lock in statsupdate to minimise lock contention

master
ckolivas 8 years ago
parent
commit
aa4e2790e9
  1. 5
      src/stratifier.c

5
src/stratifier.c

@ -7135,7 +7135,7 @@ static void *statsupdate(void *arg)
tv_time(&now); tv_time(&now);
timersub(&now, &stats->start_time, &diff); timersub(&now, &stats->start_time, &diff);
/* Use this locking as an opportunity to test clients. */ /* Test clients. */
ck_rlock(&sdata->instance_lock); ck_rlock(&sdata->instance_lock);
HASH_ITER(hh, sdata->stratum_instances, client, tmp) { HASH_ITER(hh, sdata->stratum_instances, client, tmp) {
/* Look for clients that may have been dropped which the /* Look for clients that may have been dropped which the
@ -7172,7 +7172,10 @@ static void *statsupdate(void *arg)
continue; continue;
} }
} }
ck_runlock(&sdata->instance_lock);
/* Drop and regain lock to minimise lock hold time */
ck_rlock(&sdata->instance_lock);
HASH_ITER(hh, sdata->user_instances, user, tmpuser) { HASH_ITER(hh, sdata->user_instances, user, tmpuser) {
worker_instance_t *worker; worker_instance_t *worker;
bool idle = false; bool idle = false;

Loading…
Cancel
Save