Browse Source

Count dropped workers in _dec_instance_ref

Conflicts:
	src/stratifier.c
master
Con Kolivas 10 years ago
parent
commit
c6336cdc26
  1. 9
      src/stratifier.c

9
src/stratifier.c

@ -1356,11 +1356,15 @@ static void client_drop_message(const int64_t client_id, const int dropped, cons
} }
} }
static void dec_worker(ckpool_t *ckp, user_instance_t *instance);
/* Decrease the reference count of instance. */ /* Decrease the reference count of instance. */
static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const char *file, static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const char *file,
const char *func, const int line) const char *func, const int line)
{ {
user_instance_t *user = client->user_instance;
int64_t client_id = client->id; int64_t client_id = client->id;
ckpool_t *ckp = client->ckp;
int dropped = 0, ref; int dropped = 0, ref;
ck_wlock(&sdata->instance_lock); ck_wlock(&sdata->instance_lock);
@ -1368,7 +1372,7 @@ static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const
/* See if there are any instances that were dropped that could not be /* See if there are any instances that were dropped that could not be
* moved due to holding a reference and drop them now. */ * moved due to holding a reference and drop them now. */
if (unlikely(client->dropped && !ref)) if (unlikely(client->dropped && !ref))
dropped = __drop_client(sdata, client, client->user_instance); dropped = __drop_client(sdata, client, user);
ck_wunlock(&sdata->instance_lock); ck_wunlock(&sdata->instance_lock);
client_drop_message(client_id, dropped, true); client_drop_message(client_id, dropped, true);
@ -1376,6 +1380,9 @@ static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const
/* This should never happen */ /* This should never happen */
if (unlikely(ref < 0)) if (unlikely(ref < 0))
LOGERR("Instance ref count dropped below zero from %s %s:%d", file, func, line); LOGERR("Instance ref count dropped below zero from %s %s:%d", file, func, line);
if (dropped)
dec_worker(ckp, user);
} }
#define dec_instance_ref(sdata, instance) _dec_instance_ref(sdata, instance, __FILE__, __func__, __LINE__) #define dec_instance_ref(sdata, instance) _dec_instance_ref(sdata, instance, __FILE__, __func__, __LINE__)

Loading…
Cancel
Save